Skip to content
Business logic Audit finding Intermediate

Trades where toToken is feeOnTransferToken might send user less tokens than finalAmountMin

The contract checks that the trade output meets the minimum amount before transferring tokens to the user, but if the token charges a fee on transfer, the user receives less than the minimum. An attacker could exploit this to receive fewer tokens than promised, though the sponsor considers it non-critical.

kenzo Follow

Originally disclosed on Code4rena

Submitted by kenzo.

Slingshot’s executeTrades checks that the trade result amount (to be sent to the user) is bigger than finalAmountMin, and after that sends the user the amount. But if the token charges fee on transfer, the final transfer to the user will decrease the amount the user is getting, maybe below finalAmountMin.

Proof of Concept

Slingshot requires finalOutputAmount >= finalAmountMin before sending the funds to the user: https://github.com/code-423n4/2021-10-slingshot/blob/main/contracts/Slingshot.sol#L93:#L98 So if the token charges fees on transfer, the user will get less tokens than finalOutputAmount . The check of finalOutputAmount against finalAmountMin is premature.

Tools Used

Manual analysis

Recommended Mitigation Steps

Save the user’s (not Executioner’s) toToken balance in the beginning of executeTrades after _transferFromOrWrap(fromToken, _msgSender(), fromAmount), and also in the very end, after executioner.sendFunds(toToken, _msgSender(), finalOutputAmount) has been called. The subtraction of user’s initial balance from ending balance should be bigger than finalAmountMin. https://github.com/code-423n4/2021-10-slingshot/blob/main/contracts/Slingshot.sol#L65:#L99

tommyz7 (Slingshot) disagreed with severity:

Slingshot concern is to execute the trade as promised and make sure we are sending to the user what has been promised in trade estimation. If the token adds additional taxation on transfer, it is on the user side and users understand and accept this. We have seen this play out on production for the previous version of the contracts and we decided not to make that check. It seems the most practical decision.

Personally, I think this is non-critical.

alcueca (judge) commented:

The severity for the issue is right. The sponsor should add documentation to the fact that some tokens might not conform to common expectations.

The original report as published on Code4rena, by kenzo. 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 checks the trade output amount against the minimum before the final transfer, not accounting for transfer fees.

Impact

Users could receive fewer tokens than the minimum they specified, but the sponsor considers this non-critical and a known trade-off.

What the attacker needed

Token charges fee on transfer

The fix

The contract should measure the user's balance before and after the trade and ensure the difference meets the minimum.

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.

Some tokens take a small fee when they are transferred. The contract checks the amount before the fee is taken, so the user might end up with less than they were promised. This is a logic flaw in how the contract verifies the final 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 kenzo

View all

53 more disclosed reports, best first.

More from Slingshot Finance 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.