Skip to content

idl-spec: avoid panic on malformed array types (DoS fix)#4242

Closed
yukikm wants to merge 1 commit intosolana-foundation:masterfrom
yukikm:idl-array-no-panic
Closed

idl-spec: avoid panic on malformed array types (DoS fix)#4242
yukikm wants to merge 1 commit intosolana-foundation:masterfrom
yukikm:idl-array-no-panic

Conversation

@yukikm
Copy link
Copy Markdown

@yukikm yukikm commented Feb 14, 2026

Fixes a panic in anchor-lang-idl-spec when parsing malformed array type strings (e.g. "[u8 32]").

  • Replaces unwrap() with Result propagation + structured errors
  • Adds regression tests

Write-up: https://github.com/yukikm/superteam-solana-audit-writeups/blob/main/anchor-idl-array-no-panic.md

Copilot AI review requested due to automatic review settings February 14, 2026 23:08
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 14, 2026

Someone is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Denial of Service (DoS) vulnerability in the anchor-lang-idl-spec parser by replacing panic-inducing unwrap() calls with proper error handling when parsing malformed array type strings.

Changes:

  • Converts array_from_str function to return Result<IdlType, anyhow::Error> instead of IdlType
  • Replaces .rsplit_once(';').unwrap() with proper error handling via ok_or_else
  • Replaces IdlType::from_str(raw_type).unwrap() with map_err for contextual error messages
  • Adds two regression tests covering the fixed panic scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yukikm
Copy link
Copy Markdown
Author

yukikm commented Feb 14, 2026

Note: the failing status is from Vercel preview ("Authorization required to deploy") which is expected for fork PRs. This change is limited to idl/spec panic-hardening + tests; cd idl/spec && cargo test passes locally.

@jamie-osec
Copy link
Copy Markdown
Collaborator

As with other PRs, conflicts with #4247, so I'm closing.
Please don't blindly use AI to spam our PR queue.

@jamie-osec jamie-osec closed this Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants