Skip to content

Fix out-of-bounds argv access in SNP attestation JS binding#7818

Merged
achamayou merged 1 commit into
mainfrom
copilot/fix-out-of-bounds-argv-access
Apr 14, 2026
Merged

Fix out-of-bounds argv access in SNP attestation JS binding#7818
achamayou merged 1 commit into
mainfrom
copilot/fix-out-of-bounds-argv-access

Conversation

Copilot AI commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

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) and argv[3] (line 79) were accessed without first checking that argc >= 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 the argv array, potentially causing a crash or leaking stack contents.

Fix

Gate access to argv[2] on argc >= 3 and access to argv[3] on argc >= 4, using short-circuit evaluation so the JS_IsUndefined check is only reached when the index is valid.

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>
@maxtropets maxtropets marked this pull request as ready for review April 14, 2026 13:13
@maxtropets maxtropets requested a review from a team as a code owner April 14, 2026 13:13
Copilot AI review requested due to automatic review settings April 14, 2026 13:13
Copilot AI requested a review from maxtropets April 14, 2026 13:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 behind argc >= 3 before calling JS_IsUndefined.
  • Gate argv[3] access behind argc >= 4 before calling JS_IsUndefined.

@achamayou achamayou merged commit c0e8742 into main Apr 14, 2026
23 checks passed
@achamayou achamayou deleted the copilot/fix-out-of-bounds-argv-access branch April 14, 2026 16:17
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.

4 participants