Skip to content

fix(fuzz): constrain comparison-mutated bools - #17683

Open
decofe wants to merge 4 commits into
masterfrom
centaur/fix-guided-corpus-abi-validation-1792449347
Open

decofe wants to merge 4 commits into
masterfrom
centaur/fix-guided-corpus-abi-validation-1792449347

Conversation

@decofe

@decofe decofe commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Comparison-guided fuzz mutations can turn a Solidity bool argument into a noncanonical ABI word such as 4. The Alloy runtime ABI decoder interprets it as true, but Solidity rejects the call before the handler runs; with fail_on_revert, this can report a false invariant failure.

Accept a comparison mutation only when Alloy re-encodes its decoded arguments to the same argument bytes, rejecting noncanonical bools (including nested values) without rewriting calldata. The existing enum-variant check remains independent because valid ABI uint8 values can exceed an enum range. The check avoids cloning arguments without enums and does not allocate a selector-prefixed comparison buffer.

Prompted by: @0xalpharush

Comparison-guided mutations can produce noncanonical ABI bool words that decode as true but revert before Solidity handlers run. Re-encode accepted inputs to constrain bools to canonical values, including nested bools, while preserving existing enum validation and skipping no-op mutations.

Co-authored-by: Derek Cofausper <256792747+decofe@users.noreply.github.com>
0xalpharush and others added 3 commits October 19, 2026 22:52
The runtime Alloy ABI decoder accepts noncanonical bool words, but Solidity reverts on them. Accept comparison mutations only when Alloy encodes the decoded input back to the original mutated calldata. This uses the existing enum rejection path and avoids rewriting the call bytes.

Co-authored-by: Derek Cofausper <256792747+decofe@users.noreply.github.com>
Check enum validity without cloning arguments that do not contain a declared enum. Compare encoded argument bytes directly instead of constructing a second selector-prefixed calldata buffer. The mutation acceptance rules remain unchanged.

Co-authored-by: Derek Cofausper <256792747+decofe@users.noreply.github.com>
Comment on lines +592 to +594
&& function
.abi_encode_input_raw(&inputs)
.is_ok_and(|encoded| encoded == calldata[4..])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact re-encoding check fixes bools, but it also rejects cmp mutations that Solidity accepts. Two examples are a shortened bytes or array length, and strings with non-UTF-8 bytes. Alloy re-encodes with zero padding and decodes strings lossily, so the bytes don't match.

Comparing base and head with corpus_dir set:

  • A UTF-8 parsing bug was found on 8/8 seeds on base and 0/8 on head.
  • Length guards were found 24/24 on base and 0/24 on head with only cmp mutation enabled. With default weights head was much slower or missed them.

Could this validate bool words directly instead of comparing the whole calldata?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants