Skip to content
Business logic Audit finding Intermediate

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.

Protocol Team Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-06-dodo-judging/issues/242

Found by

Protocol Team

Vulnerability Detail

https://github.com/sherlock-audit/2023-06-dodo/blob/a8d30e611acc9762029f8756d6a5b81825faf348/new-dodo-v3/contracts/DODOV3MM/D3Pool/D3Maker.sol#L158C1-L178C57

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.

Solidity
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.

The original report as published on Sherlock, by Protocol Team. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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.

More by Protocol Team

View all

8 more disclosed reports, best first.

More from DODO V3 update

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.