Skip to content

Security hardening for 1.0.2: connection links, Entra ID host allowlist, npm pipelines - #1040

Merged
Tomasz Naumowicz (tnaum-ms) merged 17 commits into
mainfrom
dev/tnaum/october-patch
Oct 21, 2026
Merged

Tomasz Naumowicz (tnaum-ms) merged 17 commits into
mainfrom
dev/tnaum/october-patch

Conversation

@tnaum-ms

@tnaum-ms Tomasz Naumowicz (tnaum-ms) commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

Security hardening for the 1.0.2 patch release. These changes mitigate issues that were reported to us. Each area is in its own commit.

Extension

  • Connection links: A link that would add a new connection now always asks for confirmation and shows the target (user, hosts, database, collection), even when documentDB.confirmations.showUrlHandlingConfirmations is off. The setting still skips the follow-up prompts and links to connections that are already saved.
  • TLS from links: A link can ask to turn off TLS certificate validation only when every host is on this machine (localhost, 127.0.0.0/8, ::1), and only after an explicit warning that names the target. The user can turn validation off, keep it on, or cancel. For any other host the request is ignored and the confirmation says so. Emulator detection for links uses the same host check.
  • Microsoft Entra ID: The OIDC host allowlist accepts only the Azure public and sovereign cloud domains (azure.com, azure.us, azure.cn).
  • No-authentication connections: Use the same host check as the other auth handlers before relaxing TLS validation.

Build and release (does not affect the installed extension)

  • npm-publish-documentdb-js.yml: The job that can mint publish credentials no longer installs, builds, restores the npm cache, or runs package scripts. It publishes tarballs packed by the verify job, after checking their hashes and package names.
  • pack-npm-packages.ps1: Packs with --ignore-scripts and rejects pack, publish, and install lifecycle scripts in release packages.
  • release-npm-packages.yml: Validates the tarball file name before it is written to an output variable or used in a path.
  • CI: Static checks fail when a committed .npmrc contains npm credentials.

Docs: 1.0.2 changelog and release notes, the setting description, and the "Connect with a URL" user manual page.

Scope

  • Includes the localization bundle update. The version bump to 1.0.2 is left to the release step, as with chore: release 1.0.1.
  • AI pre-review and the author's decisions are recorded in docs/ai-and-plans/features/build-and-test-stack/iterations/02-october-security-hardening/pr-1040-review.md. Both findings were fixed: the .npmrc credential check now catches any npm credential key, and accepted TLS exceptions apply to anonymous loopback connections.

Validation

Case 2 checks ran on 71c76a49 and passed: npm run l10n, npm run prettier-fix, npm run lint, npx vitest run (314 files, 5232 tests passed, 1 skipped), npm run build, and npm run package.

  • The pack script was run in a PowerShell container against a clean package and against one with a prepack script. The publish workflow's pack, hash check, and publish logic was run locally with npm publish --dry-run.
  • Needs a human: A real run of npm-publish-documentdb-js.yml with dry_run=false (Trusted Publishing with a tarball and --provenance). Also a manual check of the link prompts in VS Code: a new connection, a localhost link with tlsAllowInvalidCertificates=true, and a public host link with the same option.

The OIDC host allowlist now recognizes only the Azure public and sovereign
cloud suffixes (azure.com, azure.us, azure.cn). Any other host falls back to
the public-cloud default.

Co-authored-by: Copilot <[email protected]>
…hine

A connection link can now request relaxed certificate validation only when
every host is loopback (localhost, 127.0.0.0/8, ::1). For any other host the
request is dropped and certificate validation stays on; users can still opt
in from the connection settings. Emulator detection for links uses the same
host check, and the no-authentication handler now checks the hosts like the
other handlers before relaxing validation.

Co-authored-by: Copilot <[email protected]>
…alidation

When a connection link asks to turn off TLS certificate validation for a
target on this machine, the extension now always shows a warning that names
the target and lets the user turn validation off, keep it on, or cancel. This
prompt is shown even when URL handling confirmations are disabled. When the
request is ignored because the target is not on this machine, the connection
confirmation says so.

Co-authored-by: Copilot <[email protected]>
A connection link that would add a new connection now always shows a
confirmation that names the target (user, hosts, database, and collection),
even when URL handling confirmations are disabled. The setting still skips
the follow-up prompts and links to connections that are already saved, and
the add-connection prompt no longer suggests that it can be turned off. The
setting description and the deep-link user manual describe the new behavior.

Co-authored-by: Copilot <[email protected]>
The job that can mint npm publish credentials no longer installs
dependencies, builds, restores the npm cache, or runs package scripts. The
verify job, which has no OIDC permission, builds and packs the selected
packages and records their SHA-256 hashes. The publish job downloads the
tarballs, checks the hashes and package names, and publishes them with
lifecycle scripts disabled. npm itself is installed at a pinned version
with scripts disabled.

Co-authored-by: Copilot <[email protected]>
The release-bound packages are now packed with --ignore-scripts. The pack
step also fails when a release-bound package declares a pack, publish, or
install lifecycle script, so the tarball is exactly the output of the build
step.

Co-authored-by: Copilot <[email protected]>
The release pipeline now checks that the package tarball name is a plain
npm tarball name (no path separators, control characters or special
characters) before writing it to an output variable. The step that copies
the tarball checks it again and uses literal paths.

