addCredit() DOS Attack
Anyone can call addCredit() with a tiny amount of ether, which changes the stored hash of a lien. By front-running, an attacker can cause validateLien() checks to fail, blocking legitimate actions such as bidding, starting or stopping auctions, and repaying with an NFT.
Submitted by bin2chen, also found by d3e4, d3e4, and minhquanym
Proof of Concept
addCredit() can be called by anyone, and the msg.value is as small as 1 wei.
Users can modify Lien at a small cost, causing the value stored in liens[lienId]=keccak256(abi.encode(lien)) to change. By front-run, the normal user’s transaction validateLien() fails the check, thus preventing the user’s transaction from being executed.
The following methods will be exploited (most methods with validateLien() will be affected). For example:
- Front-run
auctionBuyNft()is used to prevent others from bidding. - Front-run
startLoanAuction()to prevent the lender from starting the auction. - Front-run
stopLoanAuction()is used to stop Lender from closing the auction. etc.
Recommended Mitigation Steps
addCredit()can execute only by the borrower.- Add the modification interval period.
- Limit min of
msg.value.
Assessed type
Context
hansfriese (judge) increased severity to High and commented:
Concise explanation and reasonable mitigation recommendation. Marked as primary.
Preventing borrowers from repaying NFT by causing DoS for
repayWithNftis another severe exploit: #40
wukong-particle (Particle) confirmed, disagreed with severity and commented:
Should be a Medium risk because no fund or asset can be stolen.
addCreditincurs non-trivial gas so DOS can’t economically happen very often.We agree with the suggestion to add a borrower only check and add a minimum 0.01 ETH credit limit.
hansfriese (judge) decreased severity to Medium and commented:
Agree with the sponsor. Downgrading to Medium.
We agree with the suggestion to add a borrower only check and add a minimum 0.01 ETH credit limit.
Adding a borrower only check seems good. But I am concerned that 0.01 ETH is not enough. If the max price is 72 ETH, then the auction price will increase 0.01 ETH for every block. It then seems very reasonable that the borrower could still profitably DoS
auctionBuyNft()so that they can call it when the price is close to max. This is, of course, an illegitimate use case ofaddCredit(). A way to avoid having any minimum limit for legitimate use ofaddCredit()is to enforce that the borrower is solvent after adding credit. This way, the hefty minimum limit only applies to adding additional credit, which is what is susceptible to exploits.
wukong-particle (Particle) commented:
Mitigated.
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 addCredit() function is callable by anyone and allows very small msg.value, so an attacker can cheaply alter the lien hash and invalidate other users' validateLien() checks via front-running.
Impact
The attacker can block legitimate actions such as bidding, starting or stopping auctions, and repaying with an NFT; the sponsor noted that no funds are stolen and gas costs make frequent attacks uneconomical, and the severity was downgraded to Medium.
What the attacker needed
Attacker can send transactions; attacker can front-run pending transactions; small amount of ether for gas and msg.value
The fix
The project mitigated the issue; the suggested fixes were to restrict addCredit() to the borrower, add a modification interval, and enforce a minimum msg.value (with a later suggestion to require borrower solvency).
How it was found
- Attacker observes a pending transaction that calls a function using validateLien().
- Attacker front-runs by calling addCredit() with a tiny msg.value, changing the lien hash.
- The victim's transaction fails the validateLien() check and is not executed.
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 stores a fingerprint (hash) of each loan (lien). A function lets anyone add a tiny amount of credit, which changes that fingerprint. An attacker can watch for a legitimate transaction and quickly send their own transaction first, so the original transaction fails because the fingerprint no longer matches.
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.