Adversary can brick bounty payouts by calling fundBountyToken but funding it with an ERC721 token instead
The contract's funding function accepts an ERC721 token as if it were an ERC20, but the payout function cannot transfer ERC721 tokens, causing all payouts from that bounty to revert. An attacker could permanently lock the bounty's funds by funding it with an ERC721 token.
Source: https://github.com/sherlock-audit/2023-02-openq-judging/issues/352
Found by
XKET, ck, Robert, 0x52, ltyu, ctf_sec
Summary
recieveFunds is only meant to be called with an ERC20 token but _receiveERC20 is generic enough to work with an ERC721 token. An adversary could call this with an ERC721 token to add it as a bounty reward. The problem is that the payout functions would completely break when trying to send it as a payout. The result is that afterwards the bounty would be completely broken.
Vulnerability Detail
BountyCore#_receiveERC20 makes two calls to the underlying token contract. The first is the transferFrom method which exists functions identical to the ERC20 variant using token id instead of amount.
The other call that's made is balanceOf which is also present in ERC721
On the flipside, when withdrawing and ERC20 it uses the transfer method which doesn't exist in ERC721. The result is that ERC721 tokens can be deposited as ERC20 tokens but can't be withdrawn. Since the contract will revert when trying to payout the ER721 token all payouts from the bounty will no longer work.
Submitting as high risk because when combined with refund locking methods it will result in all deposited tokens being stuck forever.
Impact
Bounty will be permanently unclaimable
Code Snippet
Tool used
Manual Review
Recommendation
Split the whitelist into an NFT whitelist and an ERC20 whitelist, to prevent a whitelisted NFT being deposited as an ERC20 token.
Discussion
FlacoJones
Will fix with an explicity OpenQTokenWhitelist, no arbitrary token addresses
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 effectively remove the possibility of this exploit
pauliax
Escalate for 52 USDC. I think this issue is essentially the same as #62. It does not matter if the token is ERC20, ERC721, ERC1155 or ERC777, or whatever, what matters is that this impostor contract pretends to comply with the funding function only later to reveal its dark side. Based on my interpretation, all the issues that are talking about feeding the bounty with 'wrong' tokens should be grouped together under one issue, because all of them are giving basically the same effect.
sherlock-admin
Escalate for 52 USDC. I think this issue is essentially the same as #62. It does not matter if the token is ERC20, ERC721, ERC1155 or ERC777, or whatever, what matters is that this impostor contract pretends to comply with the funding function only later to reveal its dark side. Based on my interpretation, all the issues that are talking about feeding the bounty with 'wrong' tokens should be grouped together under one issue, because all of them are giving basically the same effect.
You've created a valid escalation for 52 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.
Evert0x
Escalation rejected. OpenQ used the same method of locking down everything to a whitelist as a means to fix all of them but they are not all the same and would have needed different fixes for each one if OpenQ had wanted to keep the funding process open.
sherlock-admin
Escalation rejected. OpenQ used the same method of locking down everything to a whitelist as a means to fix all of them but they are not all the same and would have needed different fixes for each one if OpenQ had wanted to keep the funding process open.
This issue's escalations have been rejected!
Watsons who escalated this issue will have their escalation amount deducted from their next payout.
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 #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.
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
Likely the funding function uses generic token calls (transferFrom and balanceOf) that exist on both ERC20 and ERC721 contracts, without checking the token type, while the payout function uses transfer which is ERC20-only.
Impact
The bounty becomes permanently unclaimable, and when combined with refund locking methods all deposited tokens could be stuck forever.
What the attacker needed
Attacker can call fundBountyToken; ERC721 token is whitelisted
The fix
The whitelist should be split into an NFT whitelist and an ERC20 whitelist to prevent a whitelisted NFT from being deposited as an ERC20 token; the text also notes that later changes removed the possibility of this exploit.
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 lets people add money to a bounty, but it mistakenly accepts NFTs (unique digital tokens) as if they were ordinary fungible tokens. When someone later tries to claim the bounty, the contract tries to send the NFT using a method that only works for fungible tokens, so the transfer fails and the bounty is stuck.
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.