Skip to content

Never send Entra sign-in tokens to the marketplace - #343689

Merged
Karthik Nadig (karthiknadig) merged 5 commits into
microsoft:mainfrom
mcumming:dev/mcumming/marketplace-scoped-tokens
Nov 10, 2026
Merged

Karthik Nadig (karthiknadig) merged 5 commits into
microsoft:mainfrom
mcumming:dev/mcumming/marketplace-scoped-tokens

Conversation

@mcumming

@mcumming Michael Cummings (MSFT) (mcumming) commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Related to microsoft/vscode#325412.

Summary

Keep the Microsoft sign-in token local to account selection and tenant eligibility. Marketplace authentication uses only a session requested for the advertised marketplace scopes and authorization server, bound to the selected account.

Behavior

  • Missing protected-resource metadata or an unavailable, unsupported, or failed resource-session lookup does not substitute the sign-in access token.
  • Missing or empty marketplace scopes do not substitute identity scopes for silent lookup or interactive resource consent.
  • Open marketplaces remain anonymous when no resource token is available. Service-index 401 responses keep the existing RequiresSignIn status; 403 remains AccessDenied.
  • Successful silent acquisition and interactive consent use the advertised resource scopes. Outgoing requests and shared-process/remote manifest payloads carry only that resource token, or no token.
  • OIDC-only scope lists and internal VSCODE_ options cannot cause resource-token acquisition or consent. Syntax-valid discovery metadata remains intact for the existing cache.
  • The Microsoft provider logs a conditional warning during discovery when syntactically valid metadata has no usable marketplace resource scopes: requests will be rejected if the marketplace requires authentication, and its administrator should configure scopes_supported. Cached reads and coalesced lookups do not repeat the warning. Existing malformed-metadata warnings and retry behavior remain unchanged.

An explicitly advertised api://{client-id}/access_as_user or api://{client-id}/.default scope names the app registration. The canonical HTTPS marketplace URL in PRM resource is not used to invent an Entra {resource}/.default fallback.

This PR does not change marketplace statuses or UI. Configuration-status UX is deferred to separately reviewed follow-up work. The account contract remains limited to the credential; no diagnostic field or manifest-service logging is added.

This change does not add a redirect policy, renewal scheduler, or metadata-cache lifetime.

Validation

Commands were run with the repository-required Node 24.22.1 and pinned pnpm 12.16.0, using corepack.cmd pnpm.

Command Result
corepack.cmd pnpm run typecheck-client Passed.
corepack.cmd pnpm run build-fast --client-only Passed; fresh client output.
.\scripts\test.bat --run src\vs\workbench\services\extensionManagement\test\electron-browser\extensionGalleryAccountService.test.ts --run src\vs\workbench\services\extensionManagement\test\electron-browser\extensionGalleryManifestService.test.ts --timeout 20000 --reporter dot Passed: 227 tests, including the existing cache/403 regressions.
corepack.cmd pnpm run precommit src\vs\workbench\services\extensionManagement\common\extensionGalleryAccount.ts src\vs\workbench\services\extensionManagement\electron-browser\extensionGalleryAccountService.ts src\vs\workbench\services\extensionManagement\electron-browser\extensionGalleryManifestService.ts src\vs\workbench\services\extensionManagement\test\electron-browser\extensionGalleryAccountService.test.ts src\vs\workbench\services\extensionManagement\test\electron-browser\extensionGalleryManifestService.test.ts Passed; all five files changed by the diagnostic cleanup checked.

Regression assertions inspect actual outgoing Authorization headers and complete shared/remote manifest payloads, anonymous open indexes, absent/malformed metadata, missing/empty/identity-only/internal scopes, failed resource lookup, successful resource acquisition, interactive consent, reload recovery, sign-out races, and provider-side conditional warnings. Additional warning regressions cover coalesced lookups, cache reuse, expiry/rediscovery, and avoiding resource acquisition or consent for unusable scopes.

Live Entra-gated and interactive identity-provider flows were not exercised.

Drafted with GitHub Copilot.

Copilot AI balanced review requested due to automatic review settings October 23, 2026 03:49

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.

🟢 Approval recommended

The focused changes remove unsafe token fallbacks with targeted regression coverage and no unresolved findings.

No open issues 🎉

What changed in this PR

This security follow-up keeps Microsoft sign-in tokens local to marketplace eligibility checks and permits only resource-scoped tokens to be sent to the marketplace.

