Submitted by bronze_pickaxe, also found by Zubat
Inside PreimageOracle.sol, anyone can call the loadPrecompilePreimagePart() to load data into the contract. The problem is that anyone is able to specify the address _precompile parameter. This opens up the door for malicious users to pre-populate data and use it to validate wrong data.
PreimageOracle.readPreimage() is used to read already validated preimage_data, this happens in the MIPS.sol implementation and the mips.go implementation:
mips.go
mips.sol
Looking at readPreimage, we can notice this check that happens that ensures the field is set to true:
Now, a malicious user can use the address of the next precompile to be added as a parameter, specify the data he wants to be pass and it will set the flag to true, enabling the ability to read the preimage with invalid data.
Put this test in PreimageOracle.t.sol:
Running it, this is the output:
This means that the calls from cannon and mips.sol can all succeed, leading to malicious users crafting data such that they can validate invalid proofs because the storage can be pre-populated and when doing a read on the precompileimage, it will be true and succeed.
obront (judge) commented:
refcell (Optimism) disputed and commented:
bronze_pickaxe (warden) commented:
ajsutton (Optimism) commented:
obront (judge) commented:
clabby (Optimism) confirmed
