Attacker can specify any receiver in USD0.flashLoan() to drain receiver balance
The flashLoan function lets the caller choose any receiver address, then mints to and burns from that receiver without checking that the receiver authorised the caller. An attacker could specify a victim as receiver and drain the victim's balance by repeatedly triggering flash loans that burn the victim's tokens plus fees.
mojito_auditor Follow with n1punp
Originally disclosed on Code4rena
Submitted by mojito_auditor, also found by n1punp
The flash loan feature in USD0’s flashLoan() function allows the caller to specify the receiver address. USD0 is then minted to this address and burnt from this address plus a fee after the callback. Since there is a fee in each flash loan, an attacker can abuse this to drain the balance of the receiver because the receiver can be specified by the caller without validation.
Proof of Concept
The allowance checked that receiver approved to address(this) but not check if receiver approved to msg.sender
uint256 _allowance = allowance(address(receiver), address(this));
require(_allowance >= (amount + fee), "USDO: repay not approved");
// @audit can specify receiver, drain receiver's balance
_approve(address(receiver), address(this), _allowance - (amount + fee));
_burn(address(receiver), amount + fee);
return true;
Recommended Mitigation Steps
Consider changing the “allowance check” to be the allowance that the receiver gave to the caller instead of address(this).
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 allowance check verifies that the receiver approved the contract (address(this)) rather than the caller (msg.sender), so any caller can spend a receiver's approved balance.
Impact
An attacker could drain the balance of any address that has approved the USD0 contract, because each flash loan burns the receiver's tokens plus a fee.
What the attacker needed
Victim has approved the USD0 contract; attacker can call flashLoan()
The fix
The allowance check should verify that the receiver approved the caller (msg.sender) rather than the contract itself.
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 flash loan is a loan that must be borrowed and repaid within one transaction. Here the contract lets the person asking for the loan name anyone as the receiver, and then takes the repayment plus a fee out of that person's balance. Because the contract only checks that the receiver approved the contract itself, not the person asking, an attacker can name a victim and make the victim pay.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.