Rust Fund

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

Campaigns with a name longer than 32 bytes can never be created, even though the account allocates 200 bytes for the name

Root + Impact

The Fund account reserves space for a name of up to 200 bytes (#[max_len(200)]), which signals that long campaign names are supported. But the fund's PDA is derived with the full name as a seed (seeds = [name.as_bytes(), creator.key().as_ref()]), and Solana limits every individual PDA seed to 32 bytes. For any name longer than 32 bytes no valid program address exists at all, client-side address derivation already fails, and fund_create can never succeed. Ordinary descriptive campaign names (a typical project title with a subtitle easily exceeds 32 bytes) are silently impossible to launch, and nothing in the program, its errors, or its docs tells creators why creation keeps failing.

Description

#[derive(Accounts)]
#[instruction(name: String)]
pub struct FundCreate<'info> {
// @> #[account(init, payer = creator, space = 8 + Fund::INIT_SPACE,
// @> seeds = [name.as_bytes(), creator.key().as_ref()], bump)] // seed limit: 32 bytes
pub fund: Account<'info, Fund>,
...
}
​
pub struct Fund {
#[max_len(200)] // suggests 200-byte names are supported
pub name: String,
...
}

Risk

Likelihood: High - triggers deterministically for any name of 33 bytes or more, a very common input for real campaign titles.
Impact: Low - no funds are lost; affected creators simply cannot launch their campaign until they shorten the name, with no error message pointing at the actual cause. It is a functional dead zone across most of the advertised name-length range.

Proof of Concept

Verified with solana-program-test (test passes). Client-side PDA derivation for a 40-byte name cannot produce an address (Solana's seed length limit), and submitting fund_create with such a name fails; the same flow with a short name succeeds.

let name = "a".repeat(40); // < 200-byte max_len, > 32-byte seed limit
let res = send(fund_create_ix(name)).await;
assert!(res.is_err(), "fund creation with a 40-byte name must fail");

Recommended Mitigation

Derive the PDA from a fixed-size digest of the name instead of the raw name (for example the first 32 bytes of a hash of the full name), or validate at creation that names are at most 32 bytes and reduce the account allocation to match, so the supported range is consistent and fails with a clear error.

Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 3 hours 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!