The SantasList::collectPresent()
function is open to unauthorized minting because the contract does not control the checklisting process complement. Therefore, it is necessary to verify the complement of the checklisting process.
In Solidity, every variable has a default value. If the value of a variable is not changed, it remains the same as the default value. A mapping defines default values that are pointed to. Also, in the SantasList
contract, the s_theListCheckedOnce(address => Status)
and s_theListCheckedTwice(address => Status)
mappings defined with default values. the Status
enum's default value is NICE
because of its first defined option. This means every user defined as NICE
role which is authorized to minting tokens. Thus, anyone can mint unlimited tokens after bypassing the s_theListCheckedOnce[msg.sender] == Status.NICE && s_theListCheckedTwice[msg.sender] == Status.NICE
check in the collectPresent()
. For minting many tokens, the balanceOf(msg.sender) > 0
can be bypassed by transferring token to another address using transferFrom(address,address,uint256)
.
Attacker can mint unlimited tokens without any permission.
Proof Of Concept
Check the status of the sender's address. Contract will returnStatus.NICE
.
Set the time after the CHRISTMAS_2023_BLOCK_TIME
.
Call collectPresent()
and mint token.
Transfer the minted token to another attacker's address. Thus, set the attacker's balance 0 again.
Call collectPresent()
and mint token again. [Continue in the third step]
Finally run the test with: forge test
Foundry
The Status
enum should start with NOT_CHECKED_TWICE
value to avoid default authorization issue in the mappings.
Relying on balanceOf > 0 in collectPresent() allows the msg.sender to send their present to another address and then collect again.
In Solidity the first element of an enum is the default value. In Santa's List, the means each person is mapped by default to 'NICE'.
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.