Auctioned `taxTokensReceipt` NFT Blocks Last Claimant Due to Insufficient Funds
The auction contract does not account for fee-on-transfer tokens when buying a taxTokensReceipt NFT, so the loan contract receives less than the expected amount. This causes the last lender claiming collateral to be unable to withdraw due to insufficient funds.
0x37 Follow with KaplanLabs, bbl4de and 1 other
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-10-debita-judging/issues/470
Found by
0x37, KaplanLabs, bbl4de, dimulski
Summary
In the Auction::buyNFT function, users can purchase the current NFT in an auction using the same type of tokens as the underlying asset of the NFT. For example, taxTokensReceipt created with FoT tokens must be bought with the same FoT tokens.
During the execution of this function, a transferFrom() is performed to transfer funds from the buyer to the auction owner (loan contract). However, it does not account for fees applied during the transfer:
SafeERC20.safeTransferFrom(
IERC20(m_currentAuction.sellingToken),
msg.sender,
s_ownerOfAuction,
>> currentPrice - feeAmount // feeAmount: Fee for the protocol
);
Later in the function, it calls DebitaV3Loan::handleAuctionSell to distribute the collateral received from the buyer among the parties involved in the loan:
if (m_currentAuction.isLiquidation) {
debitaLoan(s_ownerOfAuction).handleAuctionSell(
>> currentPrice - feeAmount
);
}
The issue arises because the auction contract does not consider the fee on transfer when selling an auctioned taxTokensReceipt NFT. As a result, the final person attempting to claim their share of the collateral on the loan contract will encounter a revert due to insufficient funds.
Root Cause
Not accounting for the fee on transfer when purchasing a taxTokensReceipt NFT being auctioned.
Internal pre-conditions
- Creation a
taxTokenReceiptNFT with an FoT token. - Use this
taxTokenReceiptNFT as collateral in a loan with multiple lenders. - The loan defaults and the collateral is auctioned.
External pre-conditions
No response
Attack Path
- FoT Token Fee: 1% fee on every transfer.
Steps:
- The borrower creates a
taxTokensReceiptNFT wrapping 10,000 FoT tokens. - This NFT is used as collateral in a loan with multiple lenders.
- At the end of the loan, the borrower defaults and auctions the NFT.
- During the auction, another user buys the NFT for 7,000 FoT, but due to the FoT token's transfer fee, the loan contract receives only 6,930 FoT.
- Inside
handleAuctionSell(), the system calculates an inflatedtokenPerCollateralUsedvalue (used to split collateral among the remaining claimants) because it doesn't account for the transfer fee. - Impact: When multiple lenders attempt to claim their share of the collateral, the last lender is unable to claim due to insufficient funds in the contract.
Impact
The last person attempting to claim the collateral in the loan will be unable to do so.
PoC
No response
Mitigation
Take into account the fee on transfer when buying the taxTokenReceipt NFT.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/DebitaFinance/Debita-V3-Contracts/commit/7c2bd9e63c95e38f22f3478d36f72c33e8b17117
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 auction contract does not account for the fee on transfer when purchasing a taxTokensReceipt NFT being auctioned.
Impact
The last person attempting to claim the collateral in the loan will be unable to do so.
What the attacker needed
TaxTokensReceipt NFT with FoT token; loan with multiple lenders; loan defaults and collateral auctioned
The fix
The protocol team fixed this issue in the following PRs/commits.
How it was found
- The borrower creates a taxTokensReceipt NFT wrapping 10,000 FoT tokens.
- This NFT is used as collateral in a loan with multiple lenders.
- At the end of the loan, the borrower defaults and auctions the NFT.
- During the auction, another user buys the NFT for 7,000 FoT, but due to the FoT token's transfer fee, the loan contract receives only 6,930 FoT.
- Inside handleAuctionSell(), the system calculates an inflated tokenPerCollateralUsed value because it doesn't account for the transfer fee.
- When multiple lenders attempt to claim their share of the collateral, the last lender is unable to claim due to insufficient funds in the contract.
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 report shows that a smart contract did not account for that fee, so later when people tried to take their share of the money, the last person could not get paid because the contract did not have enough. The fix is to check the actual amount received after the fee.
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.