FestivalPass::buyPass()
function bypasses max supply limitThe FestivalPass::buypass()
function allow users to purchase festival passes. It checks that the payment is correct and that the maximum supply has not been reached by verifying the current passSupply
before minting a pass.
However, the function violates the Checks-Effects-Interactions (CEI) pattern. It performs an external interaction (via _mint(msg.sender, ...)
) before updating the internal state (passSupply++
). If msg.sender
is a contract that implements the IERC1155Receiver
interface, it can re-enter buyPass()
through the onERC1155Received()
hook before the supply is updated, effectively bypassing the passMaxSupply
constraint.
Likelihood:
Anyone can re-enters this function due to the max supply that can be bypass.
The state variable passSupply
is only updated after the external interaction, allowing as many entries as possible.
Impact:
The attacker can bypass the passMaxSupply
limit and mint more pass (token) than intended, breaking scarcity.
This can prevent user from buying a pass, therefore severly disrupting the functionnality of the protocol.
infinite minting of pass can lead to gas exhaustion and transaction failures.
An attacker can mint excessive BEAT token rewards, which may lead to inflation or imbalances in the token economy.
Add this proof of concept in your FestivalPass.t.sol
to test this reentrancy attacks.
The recommendation is to follow CEI patter by updating the passSupply
before making the external call. Additionally, consider using ReentrancyGuard
(nonReentrant modifier).
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.