Skip to content
Business logic Audit finding Intermediate

Insufficient support for fee-on-transfer tokens

The protocol's contracts do not account for fee-on-transfer tokens, so when such a token is used, the actual amount received is less than the specified transfer amount. This leads to incorrect fee calculations and share minting, causing users to receive less reimbursement and more shares than they should, resulting in a loss of funds for the protocol and users.

supernova Follow with rvierdiiev, eierina and 8 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-11-buffer-judging/issues/76

Found by

supernova, rvierdiiev, eierina, cccz, KingNFT, dipp, __141345__, Bnke0x0, jonatascm, pashov, Deivitto

Summary

The BufferBinaryPool.sol and BufferRouter.sol do not support fee-on-transfer tokens. If tokenX is a fee-on-transfer token, tokens received from users could be less than the amount specified in the transfer.

Vulnerability Detail

The initiateTrade function in BufferRouter.sol receives tokens from the user with amount set to initiateTrade's totalFee input. If tokenX is a fee-on-transfer token then the actual amount received by BufferRouter.sol is less than totalFee. When a trade is opened, the protocol will send a settlementFee to settlementFeeDisbursalContract and a premium to BufferBinaryPool.sol, where the settlementFee is calculated using the incorrect, inflated totalFee amount. When the totalFee is greater than the fee required the user is reimbursed the difference. Since the settlementFee is greater than it should be the user receives less reimbursement.

In BufferBinaryPool.sol's lock function, the premium for the order is sent from the Options contract to the Pool. The totalPremium state variable would be updated incorrectly if fee-on-transfer tokens were used.

The _provide function in BufferBinaryPool.solreceives tokenXAmount of tokenX tokens from the user and calculates the amount of shares to mint using the tokenXAmount. If fee-on-transfer tokens are used then the user would receive more shares than they should.

Impact

The protocol and users could suffer a loss of funds.

Code Snippet

BufferRouter.sol#L86-L90

BufferBinaryPool.sol#L161

BufferBinaryPool.sol#L236-L240

Tool used

Manual Review

Recommendation

Consider checking the balance of the contract before and after token transfers and using instead of the amount specified in the contract.

Discussion

0x00052

Only an issue if project intends to support fee-on-transfer tokens as underlying

bufferfinance

Not supporting fee-on-transfer tokens for now.

bufferfinance

Buffer won't be supporting fee-on-transfer tokens. Thus we are not fixing it.

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

Root cause

The contracts use the transfer amount specified in the call rather than checking the actual balance change, so they do not account for tokens that deduct a fee on transfer.

Impact

The protocol and users could suffer a loss of funds, but the team stated they do not intend to support fee-on-transfer tokens, so the issue is not being fixed.

What the attacker needed

Fee-on-transfer token used as underlying

The fix

The contracts should check the balance before and after token transfers and use the actual received amount instead of the specified amount.

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, so the receiver gets less than the sender sent. This protocol assumed that the full amount always arrives, so its calculations for fees and shares were wrong when such a token was used. That could cause users to get too many shares or too little refund, and the protocol could lose money.

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 from Buffer Finance

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.