You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 26, 2023. It is now read-only.
github-actionsbot opened this issue
Feb 21, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
A malicious user can deposit NFT as erc20 to execute the attack.
Vulnerability Detail
The current protocol allows anyone to provide bonuses
In order to prevent malicious users using malicious token addresses to break the protocol: for example, by providing malicious token addresses, always revert when claim bounty, thus blocking claims, etc.
That's why we provide a whitelist token mechanism.
However, the current whitelist puts erc20 and erc721 in the same whitelist, which gives the attacker the possibility to break the protocol: a malicious user can pretend NFT (in the whitelist) to be erc20 into tokenAddresses , when claim bounty will always revert, and cannot perform claim bounty. .
So NFT can be treated as ERC20 execution fundBountyToken ()?
Yes, because :
"NFT and ERC20 balanceOf/transferFrom method signature is the same"
But when the claim bounty uses transfer(), it will revert, because NFT does not have this method signature
Here is the test code, you can deposit NFT as erc20,but anyone can not claim his bounty:
add to test/ClaimManager.test.js
it('NFT_TO_TOKEN',async()=>{awaitopenQProxy.mintBounty(Constants.bountyId,Constants.organization,atomicBountyInitOperation);constbountyAddress=awaitopenQProxy.bountyIdToAddress(Constants.bountyId);awaitmockNft.approve(bountyAddress,1);//1. **** @audit approve first , transferFrom need it//2. **** @audit fundBountyToken nft is okawaitdepositManager.fundBountyToken(bountyAddress,mockNft.address,1,1,zeroTier);constexpectedTimestamp=awaitsetNextBlockTimestamp();console.log("fundBountyToken(NFT) is ok");//3. **** @audit claim bounty will revertawaitclaimManager.connect(oracle).claimBounty(bountyAddress,owner.address,abiEncodedTieredCloserDataFirstPlace);});
yarn test test/ClaimManager.test.js --grep NFT_TO_TOKEN
output
fundBountyToken(NFT) is ok 1) ClaimManager.sol claimBounty TIERED EVENTS NFT_TO_TOKEN: Error: VM Exception while processing transaction: reverted with reason string 'SafeERC20: low-level call failed' at AtomicBountyV1.<receive> (contracts/Bounty/Implementations/AtomicBountyV1.sol:197)
A malicious user can deposit NFT as erc20 to execute the attack.
Although the attacker will lose NFT, it should be possible to find cheap NFTs that are in the whitelist
So it is recommended that the NFT and ERC20 whitelist independent
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
bin2chen
medium
block claim bounty attacks
Summary
A malicious user can deposit NFT as erc20 to execute the attack.
Vulnerability Detail
The current protocol allows anyone to provide bonuses
In order to prevent malicious users using malicious token addresses to break the protocol: for example, by providing malicious token addresses, always revert when claim bounty, thus blocking claims, etc.
That's why we provide a whitelist token mechanism.
However, the current whitelist puts erc20 and erc721 in the same whitelist, which gives the attacker the possibility to break the protocol: a malicious user can pretend NFT (in the whitelist) to be erc20 into tokenAddresses , when claim bounty will always revert, and cannot perform claim bounty. .
So NFT can be treated as ERC20 execution fundBountyToken ()?
Yes, because :
"NFT and ERC20 balanceOf/transferFrom method signature is the same"
But when the claim bounty uses transfer(), it will revert, because NFT does not have this method signature
Here is the test code, you can deposit NFT as erc20,but anyone can not claim his bounty:
add to test/ClaimManager.test.js
yarn test test/ClaimManager.test.js --grep NFT_TO_TOKEN
output
A malicious user can deposit NFT as erc20 to execute the attack.
Although the attacker will lose NFT, it should be possible to find cheap NFTs that are in the whitelist
So it is recommended that the NFT and ERC20 whitelist independent
Impact
Normal users cannot claim the bounty
Code Snippet
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/TokenWhitelist/TokenWhitelist.sol#L19-L32
Tool used
Manual Review
Recommendation
Independent Whitelist
Duplicate of #62
The text was updated successfully, but these errors were encountered: