Raisebox Faucet

First Flight #50
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

The `MintedNewFaucetTokens` event in the `RaiseBoxFaucet::mintFaucetTokens` function is emitted after the `_mint` function call, potentially causing confusion and misinterpretation of the event.

Root + Impact

Description

The MintedNewFaucetTokens event is emitted after the _mint function call, potentially causing confusion and misinterpretation of the event.

function mintFaucetTokens(address to, uint256 amount) public onlyOwner {
if (to != address(this)) {
revert RaiseBoxFaucet_MiningToNonContractAddressFailed();
}
if (balanceOf(address(to)) > 1000 * 10 ** 18) {
revert RaiseBoxFaucet_FaucetNotOutOfTokens();
}
_mint(to, amount);
@> emit MintedNewFaucetTokens(to, amount);
}

Risk

Likelihood:

  • The MintedNewFaucetTokens event is always emitted after the ERC20 transfer event.

Impact:

  • Confusion and misinterpretation of the event by users and dapps.

Proof of Concept

Add the following code snippet to the RaiseBoxFaucet.t.sol test file.

This code snippet is designed to demonstrate the MintedNewFaucetTokens event is emitted after the _mint function, which also emits events.

function testMintNewFaucetTokensEvents() public {
// reduce balance of contract
console.log("Balance of contract: ", raiseBoxFaucet.balanceOf(address(raiseBoxFaucet)));
vm.prank(owner);
raiseBoxFaucet.burnFaucetTokens(raiseBoxFaucet.balanceOf(address(raiseBoxFaucet)) - 1);
console.log("Balance of contract after burn: ", raiseBoxFaucet.balanceOf(address(raiseBoxFaucet)));
// Try to mint more;
vm.prank(owner);
vm.expectEmit(true, true, false, true, address(raiseBoxFaucet));
// First event transfer
emit Transfer(address(0), address(raiseBoxFaucet), 2222e18);
vm.expectEmit(true, false, false, true, address(raiseBoxFaucet));
// Second event minted, after transfer should be in reverse order
emit MintedNewFaucetTokens(address(raiseBoxFaucet), 2222e18);
raiseBoxFaucet.mintFaucetTokens(address(raiseBoxFaucet), 2222e18);
console.log("Balance of contract after mint: ", raiseBoxFaucet.balanceOf(address(raiseBoxFaucet)));
}

Recommended Mitigation

Move the MintedNewFaucetTokens event before the _mint function call.

function mintFaucetTokens(address to, uint256 amount) public onlyOwner {
if (to != address(this)) {
revert RaiseBoxFaucet_MiningToNonContractAddressFailed();
}
if (balanceOf(address(to)) > 1000 * 10 ** 18) {
revert RaiseBoxFaucet_FaucetNotOutOfTokens();
}
+ emit MintedNewFaucetTokens(to, amount);
_mint(to, amount);
- emit MintedNewFaucetTokens(to, amount);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 13 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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