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.
ctf_sec - Developer cannot claim the bounty if the token revert in 0 amount transfer after the user get the bounty refund after funding the bounty contract
#316
Closed
github-actionsbot opened this issue
Feb 21, 2023
· 0 comments
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
/// @notice Transfers full balance of _tokenAddress from bounty to _payoutAddress/// @param _tokenAddress ERC20 token address or Zero Address for protocol token/// @param _payoutAddress The destination address for the fundsfunction claimBalance(address_payoutAddress, address_tokenAddress)
external
onlyClaimManager
nonReentrant
returns (uint256)
{
uint256 claimedBalance =getTokenBalance(_tokenAddress);
_transferToken(_tokenAddress, claimedBalance, _payoutAddress);
return claimedBalance;
}
If the claimedBalance is 0, calling _transferToken would revert in 0 amount transfer.
describe.only('ATOMIC POC',()=>{it('if token A does not allow 0 amount transfer, claim bounty failed if user get refund after supplying bounty token',async()=>{// ARRANGEconst[user1,user2,user3]=awaitethers.getSigners();awaitopenQProxy.mintBounty(Constants.bountyId,Constants.organization,atomicBountyInitOperation);constbountyAddress=awaitopenQProxy.bountyIdToAddress(Constants.bountyId);constvolume=100;consttokenDepositId=generateDepositId(Constants.bountyId,0);awaitmockLink.connect(user1).approve(bountyAddress,10000000);awaitdepositManager.connect(user1).fundBountyToken(bountyAddress,mockLink.address,volume,1,Constants.funderUuid);constexpectedTimestamp=awaitsetNextBlockTimestamp(2764900);awaitdepositManager.connect(user1).refundDeposit(bountyAddress,tokenDepositId)// ASSUMEletbountyIsClaimable=awaitclaimManager.bountyIsClaimable(bountyAddress);expect(bountyIsClaimable).to.equal(true);awaitclaimManager.connect(oracle).claimBounty(bountyAddress,user3.address,abiEncodedSingleCloserData);// ASSERTbountyIsClaimable=awaitclaimManager.bountyIsClaimable(bountyAddress);expect(bountyIsClaimable).to.equal(false);});});
We run the test using
yarn test
the output is:
ClaimManager.solbountyIsClaimableATOMICPOC1)iftokenAdoesnotallow0amounttransfer,claimbountyfailedifusergetrefundaftersupplyingbountytoken0passing(2s)1failing1)ClaimManager.solbountyIsClaimableATOMICPOCiftokenAdoesnotallow0amounttransfer,claimbountyfailedifusergetrefundaftersupplyingbountytoken:
Error: VMExceptionwhileprocessing transaction: revertedwithreasonstring'zero amount transfer not allowed!'
Impact
Developer cannot claim the bounty if the token revert in 0 amount transfer
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
ctf_sec
high
Developer cannot claim the bounty if the token revert in 0 amount transfer after the user get the bounty refund after funding the bounty contract
Summary
Developer cannot claim the bounty if the token revert in 0 amount transfer after the user get the bounty refund after funding the bounty contract
Vulnerability Detail
If user A fund the bounty contract using 50 token A, user B fund the bounty contract using 100 token B.
User A then refund the deposit and remove the 50 token A, the developer cannot claim the bounty if the token A reverts in 0 amount transfer.
According to https://github.com/d-xo/weird-erc20#revert-on-zero-value-transfers
LEND
) revert when transfering a zero value amount
When fund the token via DepositManager.sol, the function below is called:
which calls:
When the bounty is funded, we push the depositId and tokenAddress into the deposits and tokenAddresses.
However, when the user call refundDeposit, the deposits array and tokenAddresses map is not cleaned up.
In Atomic bounty, when the claim function is caleld via the claimManager.sol
which calls:
which calls:
If the claimedBalance is 0, calling _transferToken would revert in 0 amount transfer.
First we need to edit the MockLink Contract:
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Mocks/MockLink.sol#L9
Then we add the POC test below:
https://github.com/sherlock-audit/2023-02-openq/blob/main/test/ClaimManager.test.js#L253
We run the test using
yarn test
the output is:
Impact
Developer cannot claim the bounty if the token revert in 0 amount transfer
Code Snippet
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/BountyCore.sol#L53-L56
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/AtomicBountyV1.sol#L85-L99
Tool used
Manual Review
Recommendation
We recommend the protocol clean up the deposits and check that if the token amount is larger than 0 before transfer the token.
Duplicate of #267
The text was updated successfully, but these errors were encountered: