Skip to content
DoS Audit finding Intermediate

DoS by gas limit

The deposit function allows an attacker to add many NFTs to another user's staked list, causing that user's withdrawal to run out of gas when iterating the list. The victim can still withdraw NFTs one by one until reaching the problematic index.

danb Follow

Originally disclosed on Code4rena

Submitted by danb, also found by benk10 and pedroais

LiquidityFarming.sol#L220 LiquidityFarming.sol#L233

In deposit function it is possible to push to nftIdsStaked of anyone, an attacker can deposit too many nfts to another user, and when the user will try to withdraw an nft at the end of the list, they will iterate on the list and revert because of gas limit.

ankurdubey521 (Biconomy) confirmed and commented:

HP-25: C4 Audit Fixes, Dynamic Fee Changes bcnmy/hyphen-contract#42

pauliax (judge) decreased severity to Medium and commented:

A valid concern, but I think it should be of medium severity because the victim can still withdraw NFTs one by one until reaching the necessary index because it breaks inside the loop: LiquidityFarming.sol#L234-L235.


The original report as published on Code4rena, by danb. 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 deposit function does not limit how many NFTs can be added to a user's staked list, and the withdrawal function iterates over the entire list without a bound.

Impact

The victim may be unable to withdraw NFTs at the end of the list in a single transaction, but can still withdraw them one by one until reaching the necessary index.

What the attacker needed

Attacker can call deposit for another user

The fix

The fix should limit the number of NFTs per user or avoid iterating over the entire list during withdrawal.

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 keeps a list of NFTs each user has staked. An attacker can add lots of NFTs to someone else's list. When the victim tries to withdraw an NFT near the end, the contract has to loop through the whole list, which costs more gas than allowed, so the withdrawal fails.

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 danb

View all

12 more disclosed reports, best first.

More from Biconomy - Smart Contract Wallet contest

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.