Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: medium
Valid

The total value across all tokens is stored incorrectly

Summary

The total value across all tokens is stored incorrectly in the Treasury contract.

Vulnerability Details

When deposits are made to the Treasury address, the storage variable _totalValue is incremented by the amount of tokens transferred. The Treasury contract is expected to support multiple ERC20 tokens. These tokens can have different decimals, making _totalValue inaccurate for storing the total value across all tokens.

Additionally, a malicious user can create a malicious ERC20 contract to make a deposit where amount = type(uint256).max, causing _totalValue to reach its maximum value. This will result in every new deposit being reverted, as _totalValue += amount will overflow every time.

Impact

The total value across all tokens is stored incorrectly, which can lead to the Treasury's deposit function being blocked.

Tools Used

Mannual Review

Recommendations

Allow only approved tokens to be deposited in the Treasury contract and store the total value separately for each token using mapping(address => uint256) private tokenTotalValue;.

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Treasury::deposit increments _totalValue regardless of the token, be it malicious, different decimals, FoT etc.

Support

FAQs

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