Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Claim function can be lead into DDOS #403

Closed
code423n4 opened this issue Jan 30, 2023 · 5 comments
Closed

Claim function can be lead into DDOS #403

code423n4 opened this issue Jan 30, 2023 · 5 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-552 satisfactory satisfies C4 submission criteria; eligible for awards sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Quest.sol#L99
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/RabbitHoleReceipt.sol#L117-L133

Vulnerability details

Impact

Quest.sol#Claim() can be lead into out of gas error due to unbounded array and user can't unable to claim reward token.

Proof of Concept

User can claim reward token via Receipt NFT contract. After claiming the reward token he still hold claimed mintReceipt and increase his balance. Also user can buy mint Receipt from other marketplace. getOwnedTokenIdsOfQuest() use 2 SLOAD opration and this gas cost is 2100*2 = 4200

https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/RabbitHoleReceipt.sol#L117-L122


        for (uint i = 0; i < msgSenderBalance; i++) {
            uint tokenId = tokenOfOwnerByIndex(claimingAddress_, i);    // 1st SLOAD (2100 gas)
            if (keccak256(bytes(questIdForTokenId[tokenId])) == keccak256(bytes(questId_))) {       // 2nd SLOAD (2100 gas)
                tokenIdsForQuest[i] = tokenId;
                foundTokens++;
            }
        }

ethereum block gas limit is : 30_00_000

any user can lead into out of gas error after minting ~ 700 ( = 3000000/(2100*2) receipt lead into out of gas error and not able to claim reward token.

this limit is can be easily achievable.

Tools Used

Manual Review

Recommended Mitigation Steps

When user claim reward token Mint Receipt should be burn.

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Jan 30, 2023
code423n4 added a commit that referenced this issue Jan 30, 2023
@waynehoover
Copy link

Intended use case has ~1-5, not 700+.

@c4-sponsor c4-sponsor added the sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue label Feb 7, 2023
@c4-sponsor
Copy link

waynehoover marked the issue as sponsor disputed

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Feb 16, 2023
@c4-judge
Copy link
Contributor

kirk-baird marked the issue as satisfactory

@c4-judge
Copy link
Contributor

kirk-baird marked the issue as duplicate of #552

@kirk-baird
Copy link

Although the intended use case is ~5 quests this loop may be reach by numerous participants sending claimed tokens to one user.

It is an unlikely case but I consider this to be a valid medium.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-552 satisfactory satisfies C4 submission criteria; eligible for awards sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Projects
None yet
Development

No branches or pull requests

5 participants