Skip to content
Smart contracts Audit finding Intermediate

Incorrect type conversion in the contract ABC makes users unable to burn FSD tokens

The contract ABC incorrectly converts a negative int256 parameter to uint256, producing an extremely large number that causes a SafeMath subtraction to revert. This prevents users from burning FSD tokens when the reserve delta is negative.

FairSide contest

Originally disclosed on Code4rena

The function _calculateDeltaOfFSD of contract ABC incorrectly converts an int256 type parameter, _reserveDelta, to uint256 by explicit conversion, which in general results in an extremely large number when the provided parameter is negative. The extremely large number could cause a SafeMath operation sub at line 43 to revert, and thus the FSD tokens cannot be burned as _reserveDelta is negative when burning FSD tokens.

Simply calling fsd.burn after a successful fsd.mint will trigger this bug.

Recommend using the solidity function abs to get the _reserveDelta absolute value.

fairside-core (FairSide) confirmed:

Fixed in PR#1.

The original report as published on Code4rena. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

Root cause

Likely the code explicitly casts a negative int256 to uint256 without taking the absolute value, causing an overflow-like huge number that makes a SafeMath subtraction revert.

Impact

Users cannot burn FSD tokens when the reserve delta is negative, as the burn transaction reverts.

What the attacker needed

Successful fsd.mint

The fix

The code was fixed by using the Solidity abs function to get the absolute value of _reserveDelta before conversion.

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.

Smart contracts sometimes use signed numbers (int256) that can be negative, and unsigned numbers (uint256) that cannot. If you force a negative signed number into an unsigned one, it becomes a huge positive number. That huge number then breaks a subtraction step, so the burn function fails and users cannot burn their tokens.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More from FairSide contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.