RustFund

First Flight #36
Beginner FriendlyRust
100 EXP
View results
Submission Details
Severity: high
Invalid

Missing Input Validation

Summary

The fund_create function lacks essential input validation

Vulnerability Details

No validation for:

  • Empty strings

  • Invalid goal amounts

  • Excessive string lengths

Impact

Could lead to contract freezing or unexpected behavior

Proof Of Concept

// Example of invalid input
let empty_name = "".to_string();
let excessive_desc = "A".repeat(5001); // Exceeds max length
fund_create(ctx, empty_name, excessive_desc, 0); // Could freeze contract

Tools Used

Manual review

Recommendations

Add comprehensive input validation:

pub fn fund_create(ctx: Context<FundCreate>, name: String, description: String, goal: u64) -> Result<()> {
require_keys!(
!name.is_empty(),
ErrorCode::InvalidInput,
"Name cannot be empty"
);
require_keys!(
name.len() <= 200,
ErrorCode::InvalidInput,
"Name too long"
);
require_keys!(
description.len() <= 5000,
ErrorCode::InvalidInput,
"Description too long"
);
require_keys!(
goal > 0,
ErrorCode::InvalidInput,
"Goal must be greater than 0"
);
// ... rest of function
}
Updates

Appeal created

bube Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

[Invalid] Lack of length validation of `name` and `description` in `fund_create` function

There is a validation for the lengths of `name` and `description` in `fund_create` function: ``` pub struct Fund { #[max_len(200)] pub name: String, #[max_len(5000)] ..... } ``` Anchor will check for the lengths of these parameters and the function will fail if they have more characters than the constraints.

Support

FAQs

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