Rust Fund

AI First Flight #9
Beginner FriendlyRust
EXP
View results
Submission Details
Impact: medium
Likelihood: medium
Invalid

No upper bound validation on u64 parameters allows state corruption via overflow

Root + Impact

Description

  • Describe the normal behavior in one or more sentences

  • Explain the specific issue or problem in one or more sentences

# Finding 4: MAX_ARG inputs accepted without bounds checking
**Severity:** Medium
**Title:** No upper bound validation on u64 parameters allows state corruption via overflow
## Description
Multiple instructions (`fund_create`, `contribute`, `set_deadline`) accept raw `u64` input parameters without enforcing upper limits or sanity checks. While Anchor prevents absolute primitive math panics via safe math operations under the hood, allowing extreme numbers like `u64::MAX` breaks the program's business constraints. It corrupts state states like target goals, campaign parameters, and deadlines.
## Impact
Campaign account variables can be manipulated into absurd values. For example, a campaign target goal can be set to an unreachable value, or `amount_raised` can scale incorrectly. This causes sequential accounting logic checks (such as withdraw or refund math evaluations) to break, creating systemic failures or denial-of-service conditions.
## Proof of Concept
This simulation trace shows how unbounded parameter entry corrupts accounting metrics:
1. A creator initializes a new fund with a goal argument set to `u64::MAX`.
2. A contributor deposits funds, but the calculated target tracking parameters become corrupted.
3. Subsequent logic queries evaluate corrupted state variables, rendering matching milestones unreachable.
```rust
// 1. Creator inputs max integer value into the campaign setup
fund_create(name="OverflowCampaign", goal=18446744073709551615)
// 2. State variable gets corrupted, locking subsequent target tracking evaluation logic
```
## Recommended Mitigation
This mitigation applies boundary check validation rules to verify parameter sizes against secure protocol bounds before mutating state fields.
Introduce appropriate upper threshold assertions inside the instruction methods:
```rust
// Inside the contribute instruction logic
require!(amount > 0, ErrorCode::ZeroContribution);
require!(amount <= 1_000_000 * LAMPORTS_PER_SOL, ErrorCode::ContributionTooLarge);
// Inside the fund_create instruction logic
require!(goal > 0, ErrorCode::ZeroGoal);
require!(goal <= 10_000_000 * LAMPORTS_PER_SOL, ErrorCode::GoalTooLarge);
```
// Root cause in the codebase with @> marks to highlight the relevant section

Risk

Likelihood:

  • Reason 1 // Describe WHEN this will occur (avoid using "if" statements)

  • Reason 2

Impact:

  • Impact 1

  • Impact 2

Proof of Concept

Recommended Mitigation

- remove this code
+ add this code
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge 9 days ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!