Note: At the judges request, this downgraded issue from the same warden has been included in this report for completeness.
ScrollVerifierHooks allows many variations of incorrect proof to pass as long as leafHash == 0. Invalid proofs with incorrect leaf node values will be accepted.
This also violates the invariant: Only correct proofs are accepted. Invalid or unproven inputs are rejected.
The vulnerability here is in scrollVerifierHooks::verifyAccountState/verifyStroageValues, when leafHash == 0, the check on the leafHash == H(leafNode) will be skipped, which allows the proof to contain leafNode of many variations of value.
In ScrollVerifierHooks::walkTree, when a node type is NODE_LEAF, the leaf nodes hash will not be checked. The check is deferred to verifyAccountState/verifyStorageValues.
This means a vulnerable case where the key derives into an empty leaf hash, while the provided proof is NODE_LEAF type. There will be no check on H(leafNode). As long as the provided leaf node from the proof contains the same/partial-matched keyHash. WalkTree will return (keyHash = original keyhash, leafHash = bytes32(0), leaf = incorrect leaf node value, exists = true).
https://github.com/code-423n4/2024-12-unruggable/blob/9e0e908a207f088dd843fcdc3e4de5fa0edd6c5c/contracts/scroll/ScrollVerifierHooks.sol#L121
In verifyAccountState/verifyStorageValue, due to returned leafHash = bytes32(0), this early return 0 value without performing checks on the leaf node value (bytes memory leaf). Although the returned value is still correct ( bytes32 0 or NOT_A_CONTRACT) for non-existent data, the supplied proof has an incorrect leaf node value.
https://github.com/code-423n4/2024-12-unruggable/blob/9e0e908a207f088dd843fcdc3e4de5fa0edd6c5c/contracts/scroll/ScrollVerifierHooks.sol#L48
Some invalid proof will not be rejected. This violates the invariant: Only correct proofs are accepted. Invalid or unproven inputs are rejected.
A malicious prover can submit modified variations of proof to pass validation. Risk of proof validation inconsistency across different verification contexts. Proofs validated by this contract might be rejected off-chain or by other scroll verification processes.
A client contract deriving GatewayFetchTarget.sol will trust a deterministic proof validation system. When multiple invalid proofs can pass validation, although currently doesnt directly allow manipulation of the return data, this may open up complex attack vectors based on the client contracts business logic.
Modifying the leaf node from the original proof will still pass the test. For simplicity, the poc modifies an empty leaf node: 050..0 into 05FF..F. There are other variations as well such as modifying 050..0 into 04 + keyhash + arbitrary byte filler + 20 + keypreiamge.
Run bun test: test/gateway/scroll.test.ts:
Consider moving the leafhash and H(leafnode) check into walkTrees else if (nodeType == NODE_LEAF) branch.
raffy (Unruggable) disputed and commented:
Picodes (judge) decreased severity to Low and commented:
