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

lastResortTimelockOwnerClaimNFT() can retrieve the token although drawing is in progress #218

Closed
code423n4 opened this issue Dec 16, 2022 · 3 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-146 satisfactory satisfies C4 submission criteria; eligible for awards upgraded by judge Original issue severity upgraded from QA/Gas by judge

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-12-forgeries/blob/fc271cf20c05ce857d967728edfb368c58881d85/src/VRFNFTRandomDraw.sol#L304-L319

Vulnerability details

Impact

owner can retrieve the token although drawing is in progress

Proof of Concept

lastResortTimelockOwnerClaimNFT() Be used in:
"
If no users ultimately claim the NFT, the admin specifies a timelock period after which they can retrieve the raffled NFT.
"

But it is no check that if draw is already in progress, i.e. the current round of request.drawTimelock >= block.timestamp
it should not be able to be lastResortTimelockOwnerClaimNFT().
Because a new round of draw has already started and the results may be available.

The above problems can occur in the following two cases:
1:
Because:
_settings.drawBufferTime >= HOUR_IN_SECONDS and <= MONTH_IN_SECONDS
_settings.recoverTimelock > = WEEK_IN_SECONDS and <= MONTH_IN_SECONDS * 12

if drawBufferTime = two weeks and recoverTimelock = one weeks

So: this condition is possible: drawBufferTime > recoverTimelock

2:
The first few rounds have been unfulfilled and keep repeating to start a new round, resulting in request.drawTimelock > settings.recoverTimelock will appear

Tools Used

Recommended Mitigation Steps

add check drawTimelock

    function lastResortTimelockOwnerClaimNFT() external onlyOwner {
        // If recoverTimelock is not setup, or if not yet occurred
        if (settings.recoverTimelock > block.timestamp) {
            // Stop the withdraw
            revert RECOVERY_IS_NOT_YET_POSSIBLE();
        }


+       if (request.drawTimelock >= block.timestamp) {
+         revert STILL_IN_DRAWING();
+       }
        ...
@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 Dec 16, 2022
code423n4 added a commit that referenced this issue Dec 16, 2022
@c4-judge
Copy link
Contributor

gzeon-c4 marked the issue as duplicate of #146

@c4-judge
Copy link
Contributor

gzeon-c4 marked the issue as satisfactory

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Dec 17, 2022
@c4-judge c4-judge added 3 (High Risk) Assets can be stolen/lost/compromised directly upgraded by judge Original issue severity upgraded from QA/Gas by judge and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Jan 23, 2023
@c4-judge
Copy link
Contributor

gzeon-c4 changed the severity to 3 (High Risk)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-146 satisfactory satisfies C4 submission criteria; eligible for awards upgraded by judge Original issue severity upgraded from QA/Gas by judge
Projects
None yet
Development

No branches or pull requests

2 participants