Skip to content
Business logic Audit finding Intermediate

Users could shift tokens on Staker with more than he has staked

The Staker contract's shiftTokens function only checked the amount to shift against the user's staked balance, but did not account for multiple shifts before a price update. An attacker could call shiftTokens repeatedly to shift more tokens than they had staked, potentially manipulating the system for personal gain.

shw Follow

Originally disclosed on Code4rena

Submitted by shw

The shiftTokens function of Staker checks whether the user has staked at least the number of tokens he wants to shift from one side to the other (line 885). A user could call the shiftTokens function multiple times before the next price update to shift the staker’s token from one side to the other with more than he has staked. Staker.sol#L885

Recommend adding checks on userNextPrice_amountStakedSyntheticToken_toShiftAwayFrom_long and userNextPrice_amountStakedSyntheticToken_toShiftAwayFrom_short to ensure that the sum of the two variables does not exceed user’s stake balance.

JasoonS (Float) confirmed:

Yes, spot on! We spotted this the next morning after launching the competition. Token shifting was a last minute addition to the codebase. Really glad someone spotted it, but only in the last few hours, phew!

This would allow a malicious user to completely shift all the tokens (even those not belonging to them to one side or the other!!) No funds could be stolen by the user directly (since the execution of those shifts would fail on the user level), but it could be done for personal gain (eg improving the users FLT issuance rate, or similar economic manipulation).

The original report as published on Code4rena, by shw. 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

The contract checked each shift against the user's staked balance but did not track cumulative shifts before the next price update, allowing the total shifted amount to exceed the stake.

Impact

A malicious user could shift all tokens, including those not belonging to them, to one side, potentially gaining personal advantage such as improved FLT issuance, though direct theft was not possible because shifts would fail at the user level.

What the attacker needed

A staked position in the Staker contract

The fix

The fix should add checks on the pending shift amounts to ensure their sum does not exceed the user's stake balance.

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.

In a staking contract, users can move their staked tokens between two sides. The contract checked each move against the user's balance, but didn't consider that a user could make several moves before the balance was updated. This let someone move more tokens than they actually owned, which could be used to game rewards.

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 shw

View all

22 more disclosed reports, best first.

More from Float Capital contest

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.