Fix out-of-bounds argv access in SNP attestation JS binding#7818
Merged
Conversation
Gate argv[2] access on argc >= 3 and argv[3] access on argc >= 4 to prevent out-of-bounds stack reads when fewer arguments are passed. Agent-Logs-Url: https://github.com/microsoft/CCF/sessions/97d2f272-99d6-406e-8823-18c552582aa3 Co-authored-by: maxtropets <16566519+maxtropets@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
maxtropets
April 14, 2026 13:14
View session
maxtropets
approved these changes
Apr 14, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes an out-of-bounds argv access in the SNP attestation QuickJS binding by guarding optional argument reads with argc checks.
Changes:
- Gate
argv[2]access behindargc >= 3before callingJS_IsUndefined. - Gate
argv[3]access behindargc >= 4before callingJS_IsUndefined.
maxtropets
approved these changes
Apr 14, 2026
achamayou
approved these changes
Apr 14, 2026
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.
Summary
Fixes an out-of-bounds stack read vulnerability in the SNP attestation JavaScript binding (
src/js/extensions/snp_attestation.cpp).Problem
In
js_verify_snp_attestation(),argv[2](line 64) andargv[3](line 79) were accessed without first checking thatargc >= 3/argc >= 4. Since the function accepts between 2 and 4 arguments (validated on line 40), calling with only 2 or 3 arguments would read past the end of theargvarray, potentially causing a crash or leaking stack contents.Fix
Gate access to
argv[2]onargc >= 3and access toargv[3]onargc >= 4, using short-circuit evaluation so theJS_IsUndefinedcheck is only reached when the index is valid.