Skip to content

[release/17.0] Fix CodeQL stack-trace exposure and disabled certificate validation findings - #22034

Closed
Mitch Denny (mitchdenny) wants to merge 1 commit into
mitchdenny-backport-17-0-36-pr21912from
mitchdenny-backport-17-0-37-pr21896
Closed

Mitch Denny (mitchdenny) wants to merge 1 commit into
mitchdenny-backport-17-0-36-pr21912from
mitchdenny-backport-17-0-37-pr21896

Conversation

@mitchdenny

Copy link
Copy Markdown
Member

Description

Backport of #21896 to release/17.0 (cherry-picked from 12e7e5d with no modifications).

Layer 37 of 55 in the release/17.0 backport stack; stacked on #22033.

Backport recommendation: No — Extension and repo-tooling code ship from main.

Validation: Stable patch IDs match (16b6fde1808138a46a71097aae00dbef1f756a16). Builds/tests not run for this unchanged cherry-pick.

Backport of #21896

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

…indings (#21896)

## Description

Fixes the "simple/trivial" bucket of the internal CodeQL SDL scan
findings (S360 KPI SFI-PS3.1.1, `microsoft-aspire` `main`, scans
2026-11-03..06). The report has no line numbers and Microsoft's custom
queries aren't available locally, so the flagged sinks were located by
reading the code, fixed using the standard remediation patterns, and
checked with the equivalent public GitHub queries (see Validation); no
`// CodeQL [SMxxxxx]` suppressions were needed.

### 1. `CodeQL.SM01524` / `js/stack-trace-exposure` —
`.github/extensions/issue-triage-canvas/extension.mjs`

The local canvas HTTP server returned `String(error.stderr ||
error.message || error)` in the HTTP 500 body and in the per-issue close
failures. `gh` stderr, Node error messages and stacks can contain local
paths, command lines and API response bodies.

- Response logic lives in `http-response.mjs` (`respondWithError`,
`toCloseFailure`) so tests can import it; `http-response.test.mjs` runs
a real HTTP server and asserts the 500 body and close failures never
contain the raw error, path or stack.
- The full error is now logged server-side via `copilotSession?.log`
(the 500 handler already logged it; `closeIssues` now logs each failure
too).
- The response only carries a fixed message chosen by
`describeSafeError` (new `safe-error.mjs`): it classifies the error (gh
missing, not authenticated, rate limited, permission denied, not found)
and returns a **string literal**, otherwise a generic "see the Copilot
session log" message. No caught value flows into the response, which is
what removes the flagged source-to-sink flow.
- The "Stored preferences could not be parsed" warning (also returned to
the browser) embedded `SyntaxError.message`; it is now a fixed string
with the detail logged.
- Close-failure UX stays usable: the board status now appends the
sanitized reasons (e.g. `Closed 1 issue(s). Failures: 1. GitHub denied
the request. Check your permissions for this repository.`). Previously
it showed only the failure count.

### 2. `CodeQL.SM03616` / `js/disabling-certificate-validation` — 5
sites in extension unit tests

All five connected to the extension's own loopback servers with
`rejectUnauthorized: false`. They now keep TLS validation on and **pin**
the server's per-session self-signed certificate (SAN `localhost`)
through the `ca` option, still connecting by the `localhost` hostname so
normal chain and hostname verification runs. No `checkServerIdentity`
override or `NODE_TLS_REJECT_UNAUTHORIZED` is used.

- `extension/src/test/aspireDcpServer.test.ts`: `WebSocket`
(`wss://…/run_session/notify`) and `https.request` use `ca` from
`connectionInfo.certificate`.
- `extension/src/test/rpc/aspireRpcServer.test.ts`: `tls.connect` uses
`ca: rpcServer.connectionInfo.cert`.
- `extension/src/test/rpc/e2eServerTests.test.ts`: `tls.connect` uses
`rpcServerInfo.cert`; the DCP `https.request` uses the lease's
`DEBUG_SESSION_SERVER_CERTIFICATE`.
- New `certificateBase64ToPem` in `extension/src/utils/security.ts`: the
DCP server publishes its certificate as base64 DER, while Node's `ca`
needs PEM.
- Sibling with the identical pattern (not in the CSV), fixed the same
way because the DCP certificate is already on `DcpServerConnectionInfo`:
`extension/src/testing/e2eStateFileBridge.ts`
(`getDcpRunSessionInfoForE2E`).

### Not changed (mentioned for follow-up)

- `extension/src/debugger/languages/azureFunctions.ts`
(`rejectUnauthorized: false` against the Functions host
`/admin/host/status`): same pattern, but it is production product
behavior and a separate decision, so it is out of scope here.
- `extension/src/test-e2e/helpers/assertions.ts` (`getUrlText`,
`https.get(..., { rejectUnauthorized: false })`): not in the findings;
it fetches the dashboard's dev-certificate URL, where the certificate
isn't available to pin. Left as-is.

### Validation

| Command | Result |
| --- | --- |
| `codeql database analyze` (CodeQL CLI 2.27.4,
`codeql/javascript-queries` 2.5.0:
`Security/CWE-209/StackTraceExposure.ql` +
`Security/CWE-295/DisablingCertificateValidation.ql`) on
`.github/extensions` + `extension/src`, PR base vs this branch | base: 8
results (the 6 reported sites, plus `e2eStateFileBridge.ts` and
`test-e2e/helpers/assertions.ts`). This branch: 1 result,
`test-e2e/helpers/assertions.ts:611`, which is not in the reported
findings and is left as described above. |
| `node --check .github/extensions/issue-triage-canvas/extension.mjs` |
passed |
| `node .github/extensions/validate-extensions.mjs` (syntax-checks all
`.mjs`, runs the new `safe-error.test.mjs` and `http-response.test.mjs`)
| passed: `Validated 1 manifest(s), 31 module(s), imported 14 safe
module(s), ran 14 test file(s).` |
| `corepack yarn run compile-tests` (in `extension/`) | passed |
| `corepack yarn run lint` | passed |
| `corepack yarn run compile` (webpack, bundles the E2E bridge change) |
passed (only pre-existing warnings) |
| `corepack yarn vscode-test --run out/test/security.test.js` | 7
passing |
| `corepack yarn vscode-test --run out/test/aspireDcpServer.test.js` |
33 passing |
| `corepack yarn vscode-test --run out/test/rpc/aspireRpcServer.test.js`
| 4 passing |
| `corepack yarn vscode-test --run out/test/rpc/e2eServerTests.test.js`
| 3 passing (real extension, pinned RPC + DCP clients) |
| `corepack yarn vscode-test --run out/test/e2eStateFileBridge.test.js`
| 61 passing |
| `corepack yarn vscode-test --run out/test/e2eLaunchProfile.test.js` |
126 passing |

Not verified: Microsoft's internal scan (its custom queries may differ
from the public ones), so Security Champion / scan confirmation that
these alerts clear is still needed. The E2E bridge's own `/info` call
runs only in the opt-in E2E harness and was verified by compile and the
bridge unit tests, not by an end-to-end E2E run.

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit 12e7e5d)
@github-actions

This comment has been minimized.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-37-pr21896 branch from 2536620 to 1829d8a Compare November 10, 2026 04:23
@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-37-pr21896 branch from 1829d8a to 2536620 Compare November 10, 2026 04:25
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22034

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22034"

@mitchdenny

Copy link
Copy Markdown
Member Author

Approved for inclusion in release/17.0. Do not merge yet.

@github-actions

This comment has been minimized.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-37-pr21896 branch from 3ba7a2f to 2536620 Compare November 10, 2026 06:33
@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-37-pr21896 branch from 2536620 to 3ba7a2f Compare November 10, 2026 07:46
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-37-pr21896 branch from 3ba7a2f to 2536620 Compare November 10, 2026 08:43
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.

2 participants