Skip to content

idl/spec: avoid panic when parsing invalid array types#4247

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

idl/spec: avoid panic when parsing invalid array types#4247
yukikm wants to merge 1 commit intosolana-foundation:masterfrom
yukikm:fix-idl-array-panic

Conversation

@yukikm
Copy link
Copy Markdown

@yukikm yukikm commented Feb 15, 2026

Fixes a panic/DoS in IdlType::from_str when parsing malformed array-like type strings (e.g. [u832]).

Changes: replace unwrap() in array parser with error-returning logic; add regression tests.

Write-up: https://paste.rs/yHF7r

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

vercel bot commented Feb 15, 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 panic/DoS vulnerability in the IdlType::from_str parser when handling malformed array-like type strings. The issue was caused by unwrap() calls that would panic on invalid input such as "[u832]" (missing semicolon separator).

Changes:

  • Refactored array_from_str helper function to return anyhow::Result<IdlType> instead of panicking
  • Replaced all unwrap() calls with proper error handling using ok_or_else and map_err
  • Added validation for empty array lengths and malformed nested array syntax
  • Added two regression tests to prevent future panics on invalid input

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

@jamie-osec
Copy link
Copy Markdown
Collaborator

Closing in favour of #4029

@jamie-osec jamie-osec closed this Mar 13, 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