Co-authored-by: Copilot <[email protected]>
Static checks now fail when any tracked .npmrc file contains an auth token,
basic auth, or password entry. Pipelines inject registry credentials at
build time, so none belong in the repository. The check prints only file
names, so a leaked value is not repeated in the CI log.

Co-authored-by: Copilot <[email protected]>
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ CI passed: standard tier (ready PR)

Commit 71c76a4, workflow run.

Layer Result Ran or skipped because
Static checks ✅ passed every push
Unit tests ✅ passed every push
npm packages: verify tarballs ✅ passed packages/**, package-lock.json or the CI workflow changed
VSIX: inspect contents ✅ passed ready PR
VSIX: self-test of the checks ✅ passed build/verification/**, build/vite/**, the Vite configs, package-lock.json or the CI workflow changed
VSIX: activate in VS Code ✅ passed ready PR
VSIX: self-test of the activation check ✅ passed build/verification/**, build/vite/**, the Vite configs, package-lock.json or the CI workflow changed
Webview host in unbundled extensions ✅ passed packages/vscode-ext-webview/**, package-lock.json or the CI workflow changed
E2E ⏭️ not available yet arrives with the E2E iteration (full tier)

Full run: add the ci:full-requested label to run every layer once on the current commit.
No full run yet.

Code quality

Check Status How to fix
Localization (l10n) ✅ Passed Nothing to fix
ESLint ✅ Passed Nothing to fix
Prettier formatting ✅ Passed Nothing to fix

Build size

No page, activation, VSIX or other bundle size changed by 5% or 50 KiB or more against main. VSIX: 8.5 MiB.

Artifacts: VSIX | Bundle-reports-39578555334 | L1-manifest-report-39578555334

All graphs (exact bytes)
Graph PR bytes Base bytes Delta bytes Delta %
Collection View page (collectionView) 6,036,286 6,036,286 ✅ 0 0.0%
Document View page (documentView) 4,808,762 4,808,762 ✅ 0 0.0%
Local Quick Start page (localQuickStart) 1,551,408 1,551,408 ✅ 0 0.0%
Atlas Credentials page (atlasCredentials) 1,504,612 1,504,612 ✅ 0 0.0%
Cluster Dashboard page (clusterDashboard) 1,550,863 1,550,863 ✅ 0 0.0%
Activation (mainStartup) 3,448,763 3,447,535 ⬆️ +1,228 +0.0%
Extension host (main) 9,975,455 9,974,227 ⬆️ +1,228 +0.0%
Playground worker (playgroundWorker) 5,384,556 5,384,529 ⬆️ +27 +0.0%
VSIX (vsix) 8,941,525 8,940,785 ⬆️ +740 +0.0%
playgroundTsPlugin 6,175 6,175 ✅ 0 0.0%
viewsEntry 1,456,593 1,456,593 ✅ 0 0.0%
viewsAssets 80,340 80,340 ✅ 0 0.0%
editorWorker 259,528 259,528 ✅ 0 0.0%
jsonWorker 389,389 389,389 ✅ 0 0.0%

Packaged bytes. Shared chunks count in every graph that loads them, so rows do not add up.

Updated in place on every run.

Record the validated credential guard finding, independent review results, and outstanding draft and cross-vendor gates.

Co-authored-by: Copilot <[email protected]>
R1 (npm credential guard) is re-rated from Medium to Low, with a probe
matrix and a recommended one-line replacement. The ignored TLS consent for
anonymous loopback link connections is promoted to finding R2 (Low).

Co-authored-by: Copilot <[email protected]>
The guard matched only unquoted credential keys followed by '=', so a valid
quoted key such as "//registry.npmjs.org/:_authToken"=... or an indented
unscoped key passed. It also failed on commented-out lines.

The check now fails on any non-comment line naming _authToken, _auth or
_password, whatever its quoting or spacing, and ignores # and ; comments.
The error no longer assumes a real token: a ${VAR} reference is rejected
too, and the message says to revoke only if a credential was committed.

Verified with a 12-case probe matrix (root and nested tracked files) run
from the extracted step script: every credential key form fails, comments
and harmless settings pass, the repository's own .npmrc passes, and the
output contains file names only.

Addresses PR #1040 review finding R1.

Co-authored-by: Copilot <[email protected]>
…ections

A connection link to 127.0.0.1 or ::1 asks the user whether to turn off TLS
certificate validation, but such hosts are not classified as emulators, and
NoAuthHandler applied the stored exception only to emulators. The user's
answer was saved and then ignored, so the connection still failed on a
self-signed certificate.

NoAuthHandler now applies the exception exactly as NativeAuthHandler does:
for any local or private host, whatever its emulator classification, and
never for a public host. The 4-second server selection timeout follows the
same rule.

Tests cover the client options for both loopback forms, with and without the
flag, a public host with the flag, and the full path from link consent to the
anonymous handler's options.

Addresses PR #1040 review finding R2.

Co-authored-by: Copilot <[email protected]>
Both findings were fixed at the author's request: R1 in 93f8a8a and R2 in
e053384, with release notes in 2111d47. The review now links each fix and
records its verification and the remaining gates.

Co-authored-by: Copilot <[email protected]>
@tnaum-ms
Tomasz Naumowicz (tnaum-ms) merged commit 447e81c into main Oct 21, 2026
20 of 23 checks passed
@tnaum-ms
Tomasz Naumowicz (tnaum-ms) deleted the dev/tnaum/october-patch branch October 21, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants