Christmas Dinner

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

Lack of Validation for Amount in deposit function

Summary

The lack of validation for _amount can lead to several practical and security issues in the deposit function.

Impact

  • Wasteful Operation: The function will execute unnecessary state changes, such as updating the balances mapping and emitting event.

    • Gas will be consumed for this redundant operations, unnecessarily increasing transaction costs for users.

  • Confusion In Events:
    when _amount = events like GenerousAdditionalContribution or NewSignup will still be emitted.
    this might confuse user or developers interpreting the logs, as the deposit amount is effectively 0.

  • Logical Inconsistencies:

    • A deposit of zero tokens do not logically qualify as a "deposit" or "signUp".

    • Allowing such case undermines the purpose of the function, which is to register meaningful contributions.

Tools Used

Manual review

Recommendations

Add a validation check at the start of the function to ensure _amount > 0

Updates

Lead Judging Commences

0xtimefliez Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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