repay function can be DOSed
The repay function reverts when the supplied amount exceeds the user's current debt, so an attacker who repays a tiny amount on the victim's behalf just before their transaction causes the victim's larger repayment to fail. By repeating this, the attacker could keep blocking the victim from repaying.
Submitted by djxploit, also found by immeas
In repay() users can repay their debt.
function repay(address user, uint amount) public {
uint debt = debts[user];
require(debt >= amount, "Insufficient debt");
debts[user] -= amount;
totalDebt -= amount;
dbr.onRepay(user, amount);
dola.transferFrom(msg.sender, address(this), amount);
emit Repay(user, msg.sender, amount);
}
There is a require condition, that checks if the amount provided, is greater than the debt of the user. If it is, then the function reverts. This is where the vulnerability arises.
repay function can be frontrun by an attacker. Say an attacker pay a small amount of debt for the victim user, by frontrunning his repay transaction. Now when the victim’s transaction gets executed, the require condition will fail, as the amount of debt is less than the amount of DOLA provided. Hence the attacker can repeat the process to DOS the victim from calling the repay function.
Proof of Concept
- Victim calls repay() function to pay his debt of 500 DOLA , by providing the amount as 500
- Now attacker saw this transaction on mempool
- Attacker frontruns the transaction, by calling repay() with amount provided as 1 DOLA
- Attacker’s transaction get’s executed first due to frontrunning, which reduces the debt of the victim user to 499 DOLA
- Now when the victim’s transaction get’s executed, the debt of victim has reduced to 499 DOLA, and the amount to repay provided was 500 DOLA. Now as debt is less than the amount provided, so the require function will fail, and the victim’s transaction will revert.
This will prevent the victim from calling repay function.
Hence an attacker can DOS the repay function for the victim user.
Recommended Mitigation Steps
Implement DOS protection.
This seems like a stretch to me. Will leave open for sponsor review but most likely close as invalid.
08xmt (Inverse) confirmed and commented:
Mitigating PR: https://github.com/InverseFinance/FrontierV2/pull/13.
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
Likely the strict requirement that the repayment amount must not exceed the outstanding debt, combined with no tolerance for a debt that shrank between submission and execution.
Impact
An attacker could repeatedly block a specific user from repaying their debt, though the judge doubted the severity and the sponsor later mitigated it.
What the attacker needed
Attacker can see pending transactions; attacker can frontrun the victim; attacker pays a small amount of the victim's debt
The fix
The sponsor mitigated it in a follow-up pull request, though the text does not describe the change itself.
How it was found
- Victim submits a repay transaction for the full debt amount.
- Attacker sees the pending transaction in the mempool.
- Attacker frontruns it with a repay of a tiny amount for the same user.
- The attacker's transaction executes first and lowers the victim's debt.
- The victim's transaction then fails the require check and reverts.
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 lets a user pay back a loan by calling a function. That function refuses to run if the amount you send is bigger than what you still owe. An attacker can pay back a tiny part of your loan first, so when your own payment arrives it is now 'too big' and gets rejected, and they can keep doing this.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.