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

Owners can delay the call to startDraw to reject the draw result #300

Closed
code423n4 opened this issue Dec 16, 2022 · 3 comments
Closed

Owners can delay the call to startDraw to reject the draw result #300

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/main/src/VRFNFTRandomDraw.sol#L306

Vulnerability details

Impact

Owners can call lastResortTimelockOwnerClaimNFT to reclaim NFT back if settings.recoverTimelock <= block.timestamp. But settings.recoverTimelock is set in initialize, Owner can delay the call to startDraw until settings.recoverTimelock.

If the owner wants to refuse to give NFT to some specific winners, the owner can call lastResortTimelockOwnerClaimNFT if some specific winners win the draw. Because the owner delayed the call to startDraw, the owner can call (or front-run winnerClaimNFT) lastResortTimelockOwnerClaimNFT in no time.

Proof of Concept

The lastResortTimelockOwnerClaimNFT function checks settings.recoverTimelock:

    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 an owner delays the startDraw until settings.recoverTimelock, the owner can call lastResortTimelockOwnerClaimNFT in no time. The owner can reject some specific winners by frontrunning winnerClaimNFT() which is called by the winner.

Tools Used

Manual Review

Recommended Mitigation Steps

Add recoverBufferTime variable, and reset settings.recoverTimelock in startDraw:

    function startDraw() external onlyOwner returns (uint256) {
+       settings.recoverTimelock = block.timestamp + settings.recoverBufferTime;
        ...
@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 c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Dec 17, 2022
@c4-judge
Copy link
Contributor

gzeon-c4 marked the issue as satisfactory

C4-Staff added a commit that referenced this issue Jan 7, 2023
@c4-judge c4-judge removed the 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value label Jan 23, 2023
@c4-judge
Copy link
Contributor

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

@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 labels Jan 23, 2023
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