TempleGold

TempleDAO
Foundry
25,000 USDC
View results
Submission Details
Severity: low
Invalid

Potential breaching of the `MAX_SUPPLY` invariant during TGLD cross-chain transfers

Summary

A vulnerability in the TempleGold smart contract allows for the potential breach of the MAX_SUPPLY invariant due to inadequate checks during the minting process. Specifically, the function _canDistribute can permit distributions that exceed the maximum supply of TGLD tokens, posing a risk of over-minting.

Vulnerability Details

Take a look at https://github.com/Cyfrin/2024-07-templegold/blob/a47602635bf55221404fc9ceb96a8bb6c0db36a2/protocol/contracts/templegold/TempleGold.sol#L188-L190

function _canDistribute(uint256 mintAmount) private view returns (bool) {
return mintAmount != 0 && _totalDistributed + mintAmount == MAX_SUPPLY ? true : mintAmount >= MINIMUM_MINT;
}

This function eventually gets called in the case where there is a need to distribute TGLD tokens. It includes a special logic to allow for the last attempt of minting to directly equal MAX_SUPPLY, which means that at the final attempt, there is no problem if the mintAmount is less than the MINIMUM_MINT. The issue, however, is that the max supply invariant could be breached, because in the case where mintAmount is massive and would make us now pass the value for MAX_SUPPLY, there is no check to stop this.

Impact

A subtle invariant is broken, allowing more than the MAX_SUPPLY to be distributed for TGLD tokens.

Tools Used

Manual review

Recommendations

Introduce a check to ensure that the amount of tokens to be distributed does not exceed the MAX_SUPPLY.

Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

`_canDistribute` could return a result breaking the MAX TOTAL SUPPLY of TGLD

Support

FAQs

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