Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

`makeMerkle.js` provides incorrect merkleRoot due to `amount` being of 18 decimals which directly affects `MerkleAirdrop` contract and prevent users from claiming

Summary

The USDC token used for Airdrop is USDC token which is of 6 decimal on zkSync.

The amount used for calculation of Merkle root for every winner is 25 USDC, therefore it should be 25 * 1e6 considering the 6 decimals of USDC token, but the actual amount used is 25 * 1e18 which directly affects the calculated root and makes the Airdrop unclaimable and also results in locked funds.

Vulnerability Details

  • The vulnerability is present in the makeMerkle.js file which is used to get the Merkle root and that calculated root is directly used in Deploy.s.sol which sets the Merkle root in MerkleAirdrop contract, thus affecting the functionality of MerkleAirdrop contract.

  • The USDC token has 6 decimals but the Merkle root is calculated using 18 decimals for the amount calculation for each winner. But as the actual decimal is 6, therefore the set amount 25 * 1e18 will not be equivalent to 25 USDC but it will be 25 * 1e12 USDC.

  • As a result of which when a user tries to claim there Airdrop with amount being 25 * 1e6 (25 USDC), the call will revert as the nodes of Merkle tree were made by 25 * 1e18 as amount and no one will be able to claim the Airdrop.

Impact

  • Incorrect Merkle root used in Deploy scripts.

  • No one will be able to claim the Airdrop.

  • Locked Airdrop token balance inside MerkleAirdrop contract.

Tools Used

Manual Review

Recommendations

Recalculate the Merkle root used in Deploy scripts by correcting the decimal of amount in makeMerkle.js.

  • Correct the amount in makeMerkle.js at line 7

- const amount = (25 * 1e18).toString()
+ const amount = (25 * 1e6).toString()
  • Recalculate the Merkle Root my running yarn run makeMerkle

$ node makeMerkle.js
+ Merkle Root: 0x3b2e22da63ae414086bec9c9da6b685f790c6fab200c7918f2879f08793d77bd
Proof for address: 0x20F41376c713072937eb02Be70ee1eD0D639966C with amount: 25000000:
[
'0x32cee63464b09930b5c3f59f955c86694a4c640a03aa57e6f743d8a3ca5c8838',
'0x8ff683185668cbe035a18fccec4080d7a0331bb1bbc532324f40501de5e8ea5c'
]
Done in 0.22s.
  • Update the Merkle Root inside Deploy.s.sol at line 9

- bytes32 public s_merkleRoot = 0xf69aaa25bd4dd10deb2ccd8235266f7cc815f6e9d539e9f4d47cae16e0c36a05;
+ bytes32 public s_merkleRoot = 0x3b2e22da63ae414086bec9c9da6b685f790c6fab200c7918f2879f08793d77bd;
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

wrong-usdc-decimals-in-merkle

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.