You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.
sherlock-admin opened this issue
Mar 13, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
Conflicting Mapping Keys in _decreaseCurrentMinted() Function Can Cause Infinite TAU Token Minting and Incorrect currentMinted Calculation
Summary
In the TAU contract, the accountMinted and currentMinted[msg.sender] variables in the _decreaseCurrentMinted() function refer to the same mapping of currentMinted but accessed using different keys.
This can cause the given mint limit vault to repeatedly call the burnFrom() and mint() functions, thereby minting an infinite number of TAU tokens.
In addition, there is a possibility of incorrect calculation of currentMinted when the burnFrom() function is called.
Vulnerability Detail
For Example:
The governance calls the setMintLimit() function to set a mint limit of 100 for Alice's vault (mintLimit[Alice] = 100).
Alice calls mint() function to mint 100 TAU tokens to Alice's address (currentMinted[Alice] = 100).
Alice executes the burnFrom() function with an amount of zero to any address that has currentMinted = 0. This will also trigger the _decreaseCurrrentMinted() function.
At line 80, since both accountMinted and amount are zero, the currentMinted[msg.sender] value for Alice will also become zero (currentMinted[Alice] = 0).
Thus, Alice can call the mint() function again with a maximum mint limit of 100 TAU tokens.
Alice can repeatedly execute steps 2-5, allowing her to manipulate the currentMinted value and mint an infinite number of TAU tokens.
Impact
The given mint limit vault can arbitrarily mint the TAU tokens.
When the burnFrom() function is called, there is a possibility that the currentMinted value of msg.sender may be calculated incorrectly.
Code Snippet
function mint(addressrecipient, uint256amount) external {
// Check whether mint amount exceeds mintLimit for msg.senderuint256 newMinted = currentMinted[msg.sender] + amount;
if (newMinted > mintLimit[msg.sender]) {
revertmintLimitExceeded(newMinted, mintLimit[msg.sender]);
}
// Update vault currentMinted
currentMinted[msg.sender] = newMinted;
// Mint TAU to recipient_mint(recipient, amount);
}
function _decreaseCurrentMinted(addressaccount, uint256amount) internalvirtual {
// If the burner is a vault, subtract burnt TAU from its currentMinted.// This has a few highly unimportant edge cases which can generally be rectified by increasing the relevant vault's mintLimit.uint256 accountMinted = currentMinted[account];
if (accountMinted >= amount) {
currentMinted[msg.sender] = accountMinted - amount;
}
}
Using totalSupply() from ERC20 instead of currentMinted because the TAU contract is unable to determine whether currentMinted[account] is the minter or not. Additionally, only the TAU contract has been granted permission to mint() TAU tokens.
Also, remove the burnFrom() function and use the burn() function instead since all the addresses used as parameters in the burnFrom() function throughout the entire contract refer to msg.sender.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
LethL
high
Conflicting Mapping Keys in
_decreaseCurrentMinted()
Function Can Cause Infinite TAU Token Minting and IncorrectcurrentMinted
CalculationSummary
In the
TAU
contract, theaccountMinted
andcurrentMinted[msg.sender]
variables in the_decreaseCurrentMinted()
function refer to the same mapping ofcurrentMinted
but accessed using different keys.This can cause the given mint limit vault to repeatedly call the
burnFrom()
andmint()
functions, thereby minting an infinite number of TAU tokens.In addition, there is a possibility of incorrect calculation of
currentMinted
when theburnFrom()
function is called.Vulnerability Detail
For Example:
setMintLimit()
function to set a mint limit of 100 for Alice's vault (mintLimit[Alice] = 100
).mint()
function to mint 100 TAU tokens to Alice's address (currentMinted[Alice] = 100
).burnFrom()
function with an amount of zero to any address that hascurrentMinted = 0
. This will also trigger the_decreaseCurrrentMinted()
function.accountMinted
andamount
are zero, thecurrentMinted[msg.sender]
value for Alice will also become zero (currentMinted[Alice] = 0
).mint()
function again with a maximum mint limit of 100 TAU tokens.currentMinted
value and mint an infinite number of TAU tokens.Impact
burnFrom()
function is called, there is a possibility that thecurrentMinted
value ofmsg.sender
may be calculated incorrectly.Code Snippet
https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/TAU.sol#L35-L47
https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/TAU.sol#L71-L74
https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/TAU.sol#L76-L83
Tool used
Manual Review
Recommendation
Using
totalSupply()
fromERC20
instead ofcurrentMinted
because the TAU contract is unable to determine whethercurrentMinted[account]
is the minter or not. Additionally, only theTAU
contract has been granted permission tomint()
TAU tokens.Also, remove the
burnFrom()
function and use theburn()
function instead since all the addresses used as parameters in theburnFrom()
function throughout the entire contract refer tomsg.sender
.Duplicate of #149
The text was updated successfully, but these errors were encountered: