Reproduced Exploit

mloadPotentiallyPaddedValue returns the word it was supposed to mask

mloadPotentiallyPaddedValue loads a word and, when the read crosses memoryBound, shifts it so the bytes past the bound are zero. The shift is assigned to a new let value inside the if. That inner variable shadows the return variable, so the function returns the original word.

Undated•Ethereum•logic•2 min read

Loss

A word of 0xFFFFFFFF is returned unchanged. The mask clears it to 0xFFFFFF00, so the low byte 0xFF leaks thro…

Chain

Ethereum

Category

logic

Date

Undated

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack replays in your browser. Step through it by Solidity line or by opcode.

The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 56732-inner-variable-shadowing-causes-incorrect-return-in-mloadpot. Standalone Foundry PoC and full write-up: 56732-inner-variable-shadowing-causes-incorrect-return-in-mloadpot_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/variable-shadow · vuln/data/memory-read

Key info#

FieldValue
LossA word of 0xFFFFFFFF is returned unchanged. The mask clears it to 0xFFFFFF00, so the low byte 0xFF leaks through
Vulnerable contractLoader.load
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit at 0x15452ec016c4dc8c549e7fe6ff4b26324ea8b7a4
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 1970-01
Compilersolc 0.8.27, cancun, via IR
Bug classAn inner let value shadows the return variable, so the shift-and-mask is discarded
flowchart TD A["load is called with 0xFFFFFFFF and a shift of 8"] --> B["The inner value is shifted to 0xFFFFFF00"] B --> C["VULN the return variable is still 0xFFFFFFFF"] C --> D["The caller receives the unmasked word"] B --> E["Control writes the mask back to the return variable"] E --> F["The caller receives 0xFFFFFF00"]

TL;DR#

mloadPotentiallyPaddedValue loads a word and, when the read crosses memoryBound, shifts it so the bytes past the bound are zero. The shift is assigned to a new let value inside the if. That inner variable shadows the return variable, so the function returns the original word.

A word of 0xFFFFFFFF with a shift of 8 should come back as 0xFFFFFF00. The function returns 0xFFFFFFFF. The low byte 0xFF is the part the mask cleared. The control returns 0xFFFFFF00.

The finding has no month, so the date marker is 1970-01.

The vulnerable code#

SOLIDITY
value = word;
if (shift > 0) {
    uint256 inner = (value >> shift) << shift;
    masked = inner;
}
returned = value; // @> VULN: the masked inner value is not written back to the return variable

Impact#

Callers of the helper see bytes that sit past the memory bound. Here the returned word keeps 0xFF that the mask had cleared.

How to reproduce#

BASH
cd 56732-inner-variable-shadowing-causes-incorrect-return-in-mloadpot_exp
forge test -vv

test_exploit_returns_the_unmasked_word asserts the return is 0xFFFFFFFF and the mask was 0xFFFFFF00. test_control_returns_the_masked_word asserts 0xFFFFFF00.

Sources#


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • Web3Sec X hacked database: search.
  • Rekt leaderboard: search.
  • Solodit incident search: search.

These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.