Santa's List

AI First Flight #3
Beginner FriendlyFoundry
EXP
View results
Submission Details
Impact: medium
Likelihood: medium
Invalid

Missing Validation in `checkTwice` for Unchecked Addresses

Root + Impact

Description

  • The `checkTwice` function doesn't explicitly validate that an address was actually checked once before being checked twice. While it checks if statuses match, it doesn't verify that a check actually occurred, relying on enum default behavior which may be confusing and error-prone.

    ### Root + Impact

    **Description:**

    * The normal behavior is that `checkTwice` should only work if someone was first checked once, and the statuses should match.

    * The issue is that the function only checks if statuses match, but doesn't explicitly verify that the address was checked once. This relies on enum default values and implicit behavior, making the code less clear and potentially error-prone.

    ```solidity

    // @> SantasList.sol:133-139

    function checkTwice(address person, Status status) external onlySanta {

    if (s_theListCheckedOnce[person] != status) { // @> Doesn't explicitly check if person was checked once

    revert SantasList__SecondCheckDoesntMatchFirst();

    }

    s_theListCheckedTwice[person] = status;

    emit CheckedTwice(person, status);

    }

    ```


Risk

Likelihood:

  • * This occurs when Santa tries to check someone twice, as there's no explicit validation

    * The code relies on implicit enum default behavior

Impact:

  • * Less clear code intent and potential for confusion

    * Relies on enum default values which may not be obvious to developers

    * Could lead to unexpected behavior if enum order changes

Proof of Concept

```solidity
// No explicit check that person was checked once
// Relies on enum default value being NOT_CHECKED_TWICE or matching status
```

Recommended Mitigation

```diff
function checkTwice(address person, Status status) external onlySanta {
+ Status firstCheck = s_theListCheckedOnce[person];
+ if (firstCheck == Status.NOT_CHECKED_TWICE) {
+ revert SantasList__NotCheckedOnce();
+ }
- if (s_theListCheckedOnce[person] != status) {
+ if (firstCheck != status) {
revert SantasList__SecondCheckDoesntMatchFirst();
}
s_theListCheckedTwice[person] = status;
emit CheckedTwice(person, status);
}
```
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge 16 days ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!