Raisebox Faucet

First Flight #50
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: medium
Valid

## Critical & High Severity Findings ### 🔴 [H-1] Burn Function Transfers Entire Contract Balance Instead of Specified Amount

### 🔴 [H-1] Burn Function Transfers Entire Contract Balance Instead of Specified Amount

**Severity:** HIGH

**Location:** Line 132

**Description:**

The `burnFaucetTokens` function has a critical flaw - it transfers the **entire contract balance** to the owner, not just the `amountToBurn` specified in the parameter.

```solidity

function burnFaucetTokens(uint256 amountToBurn) public onlyOwner {

require(amountToBurn <= balanceOf(address(this)), "Faucet Token Balance: Insufficient");

// BUG: This transfers ALL tokens, not just amountToBurn

_transfer(address(this), msg.sender, balanceOf(address(this)));

_burn(msg.sender, amountToBurn);

}

```

**Impact:**

- If owner wants to burn 1000 tokens from a balance of 1,000,000, all 1,000,000 tokens get transferred to owner

- Only 1000 tokens get burned, leaving owner with 999,000 tokens

- Breaks the intended functionality and allows owner to drain the faucet


```solidity
function burnFaucetTokens(uint256 amountToBurn) public onlyOwner {
require(amountToBurn <= balanceOf(address(this)), "Faucet Token Balance: Insufficient");
// BUG: This transfers ALL tokens, not just amountToBurn
_transfer(address(this), msg.sender, balanceOf(address(this)));
_burn(msg.sender, amountToBurn);
}
```

Recommended Mitigation

- remove this code
+ add this code```solidity
function burnFaucetTokens(uint256 amountToBurn) public onlyOwner {
require(amountToBurn <= balanceOf(address(this)), "Faucet Token Balance: Insufficient");
// FIX: Transfer only the amount to be burned
_transfer(address(this), msg.sender, amountToBurn);
_burn(msg.sender, amountToBurn);
}
```
Updates

Lead Judging Commences

inallhonesty Lead Judge 13 days ago
Submission Judgement Published
Validated
Assigned finding tags:

Unnecessary and convoluted logic in burnFaucetTokens

Support

FAQs

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