Adversary can break any bounty they wish by depositing an NFT then refunding it
Refunding an NFT deposit does not remove the deposit receipt from the bounty's nftDeposits list, so when a payout is attempted the contract tries to transfer an NFT it no longer holds, causing all payouts to fail permanently. An attacker can exploit this to break payouts on any bounty.
8olidity Follow with HollaDieWaldfee, 0x52 and 17 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-02-openq-judging/issues/263
Found by
8olidity, HollaDieWaldfee, 0x52, HonorLt, unforgiven, rvierdiiev, GimelSec, StErMi, Jeiwan, 0xbepresent, libratus, cergyk, Ruhum, Robert, bin2chen, usmannk, TrungOre, Tricko, ctf_sec, cccz
Summary
Refunding an NFT doesn't remove the nftDeposit so the contract will try to payout an NFT it doesn't have if the NFT has been refunded.
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.
When any bounty is claimed it loops through nftDeposits and attempts to transfer an NFT for each one. The problem is that if an NFT has been refunded the deposit receipt will still exist but the contract won't have the NFT. The result is that all payouts will be permanently broken.
Submitting as high risk because when combined with refund locking methods it will result in all deposited tokens being stuck forever.
Impact
Adversary can permanently break payouts on any bounty
Code Snippet
Tool used
Manual Review
Recommendation
Remove the deposit receipt from nftDeposits when refunding NFT deposits
Discussion
FlacoJones
Valid. Will fix by removing nfts for now
FlacoJones
https://github.com/OpenQDev/OpenQ-Contracts/pull/113
and
https://github.com/OpenQDev/OpenQ-Contracts/pull/114
kiseln
Escalate for 20 USDC
This completely bricks payouts just like #62. Shouldn't it be high?
sherlock-admin
Escalate for 20 USDC
This completely bricks payouts just like #62. Shouldn't it be high?
You've created a valid escalation for 20 USDC!
To remove the escalation from consideration: Delete your comment. To change the amount you've staked on this escalation: Edit your comment (do not create a new comment).
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
hrishibhat
Escalation accepted
This issue is a valid high
sherlock-admin
Escalation accepted
This issue is a valid high
This issue's escalations have been accepted!
Contestants' payouts and scores will be updated according to the changes made on this issue.
sherlock-admin
Escalation accepted
This issue is a valid high
This issue's escalations have been accepted!
Contestants' payouts and scores will be updated according to the changes made on this issue.
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.
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 does not remove the corresponding deposit receipt from the nftDeposits array.
Impact
An attacker can permanently break payouts on any bounty, and when combined with refund locking methods, all deposited tokens could become stuck forever.
What the attacker needed
Ability to deposit an NFT; ability to refund the deposit
The fix
The deposit receipt should be removed from nftDeposits when an NFT deposit is refunded; the text states this was fixed by removing NFTs for now.
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 bounty lets people deposit tokens or NFTs as rewards. When someone asks for their deposit back, the contract returns the NFT but forgets to delete the record saying it still has it. Later, when a winner tries to claim the reward, the contract tries to send an NFT it no longer owns, which fails and blocks all payouts.
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.