Skip to content

agentHost: avoid subprocesses for Windows endpoint ACLs - #341178

Draft
Dmitriy Vasyura (dmitrivMS) wants to merge 1 commit into
mainfrom
agents/replace-whoami-with-non-spawning-alternative
Draft

Dmitriy Vasyura (dmitrivMS) wants to merge 1 commit into
mainfrom
agents/replace-whoami-with-non-spawning-alternative

Conversation

@dmitrivMS

Copy link
Copy Markdown
Collaborator

Fixes #332710.

Summary

Replace the local agent host's Windows whoami.exe and icacls.exe calls with the asynchronous native setOwnerOnlyAcl API. This avoids startup subprocesses that can trigger security alerts while preserving protected, inheritable full-control grants for the current process user, SYSTEM and Administrators.

The shared owner-only directory helper also covers the Dev Container certificate cache. Add a regression test that observes child-process creation and asserts metadata publication spawns none, plus documentation and the Node diagnostics-channel import allowance.

Dependency / merge blocker

Depends on microsoft/vscode-windows-process-tree#104. This draft was validated with that package built and linked locally. Do not merge until the native APIs are published and this PR updates the package dependency and lockfile. Neither a machine-local dependency path nor an unpublished version is committed. Without the companion package, a clean checkout does not yet have the new API.

Validation

Windows x64, locally linked native package:

  • npm run transpile-client — passed.
  • .\scripts\test.bat --run src\vs\platform\agentHost\test\node\localAgentHostMetadata.test.ts --run src\vs\platform\agentHost\test\node\devContainerAgentHostService.test.ts --grep 'Local Agent Host Endpoint Metadata|writes certificates to an owner-only cache' — passed, 11 Electron tests, including zero child processes during metadata publication and concurrent certificate-cache writes.
  • npm run eslint -- src\vs\platform\agentHost\node\localAgentHostMetadata.ts src\vs\platform\agentHost\test\node\localAgentHostMetadata.test.ts — passed.
  • git diff --check — passed.

Companion package: native build, TypeScript compilation, all 39 tests and lint passed. ACL tests validate exact permissions, ownership preservation, inheritance, old-grant replacement, Unicode paths, concurrent calls and errors.

Full VS Code typecheck and full application build were not run. This draft retains the tested branch base; it has not been rebased onto the latest main.

Use native owner-only ACL setup to avoid whoami.exe and icacls.exe at startup. Requires the companion windows-process-tree API release and dependency update before merging.

Fixes #332710

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

The native dependency remains unpublished/unpinned, and the regression test misses synchronous subprocess creation.

2 open findings
What changed in this PR

Replaces Windows ACL subprocesses with a native asynchronous API for Agent Host metadata.

Changes:

  • Applies owner-only ACLs through setOwnerOnlyAcl.
  • Adds subprocess regression coverage.
  • Documents native ACL behavior and permits diagnostics-channel imports.
File Description
localAgentHostMetadata.ts Uses the native ACL API.
localAgentHostMetadata.test.ts Tests subprocess-free publication.
LOCAL_ENDPOINT.md Documents Windows ACL handling.
eslint.config.js Allows diagnostics_channel imports.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

return new Promise((resolve, reject) => {
execFile(command, [...args], { encoding: 'utf8', windowsHide: true }, (error, stdout) => error ? reject(error) : resolve(String(stdout)));
});
const { setOwnerOnlyAcl } = await import('@vscode/windows-process-tree');
if (process.platform === 'win32') {
test('publishes metadata without spawning processes', async () => {
const childProcesses: ChildProcess[] = [];
const childProcessChannel = channel('child_process');

This branch has not been deployed

No deployments
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.

VSCode spawning whoami.exe triggers security alerts

2 participants