Christmas Dinner

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

security fixes made to the original contract

the key security fixes made to the original contract:

  1. Reentrancy Protection Fix

    • Before: receive() and other functions were vulnerable to reentrancy

    • Fixed by:

      import { ReentrancyGuard } from "...ReentrancyGuard.sol";
      contract ChristmasDinner is ReentrancyGuard {
      // Added nonReentrant modifier to critical functions
      receive() external payable nonReentrant beforeDeadline {
  2. Deadline Enforcement Fix

    • Before: Participation could be toggled after deadline

    • Fixed by:

      function changeParticipationStatus() external beforeDeadline {
      bool newStatus = !participants[msg.sender];
      participants[msg.sender] = newStatus;
      emit ChangedParticipation(msg.sender, newStatus);
      }
  3. Deposit Limit Fix

    • Before: No limit on deposits, risk of overflow

    • Fixed by:

      uint256 private constant MAX_DEPOSIT = 1000 ether;
      if (msg.value > MAX_DEPOSIT) revert ExceedsMaxDeposit();
  4. Host Management Security Fix

    • Before: Single-step host change was risky

    • Fixed by adding two-step process:

      function proposeNewHost(address _newHost) external onlyHost {
      // ... validation
      }
      function acceptHostRole() external {
      // ... time-bound acceptance
      }
  5. Token Whitelist Security Fix

    • Before: Whitelist could potentially be modified

    • Fixed by:

      mapping(address => bool) public immutable whitelistedTokens;
  6. ETH Transfer Security Fix

    • Before: Used .transfer() which could fail

    • Fixed by:

      (bool success, ) = _to.call{value: ethBalance}("");
      require(success, "ETH transfer failed");
  7. State Management Fix

    • Before: State changes after external calls

    • Fixed by implementing CEI pattern:

      // Update state before transfer
      etherBalances[msg.sender] = 0;
      participants[msg.sender] = false;
      // Then perform transfers

These fixes significantly improve the contract's security by:

  • Preventing reentrancy attacks

  • Enforcing proper deadline checks

  • Adding deposit limits

  • Implementing secure host transfers

  • Protecting the token whitelist

  • Using safer ETH transfer methods

  • Following best practices for state management

Updates

Lead Judging Commences

0xtimefliez Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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