Skip to content
DoS Audit finding Intermediate

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.

bin2chen Follow with d3e4, d3e4 and 1 other

Originally disclosed on Code4rena

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:

  1. Front-run auctionBuyNft() is used to prevent others from bidding.
  2. Front-run startLoanAuction() to prevent the lender from starting the auction.
  3. Front-run stopLoanAuction() is used to stop Lender from closing the auction. etc.

Recommended Mitigation Steps

  1. addCredit() can execute only by the borrower.
  2. Add the modification interval period.
  3. 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.

hansfriese (judge) commented:

Preventing borrowers from repaying NFT by causing DoS for repayWithNft is 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. addCredit incurs 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.

d3e4 (warden) commented:

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 of addCredit(). A way to avoid having any minimum limit for legitimate use of addCredit() 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.


The original report as published on Code4rena, by bin2chen. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

  1. Attacker observes a pending transaction that calls a function using validateLien().
  2. Attacker front-runs by calling addCredit() with a tiny msg.value, changing the lien hash.
  3. 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.

More by bin2chen

View all

139 more disclosed reports, best first.

More from Particle Leverage AMM Protocol Invitational

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.