Repository navigation
[release/17.0] Fix CodeQL stack-trace exposure and disabled certificate validation findings - #22034
Closed
Mitch Denny (mitchdenny) wants to merge 1 commit into
Conversation
…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)
14 tasks
This comment has been minimized.
This comment has been minimized.
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-37-pr21896
branch
from
November 10, 2026 04:23
2536620 to
1829d8a
Compare
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-37-pr21896
branch
from
November 10, 2026 04:25
1829d8a to
2536620
Compare
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22034Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22034" |
Mitch Denny (mitchdenny)
marked this pull request as ready for review
November 10, 2026 05:10
Mitch Denny (mitchdenny)
requested review from
Adam Ratzman (adamint) and
Ella Hathaway (ellahathaway)
as code owners
November 10, 2026 05:10
Member
Author
|
Approved for inclusion in release/17.0. Do not merge yet. |
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-37-pr21896
branch
from
November 10, 2026 06:03
2536620 to
3ba7a2f
Compare
This comment has been minimized.
This comment has been minimized.
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-37-pr21896
branch
from
November 10, 2026 06:33
3ba7a2f to
2536620
Compare
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-37-pr21896
branch
from
November 10, 2026 07:46
2536620 to
3ba7a2f
Compare
Contributor
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-37-pr21896
branch
from
November 10, 2026 08:43
3ba7a2f to
2536620
Compare
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.
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
<remarks />and<code />elements on your triple slash comments?