Incorrect fees will be charged
The initiator fee is calculated on the full transferAmount before deducting the amounts actually used to pay liens, so if the transferAmount exceeds the total lien amounts, the fee is charged on more than was used. An attacker could cause excess fees to be deducted from users.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/36
Found by
csanuragjain
Summary
If user has provided transferAmount which is greater than all lien.amount combined then initiatorPayment will be incorrect since it is charged on full amount when only partial was used as shown in poc
Vulnerability Detail
- Observe the _handleIncomingPayment function
- Lets say transferAmount was 1000
- initiatorPayment is calculated on this full transferAmount
uint256 initiatorPayment = transferAmount.mulDivDown(
auction.initiatorFee,
100
);
- Now all lien are iterated and lien.amount is kept on deducting from transferAmount until all lien are navigated
if (transferAmount >= lien.amount) {
payment = lien.amount;
transferAmount -= payment;
} else {
payment = transferAmount;
transferAmount = 0;
}
if (payment > 0) {
LIEN_TOKEN.makePayment(tokenId, payment, lien.position, payer);
}
}
- Lets say after loop completes the transferAmount is still left as 100
- This means only 400 transferAmount was used but fees was deducted on full amount 500
Impact
Excess initiator fees will be deducted which was not required
Code Snippet
Tool used
Manual Review
Recommendation
Calculate the exact amount of transfer amount required for the transaction and calculate the initiator fee based on this amount
Discussion
IAmTurnipBoy
Escalate for 1 USDC
The fee is not the problem, so this report is invalid. The issue is that the payment isn't working as intended and that sometimes it doesn't take as much as it should. See #107.
sherlock-admin
Escalate for 1 USDC
The fee is not the problem, so this report is invalid. The issue is that the payment isn't working as intended and that sometimes it doesn't take as much as it should. See #107.
You've created a valid escalation for 1 USDC!
To remove the escalation from consideration: Delete your comment. To change the amount you've staked on this escalation: Edit your comment (do not create a new comment).
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
Evert0x
Escalation rejected.
This is a valid finding as fees are too high - Fees should be calculated based on the actual amount used as the repayment
sherlock-admin
Escalation rejected.
This is a valid finding as fees are too high - Fees should be calculated based on the actual amount used as the repayment
This issue's escalations have been rejected!
Watsons who escalated this issue will have their escalation amount deducted from their next payout.
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 initiator fee is computed on the full transferAmount before determining how much is actually needed to pay off the liens.
Impact
Excess initiator fees will be deducted from the payer, as the fee is based on the full transferAmount rather than the amount actually used to repay liens.
What the attacker needed
TransferAmount exceeds total lien amounts
The fix
The fee should be calculated based on the exact amount of transferAmount actually used to repay liens, not the full amount.
How it was found
- Call _handleIncomingPayment with a transferAmount greater than the sum of all lien amounts.
- The initiatorPayment is calculated on the full transferAmount.
- The code iterates over liens, deducting each lien.amount from transferAmount until all liens are paid.
- If transferAmount remains after all liens are paid, the fee was still charged on the original full amount, not just the used portion.
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.
When someone repays a loan, a fee is taken. The code calculates the fee on the total amount sent, even if part of that money is not needed to repay the loan. This means the user pays a fee on money that is not actually used, so they lose extra funds.
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.