The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: low
Invalid

`abi.encodePacked()` should not be used for mappings' IDs

by CarlosAlegreUr

abi.encodePacked() should not be used for mappings' IDs đŸ”ĸ

Summary 📌

â„šī¸ Note 📘: Aderyn caught the use of abi.encodePacked() in some files of the system that are out of socope. But there are files in-scope that suffer from this problem and in a different way. In the Aderyn cases the use of abi.encodePacked() is highligthed when generatin NFT string type metadata in NFTMetadataGenerator and the other contracts assosiated with it (all out of scope).

In the LiquidtaionPool contract abi.encodePaked() is used as unique keys for the rewards mapping. As abi.encodePaked() can have the same output for differnet inputs, this ID can someday clash.


Vulnerability Details 🔍 && Impact 📈

The clash of IDs would overwrite the rewards mapping for a user and thus it would overwrite and potentially lose any rewards he might have accumulated from a different asset.


Tools Used đŸ› ī¸

  • Manual audit.


Recommendations đŸŽ¯

Instead of using as ID key abi.encodePacked() use the keccak256() hash function:

- rewards[abi.encodePacked(userAddress, asset.token.symbol)]
+ rewards[keccack256(userAddress, asset.token.symbol)]

🚧 Note âš ī¸: On top of all this the current values that make up the ID could potentially not
be unique enough. Tokens can have the same symbol and this limits the amount of assets your protocol
could use in the future without and ID clash. As current assets do not have shared symbols this is not a problem for now but consider adding something extra for the ID calculation like the asset's contract address.


Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

informational/invalid

charlescheerful Submitter
over 1 year ago
hrishibhat Lead Judge
over 1 year ago
hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

informational/invalid

Support

FAQs

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