Unhandled Bailout During AbstractInstructi #6810
Labels
bug
Something isn't working
compiler: codegen
Everything to do with IR->ASM, register allocation, etc.
P: high
Should be looked at if there are no critical issues left
team:compiler
Compiler Team
From https://reports.immunefi.com/fuel-network-or-attackathon/attackathon-_-fuel-network-32438-smart-contract-low-unhandled-bailout-during-abstractinstructionset
const_indexing_aggregates_function() process VirtualOp::LW without handling the case if the offset in addr_reg is not aligned to 8, resulting in the old constant being used and leading to incorrect program behavior.
Vulnerability Details
While processing a VirtualOp::LW with non-aligned address offset, const_indexing_aggregates_function() does not clear register information in reg_contents and setup a new definition with record_new_def(). This means the old state of the register stored in reg_contents will still be used, causing incorrect value tracking after the LW instruction. The incorrect tracking may then cause incorrect immediate replacement in other instructions.
Impact Details
As usual, it is hard to come up with a precise impact estimation of incorrect code generation because it depends on what code the user writes. The best case scenario would be contracts that run into those bugs getting bricked, and the worst case scenario would be that incorrect program behaviors lead to loss of funds.
References
sway/sway-core/src/asm_generation/fuel/optimizations.rs
Line 155 in 7b56ec7
Proof of concept
This test would fail because addi a a i15 incorrectly uses the reg values before lw a a i0
The text was updated successfully, but these errors were encountered: