idl/spec: avoid panic when parsing invalid array types#4247
Closed
yukikm wants to merge 1 commit intosolana-foundation:masterfrom
Closed
idl/spec: avoid panic when parsing invalid array types#4247yukikm wants to merge 1 commit intosolana-foundation:masterfrom
yukikm wants to merge 1 commit intosolana-foundation:masterfrom
Conversation
|
Someone is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
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_strhelper function to returnanyhow::Result<IdlType>instead of panicking - Replaced all
unwrap()calls with proper error handling usingok_or_elseandmap_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.
This was referenced Feb 16, 2026
Collaborator
|
Closing in favour of #4029 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a panic/DoS in
IdlType::from_strwhen 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