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

neko_nyaa - Raffles with exactly minTicketsThreshold tickets sold can still be cancelled #507

Closed
sherlock-admin3 opened this issue Aug 20, 2024 · 9 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Escalation Resolved This issue's escalations have been approved/rejected Medium A Medium severity issue. Reward A payout will be made for this issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed

Comments

@sherlock-admin3
Copy link
Contributor

sherlock-admin3 commented Aug 20, 2024

neko_nyaa

Medium

Raffles with exactly minTicketsThreshold tickets sold can still be cancelled

Summary

Wrong conditional check/comparison in minTicketsThreshold will cause raffles with exactly minTicketsThreshold tickets to still be cancellable.

Root Cause

In checkShouldCancel():

function _checkShouldCancel(uint256 raffleId) internal view {
    // ...
    if (supply > raffle.minTicketsThreshold) revert TargetTicketsReached(); // @audit if supply == minTicketsThreshold then still cancellable
}

https://github.com/sherlock-audit/2024-08-winnables-raffles/blob/main/public-contracts/contracts/WinnablesTicketManager.sol#L440

Note that when the number of tickets sold is equal to minTicketsThreshold of the raffle, then the raffle is still cancellable. This is inconsistent with the code documentation about the use of minTicketsThreshold.

/// @return minTicketsThreshold minimum number of tickets that needs to be sold before
///         this raffle is elligible for drawing a winner

https://github.com/sherlock-audit/2024-08-winnables-raffles/blob/main/public-contracts/contracts/WinnablesTicketManager.sol#L75-L76

Furthermore, this is also inconsistent with _checkShouldDraw() for checking if a raffle should be drawable.

function _checkShouldDraw(uint256 raffleId) internal view {
    // ...
    if (currentTicketSold < raffle.minTicketsThreshold) revert TargetTicketsNotReached(); // @audit if target ticket is strictly less, then raffle is not drawable
}

One must also note that cancelRaffle() was designed to be callable by anyone (so as to prevent prize locking).

https://github.com/sherlock-audit/2024-08-winnables-raffles/blob/main/public-contracts/contracts/WinnablesTicketManager.sol#L278

Therefore, when a raffle ends up with exactly minTicketsThreshold, anyone can still cancel the raffle and deny the potential winner their winnings, even if the raffle was supposed to be drawable.

Internal pre-conditions

  1. The raffle needs to have had exactly minTicketsThreshold sold

External pre-conditions

No response

Attack Path

No response

Impact

If a raffle ends up with exactly minTicketsThreshold, anyone can still cancel the raffle and deny the potential winner their winnings, even if the raffle was supposed to be drawable.

PoC

No response

Mitigation

The correct comparison should be if (supply >= raffle.minTicketsThreshold) revert TargetTicketsReached();

Duplicate of #26

@github-actions github-actions bot added the Excluded Excluded by the judge without consulting the protocol or the senior label Aug 29, 2024
@sherlock-admin3 sherlock-admin3 changed the title Prehistoric Metal Rabbit - Raffles with exactly minTicketsThreshold tickets sold can still be cancelled neko_nyaa - Raffles with exactly minTicketsThreshold tickets sold can still be cancelled Sep 4, 2024
@sherlock-admin3 sherlock-admin3 added the Non-Reward This issue will not receive a payout label Sep 4, 2024
@neko-nyaa
Copy link

Escalate. There are multiple escalated issues that can be duped with this. This is to bring attention to also validate this in case the other duped issues are accepted.

@sherlock-admin3
Copy link
Contributor Author

Escalate. There are multiple escalated issues that can be duped with this. This is to bring attention to also validate this in case the other duped issues are accepted.

You've created a valid escalation!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

@sherlock-admin4 sherlock-admin4 added the Escalated This issue contains a pending escalation label Sep 4, 2024
@Brivan-26
Copy link

A similar issue with involved discussion is going on #26

@mystery0x
Copy link
Collaborator

A fixed is desired to perfect the conditional check but it's deemed low given the trivial change needed.

@v-kirilov
Copy link

A similar issue with involved discussion is #395

@WangSecurity
Copy link

Planning to accept the escalation, validate with medium severity and duplicate with #26. For more details, see the discussion under #26.

@sherlock-admin3 sherlock-admin3 added Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed labels Sep 16, 2024
@WangSecurity WangSecurity added Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A Medium severity issue. and removed Excluded Excluded by the judge without consulting the protocol or the senior labels Sep 20, 2024
@sherlock-admin2 sherlock-admin2 added Reward A payout will be made for this issue and removed Non-Reward This issue will not receive a payout labels Sep 20, 2024
@WangSecurity
Copy link

Result:
Medium
Duplicate of #26

@sherlock-admin2 sherlock-admin2 removed the Escalated This issue contains a pending escalation label Sep 20, 2024
@sherlock-admin3 sherlock-admin3 added the Escalation Resolved This issue's escalations have been approved/rejected label Sep 20, 2024
@sherlock-admin4
Copy link
Contributor

Escalations have been resolved successfully!

Escalation status:

@sherlock-admin2
Copy link

The protocol team fixed this issue in the following PRs/commits:
Winnables/public-contracts#23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Escalation Resolved This issue's escalations have been approved/rejected Medium A Medium severity issue. Reward A payout will be made for this issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed
Projects
None yet
Development

No branches or pull requests

8 participants