The SantasList
contract assumes that only Santa can change the status of addresses . The checkList()
function changes the status of an address to a new one, but does not include access control, so anyone can call it, including an attacker.
The vulnerability is in the SantasList::checkList
function in the SantasList.sol
contract starting at line 121.
The checkList()
function should only be called by Santa, but it does not contain access control, so anyone can call it and change the status of the address.
To limit who can change the status of an address, we need to check that the calling function, msg.sender
, is the owner of the contract.
A possible use case for this function is for Santa to give addresses statuses and then check them. The essence of the contract is to give addresses with certain statuses special features. But given that the final status is only set after 2 checks, even if the attacker passes the first check, he will not pass the second check
Since anyone can set the status, including attackers, this opens up the possibility that depending on the context, these unauthorized and potentially malicious strings could be dangerous.
According to the following NatSpec comment: This function allows only Santa to set a new status
, only Santa can set a status-this is the basic assumption, and the functionality that is not true is a high severity vulnerability, but since there is then a second check, the vulnerability is considered medium severity
The following test sets the status of "s_theListCheckedOnce"
using the address of the user . When executed, this test will pass, demonstrating that the user can set the status :
Run the test:
Which yields the following output:
Include access control so that the checkList
function can only be called by Santa. This can be achieved in two ways
Using an if
statement, calling the function will result in a SantasList__NotSanta()
custom error if the address calling the function is not the Santa:
Using onlySanta
modifier adds logic to check that the msg.sender
is the owner of the contract before executing the function's logic:
Anyone is able to call checkList() changing the status of a provided address. This is not intended functionality and is meant to be callable by only Santa.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.