Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOS of auction and stuck funds because of gas griefing #601

Closed
c4-submissions opened this issue Nov 8, 2023 · 7 comments
Closed

DOS of auction and stuck funds because of gas griefing #601

c4-submissions opened this issue Nov 8, 2023 · 7 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-734 edited-by-warden partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%)

Comments

@c4-submissions
Copy link
Contributor

c4-submissions commented Nov 8, 2023

Lines of code

https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/AuctionDemo.sol#L139

Vulnerability details

Impact

When an auction comes to its end, the highest bid is sent to the owner of the NFT selled and all other bids are send back to their owners. A gas griefing attack where a malicious bidder consumes all the gas available is possible. All auctions can be DOS-ed if a malicious bidder sends as little as 1 wei to the contract. Once entered, bidders cannot be removed. The bid call can be initiated by a contract that uses up all the available gas on receive(). The attacker can even bid several times to increase even further their chances of DOS of the system (because of the 63/64 rule) or just gas bomb it returning a huge amount of bytes.

Impact -> all the gas will be consumed and the transaction will revert, the NFT will not be send to the winner and the remainder of the funds will be stuck forever.

Proof of Concept

  1. Create foundry folder and install Foundry inside of it.
  2. Add remappings to map smart-contracts to contracts relative to the needed path.
  3. Add the following PoC.
  4. Run
forge test --lib-paths ../smart-contracts

Tools Used

Foundry

Recommended Mitigation Steps

Add a mapping that tracks the balance of each bidder. When an auction ends, increase the corresponding balances. Then create a function that enables withdrawals from the contract by the authorized bidders.

Assessed type

DoS

@c4-submissions c4-submissions added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Nov 8, 2023
c4-submissions added a commit that referenced this issue Nov 8, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@c4-pre-sort
Copy link

141345 marked the issue as duplicate of #843

@c4-pre-sort
Copy link

141345 marked the issue as duplicate of #486

@c4-judge
Copy link

c4-judge commented Dec 1, 2023

alex-ppg marked the issue as not a duplicate

@c4-judge
Copy link

c4-judge commented Dec 1, 2023

alex-ppg marked the issue as duplicate of #1782

@c4-judge c4-judge added duplicate-734 partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%) and removed duplicate-1782 labels Dec 4, 2023
@c4-judge
Copy link

c4-judge commented Dec 8, 2023

alex-ppg marked the issue as partial-50

@ZdravkoHr
Copy link

This issue should not be labeled as partial-50. It shows the same root cause and impact as 734.

Thanks!

@alex-ppg
Copy link

alex-ppg commented Dec 9, 2023

Hey @ZdravkoHr, thanks for your contribution! The submission was graded partially because of an "incorrect" recommendation chapter.

There is no need to maintain mappings that are solely mutated when the auction ends, better alternatives exist as advised by other duplicated submissions. Additionally, the impact specifies that the "remainder" will be left in the contract which is not the case as all funds will be locked, not just some.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-734 edited-by-warden partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%)
Projects
None yet
Development

No branches or pull requests

6 participants