Changes:

  • Removes sign-in-token fallbacks when metadata or resource sessions are unavailable.
  • Skips silent resource-session lookup and interactive resource consent when no resource scopes are advertised.
  • Expands regression coverage for outgoing authorization headers and shared-process/remote manifest arguments across open and gated marketplaces.
File Description
src/​vs/​workbench/​services/​extensionManagement/​test/​electron-browser/​extensionGalleryManifestService.test.ts Verifies anonymous fallback, resource-token use, and cross-process token propagation.
src/​vs/​workbench/​services/​extensionManagement/​electron-browser/​extensionGalleryAccountService.ts Removes credential fallbacks and guards resource authentication against empty scopes.

Review effort: Balanced

@mcumming

Copy link
Copy Markdown
Contributor Author

TylerLeonhardt, could you provide explicit security sign-off on the private Marketplace credential boundary before wider rollout?

The proposed boundary in this PR is intentional delegation: the renderer obtains a marketplace resource-scoped Entra access token and publishes the raw bearer plus service-index URL over the existing manifest IPC channel to the shared process and any connected remote agent (SSH, WSL, tunnels, or Codespaces). A host controlling that remote process can read the credential. The HTTPS/origin check restricts cooperative request attachment; it does not isolate the token from that host.

This PR removes the fallback sign-in credential and identity-scope substitution. No refresh grant is sent to those replicas. Separate focused follow-ups address redirect credential stripping in Node and Electron (#343690), token renewal (#343688), and 403 status handling (#343686). They are open PRs, not protection already landed on main. The existing GitHub exchange feature, #325815, remains in review separately.

Please explicitly review whether the remote delegation and resource/scope/origin restrictions are acceptable. Source-level checks and passing regressions are not a substitute for that approval.

Drafted with GitHub Copilot.

@mcumming

Michael Cummings (MSFT) (mcumming) commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

CI failure investigation

The two underlying failures in Code OSS run https://github.com/microsoft/vscode/actions/runs/39897075541 are unrelated to the two files changed by this PR:

  • Linux (unit) / Browser, job 120229962597: ChatImageReveal / time spent handling the image load does not extend the reveal deadline expected a duration reduction of 100, but observed 79. The other 46,293 tests passed. The test uses a timing-sensitive browser animation deadline and is unchanged by this PR.
  • Windows (run) / Remote, job 120229962812: vscode API - browser / CDP sendMessage and onDidReceiveMessage round-trip expected a target URL of about:blank, but observed an empty URL immediately after opening the tab. The other 329 tests passed. That test and its CDP/browser implementation are unchanged by this PR.

The Linux / Browser and Windows / Remote summary failures simply propagate those two job failures. The marketplace changes are confined to the Electron-browser account provider and its manifest tests; neither failing source file is in the diff. The corresponding other-platform jobs passed. No unrelated product/test changes or empty commits have been made to hide or bypass these failures.

I attempted gh run rerun 39897075541 --repo microsoft/vscode --failed, but GitHub refused it: run 39897075541 cannot be rerun; Must have admin rights to Repository. Could a repository maintainer rerun the failed jobs on this existing head? The PR remains at ea933051db9f4bb72f7ebb0202b4d8e16061a723; a green rerun is still required before these checks can be considered resolved.

Drafted with GitHub Copilot.

Update: resolved after rebasing on current main

The user requested an actual base refresh, not an empty CI-trigger commit. This PR was rebased without conflicts onto main 0f13ecc98a6fe0ccfc9216fa330765bfc942c502; the token-selection patch is unchanged (range-diff identical), and the new head is deb73fae0a139da1057f33f67f4d667b78dba867.

Fresh Code OSS run https://github.com/microsoft/vscode/actions/runs/40379461103 completed successfully. Browser-Unit / Linux, Remote (integration) / Windows, and Compile & Hygiene all passed. The old run above remains historical; no maintainer-only rerun was bypassed. Main includes isolated failed-test reruns and scoped CI selection improvements, but the original chat/CDP assertions themselves were not changed.

There are now no failing checks on this head. The remaining VS Code PR Check is the collaborator-approval gate, not a build failure.

@mcumming
Michael Cummings (MSFT) (mcumming) force-pushed the dev/mcumming/marketplace-scoped-tokens branch from ea93305 to deb73fa Compare October 26, 2026 18:38
@mariaghiondea

Copy link
Copy Markdown

Karthik Nadig (@karthiknadig) this is ready for your review 🙏

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. The sign-in token no longer leaves the provider, and the sign-in scopes are no longer substituted for the marketplace's. One question inline.

The remote-delegation sign-off you asked Tyler for is about behavior that already shipped in #325804. This PR only narrows what is sent, so I don't think it needs to wait on that.


Review assisted by Copilot.

Keep sign-in credentials local when resource metadata or marketplace-scoped sessions are unavailable. Skip resource requests without advertised scopes and cover outgoing HTTP headers and shared/remote manifest IPC payloads.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 501856fc-20e7-4945-be4d-520737498b91
Show an administrator configuration explanation only for gated 401 responses with unusable advertised resource scopes. Preserve metadata fidelity and enforce resource-scope safety at token acquisition and consent, with HTTP, shared/remote payload, UI, and reload-compatible regression coverage.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 501856fc-20e7-4945-be4d-520737498b91
@mcumming
Michael Cummings (MSFT) (mcumming) force-pushed the dev/mcumming/marketplace-scoped-tokens branch from 3d05bc9 to bfae5fb Compare November 2, 2026 19:57
@mariaghiondea

Copy link
Copy Markdown

Karthik Nadig (@karthiknadig) your comments says LG, but it’s not approved. We are also running into build issues if you can provide any insights

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The token change I approved is unchanged and still looks good. Rejecting VSCODE_-prefixed and OIDC-only scopes is a good addition: scopes supplied by the marketplace shouldn't be able to steer the Microsoft provider's client ID or tenant.

The new commit also adds a public ExtensionGalleryManifestStatus.RequiresConfiguration value, with its own welcome message, badge and sign-in precondition (inline). I'd like to keep that out of this PR; I'll approve once that's settled.

On the CI failure: macOS / Electron-Unit failed while downloading Electron's SHASUMS256.txt from GitHub releases (HTTP 500, three times), so it's unrelated to this change. Rerunning the failed jobs should clear it.


Review assisted by Copilot.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. The RequiresConfiguration status point from my earlier comment is non-blocking; fine to address in a follow-up with Sandeep.


Review assisted by Copilot.

Integrate pinned main 64c455b without rewriting reviewed history. Preserve metadata caching, validation and stale-consent protections together with resource-only tokens and the 401-only scope configuration diagnostic. Keep main's 403 denial and synchronized sign-out/consent regressions.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 501856fc-20e7-4945-be4d-520737498b91
auto-merge was automatically disabled November 4, 2026 18:58

Head branch was pushed to by a user without write access

Keep the existing RequiresSignIn status and UI while logging unusable marketplace scope metadata after a gated 401. Preserve resource-only token acquisition, scope guards and HTTP/shared/remote regression coverage. Save the separate status, welcome, badge and sign-in gating changes for owner-reviewed follow-up work.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 501856fc-20e7-4945-be4d-520737498b91

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for moving the status and UI out. The resource-only token boundary, the scope guards, and the conflict resolution with #343686 and #343687 look good; logging the misconfiguration while keeping RequiresSignIn is the right scope for this PR. LGTM.


Review assisted by Copilot.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approval stands; one non-blocking suggestion inline. Happy to re-approve if you change it.


Review assisted by Copilot.

Warn during protected-resource discovery when advertised scopes cannot support marketplace authentication. Return no credential for unusable scopes without extending the shared account contract or the manifest service. Preserve metadata caching, fidelity and resource-only token/consent guards, with warning/cache and outgoing HTTP/IPC regression coverage.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 501856fc-20e7-4945-be4d-520737498b91
auto-merge was automatically disabled November 6, 2026 13:49

Head branch was pushed to by a user without write access

@mariaghiondea

Copy link
Copy Markdown

Karthik Nadig (@karthiknadig) we need your re-approval here and 2 more to merge. Thank you so much for the help with all of these 🙏

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, that addresses my comment. The diagnostic now lives in the provider, the shared account contract and manifest service are unchanged, and the warning is covered once per discovery without credentials or resource consent. LGTM.


Review assisted by Copilot.

@karthiknadig
Karthik Nadig (karthiknadig) merged commit 865fc10 into microsoft:main Nov 10, 2026
54 of 72 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.147.0 milestone Nov 10, 2026
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.

7 participants