It's dangerous for makers to set token decimal by manual
A smart contract function that registers a new token stores the token's decimal value as a maker-supplied input without checking it against the token itself. If a maker enters the wrong decimal, swaps involving that token would transfer more or less than the expected amount.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-06-dodo-judging/issues/242
Found by
Protocol Team
Vulnerability Detail
Contract does not check decimal but record the variable directly.
Impact
If maker entered wrong decimal, swap will transfer more or less amount than expected.
Tool Used
Manual Review
Recommandation
In setNewToken function, taking token decimal through token's interface rather than entering by maker.
state.tokenMMInfoMap[token].decimal = IERC20(token).decimal();
Discussion
Attens1423
in new calculation model, we don't need token decimal anymore. fix pr:https://github.com/DODOEX/new-dodo-v3/pull/32
hrishibhat
Please note: This issue is not part of the contest submissions and is not eligible for contest rewards.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
If a maker enters the wrong decimal, swaps could transfer more or less of the token than expected.
What the attacker needed
Maker sets up a new token; maker enters an incorrect decimal
The fix
The recommendation was to read the decimal from the token's own interface inside setNewToken rather than accepting it from the maker; the team later said the new calculation model no longer needs the decimal at all.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Tokens on a blockchain can have different numbers of decimal places, and the contract uses that number to work out how much of a token to move. Here the person setting up the token typed the number in by hand instead of asking the token contract for it, so a typo would make every swap move the wrong amount.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.