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` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
tokenAddresses count is not decreased on refunds causing a limitation in deposits.
Summary
The tokenAddresses count is not decreased on the refund action causing a bad validation in the fundBountyToken() function because the function checks the token addresses count with the tokenAddressLimitReached() function.
Vulnerability Detail
When there is a deposit to the Bounty a tokenAddress count is increased. If the funder refunds his deposit, the tokenAddresses count is not decreased, so if another funder wants to deposit the tokenAddressLimitReached() function will get bad information because one token address was refunded previously by the funder but the tokenAddress count was not decreased.
Impact
Various funders can reach the token address limit then the funders withdraw his money and tokenAddressLimitReached() function will still return true because the token addresses count were not decreased when the funders withdrew his money. Causing others funders can not deposit.
I created a test in DepositMAnager.test.js where it can seen that the funder deposit a tokenAddress, then the funder withdraw his money, then the funder wants to deposit again but the function will be reverted becuase "TOO_MANY_TOKEN_ADDRESSES" error.
Create the atomic bounty
Fund the bounty. The tokenAddress is set with the mockLink address.
Refund the mockLink token and the volume is refunded.
Fund the bounty again with a blacklisted token, it will be reverted because "TOO_MANY_TOKEN_ADDRESSES"
it('TokenAddresses count is not decreased after refund',async()=>{// The Bounty could be limited by deposits if the token address is not decreased// 1. Create the atomic bounty// 2. Fund the bounty. The tokenAddress is set with the mockLink address.// 3. Refund the mockLink token and the volume is refunded.// 4. Fund the bounty again with a blacklisted token, it will be reverted because "TOO_MANY_TOKEN_ADDRESSES"//// 1. Create the atomic bounty.//awaitopenQProxy.mintBounty(Constants.bountyId,Constants.organization,atomicBountyInitOperation);constbountyAddress=awaitopenQProxy.bountyIdToAddress(Constants.bountyId);constvolume=100;awaitmockLink.approve(bountyAddress,10000000);awaitAtomicBountyV1.attach(bountyAddress);awaitopenQTokenWhitelist.setTokenAddressLimit(1);//// 2. Fund the bounty. The tokenAddress is set with the mockLink address//awaitdepositManager.fundBountyToken(bountyAddress,mockLink.address,volume,1,Constants.funderUuid);expect((awaitmockLink.balanceOf(bountyAddress)).toString()).to.equal('100');//// 3. Refund the mockLink and the volume is refunded.//constbountyDepositId=generateDepositId(Constants.bountyId,0);constexpectedTimestamp=awaitsetNextBlockTimestamp(2764800);awaitexpect(depositManager.refundDeposit(bountyAddress,bountyDepositId)).to.emit(depositManager,'DepositRefunded').withArgs(bountyDepositId,Constants.bountyId,bountyAddress,Constants.organization,expectedTimestamp,mockLink.address,volume,0,[],Constants.VERSION_1);expect((awaitmockLink.balanceOf(bountyAddress)).toString()).to.equal('0');//// 4. Fund the bounty again with a blacklisted token, it will be reverted because "TOO_MANY_TOKEN_ADDRESSES"//awaitblacklistedMockDai.approve(bountyAddress,10000000);awaitexpect(depositManager.fundBountyToken(bountyAddress,blacklistedMockDai.address,10000000,1,Constants.funderUuid)).to.be.revertedWith('TOO_MANY_TOKEN_ADDRESSES');});
Code Snippet
In the receiveFunds() function the tokenAddresses is increased.
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` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
0xbepresent
high
tokenAddresses
count is not decreased on refunds causing a limitation in deposits.Summary
The
tokenAddresses
count is not decreased on the refund action causing a bad validation in thefundBountyToken()
function because the function checks the token addresses count with thetokenAddressLimitReached()
function.Vulnerability Detail
When there is a deposit to the Bounty a tokenAddress count is increased. If the funder refunds his deposit, the
tokenAddresses
count is not decreased, so if another funder wants to deposit the tokenAddressLimitReached() function will get bad information because one token address was refunded previously by the funder but the tokenAddress count was not decreased.Impact
Various funders can reach the token address limit then the funders withdraw his money and tokenAddressLimitReached() function will still return
true
because the token addresses count were not decreased when the funders withdrew his money. Causing others funders can not deposit.I created a test in DepositMAnager.test.js where it can seen that the funder deposit a tokenAddress, then the funder withdraw his money, then the funder wants to deposit again but the function will be reverted becuase "TOO_MANY_TOKEN_ADDRESSES" error.
Code Snippet
In the receiveFunds() function the
tokenAddresses
is increased.In the refundDeposit() the
tokenAddresses
is not decreased.The tokenAddressLimitReached() function will return a wrong value.
In the fundBountyToken() the
tokenAddressLimitReached()
function will limit the deposits.Tool used
Vscode
Recommendation
Decrease the
tokenAddresses
count when the funder refunds his deposit.Duplicate of #530
The text was updated successfully, but these errors were encountered: