Christmas Dinner

First Flight #31
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: high
Invalid

No Amount Validation Check (Root Cause: Missing amount validation check) :

Summary

Description:

The contract does not validate if a user is depositing a non-zero amount when signing up or contributing tokens. This lack of validation allows a user to sign up or contribute without depositing any tokens, which could lead to participants being incorrectly added without making an actual contribution. This vulnerability can be exploited by malicious users to gain access to the event without making any real deposit.

Vulnerability Details

Proof of Concept:

A user can call the ChritsmasDinner::deposit function with a zero amount, thus being added to the participant list without contributing any tokens.

contract Exploit {
ChristmasDinner dinner;
constructor(address _dinnerAddress) {
dinner = ChristmasDinner(_dinnerAddress);
}
function exploit() public {
dinner.deposit(address(0), 0); // Deposit 0 amount
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.27;
import "forge-std/Test.sol";
import { ChristmasDinner } from "./ChristmasDinner.sol";
contract TestChristmasDinner is Test {
ChristmasDinner dinner;
function setUp() public {
dinner = new ChristmasDinner(address(0), address(0), address(0));
}
function testDepositZeroAmount() public {
vm.expectRevert("Amount must be greater than 0");
dinner.deposit(address(0), 0); // Should revert on zero amount deposit
}
}

Impact

This issue can lead to the inclusion of non-contributing users in the participant list, potentially allowing them to access event resources without paying. This could undermine the event’s purpose, as non-paying users could receive benefits reserved for contributors, leading to an unfair distribution of resources or rewards.

Tools Used

aderyn, slither, manual, foundry forge

Recommendations

Add validation checks in the ChritsmasDinner::deposit function to ensure that a non-zero amount is deposited when a user signs up or contributes.

require(_amount > 0, "Amount must be greater than 0");
Updates

Lead Judging Commences

0xtimefliez Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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

Give us feedback!