The external function buyPresent()
mints a Present NFT to the msg.sender
address. This provides opportunity for a malicious actor to mint extra NFTs for themselves. *This finding is related to other finding titled "buyPresent()
function burns from wrong address".
The external function buyPresent()
calls _mintAndIncrement()
, which mints to the msg.sender
address, not to the intended presentReceiver
address, as shown below:
This introduces a new attack vector, since a related bug (as mentioned in summary) causes the incorrect burning of the SANTA ERC20 token immediately before the aforementioned minting bug, shown below:
With the existence of these two related bugs, a user with the SANTA ERC20 token may bypass the rule of only owning one NFT (as implied by line 151 balance check and line 152 revert message below).
To bypass this rule, an EXTRA_NICE
user, aka malicious actor, may do the following steps
call the collectPresent()
function, acquiring both a SANTA ERC20 token and an NFT.
transfer the SANTA ERC20 token to a different "friend" address
call the buyPresent
function, passing the "friend" address as the parameter, burning the ERC20 token in the "friend" wallet, and minting an NFT for themself.
The below code block is a PoC (written as a forge test) demonstrating the above steps in action, ultimately allowing the attacker to hold 2 NFTs.
A malicious actor may mint more than one NFT for themselves.
Forge
pass msg.sender
as a param into the i_santaToken.burn()
call
add an address to
param to the private function _mintAndIncrement()
, passing to
to _safeMint
, instead of msg.sender
by default.
See corrected code recommendations below:
By adding the address to
param to _mintAndIncrement
, be sure to pass the correct param value to all other calls to _mintAndIncrement
in the contract. (this should often be msg.sender
.)
Example of _mintAndIncrement()
calls in collectPresent()
function:
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.