idl-spec: avoid panic on malformed array types (DoS fix)#4242
idl-spec: avoid panic on malformed array types (DoS fix)#4242yukikm 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 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_strfunction to returnResult<IdlType, anyhow::Error>instead ofIdlType - Replaces
.rsplit_once(';').unwrap()with proper error handling viaok_or_else - Replaces
IdlType::from_str(raw_type).unwrap()withmap_errfor 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.
|
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; |
|
As with other PRs, conflicts with #4247, so I'm closing. |
Fixes a panic in anchor-lang-idl-spec when parsing malformed array type strings (e.g. "[u8 32]").
Write-up: https://github.com/yukikm/superteam-solana-audit-writeups/blob/main/anchor-idl-array-no-panic.md