Description The makeMerkle.js
script generates the Merkle Tree root (s_merkleRoot
) used within the Deploy.s.sol
script. However, there is a discrepancy in the decimal precision settings: while the script utilizes 1e18
as a base value, the USDC token, which interacts with the contract, has only 6 decimals (i.e., 1e6
). Consequently, the calculation of the s_merkleRoot
value in the deployment script is incorrect due to this precision mismatch. This inconsistency poses a critical issue as it prevents the contract from accurately verifying Merkle proofs provided by users. Without proper verification, the contract is vulnerable to denial-of-service (DoS) attacks, as none of the chosen users would be able to claim their tokens.
Impact If the current deploy script is used as is, none of the users would be able to claim their tokens, due to invalid Merkle Tree proof calculations. This in turn will render the protocol useless.
Proof of Concept The DoS attack is shown in the MerkleAirdropTest::test_deploy_script_makes_protocol_unusable
test. For the sake of the test, the bytes32 public merkleRoot
value in the test MerkleAirdropTest.t.sol
was changed to the one generated (i.e. 0xf69aaa25bd4dd10deb2ccd8235266f7cc815f6e9d539e9f4d47cae16e0c36a05
) from the JS script. Also, the bytes32 proofOne
and bytes32 proofTwo
values were changed to correspond to the JS script generated one (i.e. 0x4fd31fee0e75780cd67704fbc43caee70fddcaa43631e2e1bc9fb233fada2394
and 0xc88d18957ad6849229355580c1bde5de3ae3b78024db2e6c2a9ad674f7b59f84
).
Tools used Manual review + Foundry
Recommended Mitigation One feasible solution involves regenerating a new Merkle Tree Root with the correct amount and substituting that value in the Deploy.s.sol
script before deploying the protocol. This ensures that the correct amount is used in the Merkle proofs, aligning with the token's decimal precision and preventing potential verification failures. Alternatively, implementing a mechanism for the owner to dynamically set a new Merkle Root value offers flexibility in handling scenarios involving invalid amounts or addresses. This approach allows for the distribution of tokens even in the presence of discrepancies. Additionally, it enables the utilization of the currently unused MerkleRootUpdated event. However, it's essential to exercise caution with this solution. Granting the owner the ability to set the Merkle Root dynamically opens up the possibility of malicious behavior. The owner could potentially exploit this capability to drain the contract of tokens by setting arbitrary Merkle Root values. Therefore, strict access controls and thorough auditing mechanisms should be implemented to mitigate the risk of misuse.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.