Skip to content
Business logic Audit finding Intermediate

Incorrect withdrawal requested

The withdrawal function calculated a capped amount but then requested the uncapped amount from the Tokemak pool, so when the balance was lower than the requested amount, the contract asked to withdraw more than it held. An attacker could trigger this to request an excessive withdrawal, potentially causing a failure or draining more than intended.

Anurag Jain Follow

Originally disclosed on Code4rena

Submitted by csanuragjain, also found by MiloTruck

\_requestWithdrawalFromTokemak function :: Instead of sending amountToRequest for requestWithdrawal, contract is asking _amount for requestWithdrawal. This becomes a problem when balance < _amount and only balance could be withdrawn

Proof of Concept

  1. In _requestWithdrawalFromTokemak function, amountToRequest is calculated as
// the only way balance < _amount is when using unstakeAllFromTokemak
        uint256 amountToRequest = balance < _amount ? balance : _amount;
  1. Now assuming balance < _amount then amountToRequest becomes balance
  2. But tokePoolContract.requestWithdrawal is called over _amount instead of amountToRequest which means withdrawal is requested over an extra amount

Recommended Mitigation Steps

Modify Staking.sol#L326 to

if (amountToRequest > 0) tokePoolContract.requestWithdrawal(amountToRequest);

toshiSat (Yieldy) confirmed and resolved


The original report as published on Code4rena, by csanuragjain. 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 code computed a safe amount (amountToRequest) but then passed the original _amount to the external call instead of the computed value.

Impact

The contract could request a withdrawal larger than its balance, potentially causing the transaction to fail or withdrawing more than intended.

What the attacker needed

Balance < _amount

The fix

The code was fixed by changing the call to use amountToRequest instead of _amount.

How it was found

  1. Call the _requestWithdrawalFromTokemak function with an amount greater than the contract's balance.
  2. The function calculates amountToRequest as the balance because balance < _amount.
  3. The function then calls tokePoolContract.requestWithdrawal with _amount instead of amountToRequest, requesting an excessive withdrawal.

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.

A smart contract function is supposed to withdraw only what is available when the requested amount is too high. Instead, it tells the external pool to withdraw the full requested amount, which can be more than the contract actually has. This mistake could cause the withdrawal to fail or take too much.

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 Anurag Jain

View all

63 more disclosed reports, best first.

More from Yieldy 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.