Adversary can break NFT distribution by depositing up to max then refunding all of them
The bounty contract's refund function returns the NFT to the funder but does not remove the deposit record, so the deposit limit of five is consumed by refunded deposits. An attacker can repeatedly deposit and refund NFTs to fill all slots, preventing legitimate NFT distribution to the claimant.
Source: https://github.com/sherlock-audit/2023-02-openq-judging/issues/262
Found by
GimelSec, dipp, caventa, clems4ever, HollaDieWaldfee, Ruhum, Jeiwan, kiki_dev, 0x52, HonorLt, unforgiven, jkoppel, bin2chen, 0xmuxyz, libratus
Summary
Bounties limit the number of NFT deposits to five. An adversary can block adding NFTs by repeatedly depositing and withdrawing an NFT.
Vulnerability Detail
All bounties use BountyCore#refundDeposit to process refunds to user. This simply transfers the NFT back to the funder but leaves the nftDeposit. This uses up the deposit limit which is current set to 5. Since the deposit cap is used up by deposits that have been refunded the slots can't be used to distribute legitimate NFTs to the bounty claimant.
Impact
Adversary can block legitimate NFT distribution
Code Snippet
Tool used
Manual Review
Recommendation
When an NFT deposit is refunded it should remove the depositID from nftDeposits
Discussion
FlacoJones
Valid. Will fix by removing nft funding and disbaling crowdfunding
FlacoJones
https://github.com/OpenQDev/OpenQ-Contracts/pull/113
and
https://github.com/OpenQDev/OpenQ-Contracts/pull/116
and
https://github.com/OpenQDev/OpenQ-Contracts/pull/114
jacksanford1
Lead Senior Watson comment on PR #113:
Changes look good.
Token requirement has been simplified to just a whitelist. It makes the rest changes to support this revision. tokenAddressLimitReach method has been removed from DepositManagerV1. _tokenAddressLimit has been removed from TokenWhitelist constructor. TOKEN_ADDRESS_LIMIT has been removed along with it's setter. Tests have been updated to accommodate changes.
Lead Senior Watson comment on PR #114:
Changes look good. Removes all logic from bounties. Seems to have gotten all related code. Will keep my out for any that was missed on when checking the rest of the PRs
Lead Senior Watson comment on PR #116:
Changes look good. Requires that funder is the issuer. This prevents a whole host of potential exploits in exchange for closing the otherwise open funding model.
jacksanford1
Lead Senior Watson comment on PR #113:
Changes look good.
Token requirement has been simplified to just a whitelist. It makes the rest changes to support this revision. tokenAddressLimitReach method has been removed from DepositManagerV1. _tokenAddressLimit has been removed from TokenWhitelist constructor. TOKEN_ADDRESS_LIMIT has been removed along with it's setter. Tests have been updated to accommodate changes.
Lead Senior Watson comment on PR #114:
Changes look good. Removes all logic from bounties. Seems to have gotten all related code. Will keep my out for any that was missed on when checking the rest of the PRs
Lead Senior Watson comment on PR #116:
Changes look good. Requires that funder is the issuer. This prevents a whole host of potential exploits in exchange for closing the otherwise open funding model.
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 refund function transfers the NFT back to the funder but fails to remove the deposit identifier from the list of NFT deposits, so the deposit limit is consumed by refunded entries.
Impact
An adversary can block legitimate NFT distribution to the bounty claimant.
What the attacker needed
Ability to deposit and refund NFTs
The fix
The refund function should remove the deposit identifier from the NFT deposits list when an NFT deposit is refunded; the project later removed NFT funding and disabled crowdfunding.
How it was found
- Deposit an NFT into the bounty.
- Request a refund of that NFT deposit.
- Repeat the deposit and refund until the deposit limit of five is reached.
- Legitimate NFT deposits can no longer be added.
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 bounty lets people fund it with NFTs, but only five NFT deposits are allowed. When someone asks for a refund, the NFT goes back to them, but the system still counts that deposit as one of the five. An attacker can use this to fill all five slots with refunded deposits, so no real NFTs can be added for the person who is supposed to receive the bounty.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.