Conversation
EhabY
force-pushed
the
fix/windows-ssh-config-acls
branch
2 times, most recently
from
September 14, 2026 16:50
b895e47 to
3635e17
Compare
EhabY
marked this pull request as ready for review
September 14, 2026 16:55
EhabY
force-pushed
the
fix/windows-ssh-config-acls
branch
6 times, most recently
from
September 14, 2026 17:54
72e1d72 to
91612cb
Compare
EhabY
marked this pull request as draft
September 14, 2026 18:24
EhabY
force-pushed
the
fix/windows-ssh-config-acls
branch
4 times, most recently
from
September 16, 2026 10:46
6ebe186 to
ad4b2dc
Compare
EhabY
marked this pull request as ready for review
September 16, 2026 11:01
EhabY
force-pushed
the
fix/windows-ssh-config-acls
branch
4 times, most recently
from
September 16, 2026 13:22
4a896a4 to
16adc12
Compare
untra
reviewed
Sep 16, 2026
untra
reviewed
Sep 16, 2026
EhabY
force-pushed
the
fix/windows-ssh-config-acls
branch
from
September 16, 2026 16:00
16adc12 to
dddc9e9
Compare
Member
|
is there any reason you didn't use the Scripts ran by the Windows Script Host are super sketchy patterns that AVs love to flag for no reason. Spawning PowerShell is similar but less so. |
EhabY
force-pushed
the
fix/windows-ssh-config-acls
branch
2 times, most recently
from
September 17, 2026 16:16
8cf3d1c to
dd84e8c
Compare
EhabY
force-pushed
the
fix/windows-ssh-config-acls
branch
from
September 17, 2026 16:27
dd84e8c to
98bbb22
Compare
Collaborator
Author
|
Simplified this a lot more by removing the pre/post ACL checks that ran to make sure everything was applied correctly. We now apply this on all runs on Windows (which takes the same amount of time as the check anyway). The only windows specific logic is in |
Repair included fragments with built-in Windows tools and retain best-effort SSH setup. Inject permission repair as a collaborator so the config writer stays platform agnostic, skip files whose permissions already verify, and drive the real Windows tools from the native tests. Fixes #1108 Generated by Coder Agents.
Keep vitest.config.mts declarative, and record why the icacls backup is read as UTF-16LE.
Replace the WSH setter and runtime ACL parsing with checked icacls commands. Repair existing deployment fragments on upgrade, retain path and link guards, and consolidate ACL helpers and tests.
EhabY
force-pushed
the
fix/windows-ssh-config-acls
branch
3 times, most recently
from
September 18, 2026 23:32
a5484af to
b7a0f0c
Compare
Installing dependencies took eight minutes there against one on x64. Neither bufferutil nor utf-8-validate ships a win32-arm64 prebuild, so pnpm compiled both with node-gyp on every cold install. Both fall back to JavaScript when no binary is present, so skip their builds. setup-node's pnpm cache restores on an exact lockfile hash, so a dependency bump refetched the whole store on every runner. Hand the store cache to pnpm/action-setup, which keys on the same hash but falls back to the last store for the platform. A cold setup step now takes 2m31s.
EhabY
force-pushed
the
fix/windows-ssh-config-acls
branch
from
September 18, 2026 23:39
b7a0f0c to
07c23ef
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.
Summary
Fixes #1108. Windows files inherit their permissions from the directory they live in, so a config the extension generates under
%APPDATA%\coder.coder-remote\sshcan end up readable by other accounts. OpenSSH rejects such a file withBad owner or permissionsand skips the wholeInclude, so one bad file blocks every Coder host, not just the one it came from.Before each managed write, the extension locks that directory down with built-in commands and lets its files inherit from it. No Windows Script Host, ADSI, native dependency, or elevation:
whoami.exe /user /fo csv /nhicacls.exe <dir> /reseticacls.exe <dir> /inheritance:r /grant:r <trustee>*.conffile so it inherits the directoryicacls.exe <file> /reset*.confmatch, not only the file being written, also repairs other deployments and editors on the first connection after an upgrade. The temporary file is reset before its rename.SshConfigtakes an optionalManagedPermissions. Its absence is the marker for "not Coder-managed", which is why it has no no-op default: a default would make the extension enumerate~/.sshon every save on every platform.createManagedPermissions()returnsundefinedoff Windows, so the whole repair path stays Windows-only.What each file changes
src/remote/windowsAcl.tsWINDOWS_ACL,createManagedPermissions, andsystem32; everything else is private, ordered by first use.src/remote/sshConfig.tsManagedPermissionsinterface, splitssave()intogetFileMode,repairIncludedFiles,writeTemp,repairPermissions, andreplaceWithTemp, and makes the temp write exclusive (wx).src/remote/remote.tscreateManagedPermissions()to the per-deploymentSshConfig.icacls.exeandwhoami.exe, 5 against the real tools and OpenSSH (skipped off Windows), 9 for the managed-permissions path insshConfig, and a global setup that fails the run whenprocess.archdoes not matchEXPECTED_ARCH.windows-11-armunit test job and the two speedups below.CONTRIBUTING.mdfor the approach and its limits,CHANGELOG.mdfor the user-facing fix..gitattributesand.vscodeignorepick up a generated-file marker and a trailing newline, unrelated to the fix. Total: 884 added, 20 removed across 15 files.CI
The new ARM64 job took 11m15s against 3m10s for x64, all of it in dependency install, while the test run itself matched x64 to within four seconds.
pnpm installbufferutilnorutf-8-validateships awin32-arm64prebuild, so pnpm compiled both withnode-gypon every cold install, 4m25s of it. Both ship a JavaScript fallback, and the VSIX carries no.nodefile, soallowBuildsnow denies their build scripts. Platforms with a prebuild are unaffected:node-gyp-buildstill finds the binary at require time, and its install script was already a no-op there.setup-node's pnpm cache restores on an exact lockfile hash, so a dependency bump refetched the whole store on every runner.pnpm/action-setup, already pinned here, caches the store under the same hash but falls back to the last store for the platform, so a bump fetches only what changed.What remains is the runner image. ARM64 has no
D:scratch disk, so the workspace and the pnpm store both sit on the network-backed OS disk: linking 856 packages costs about two minutes there against nine seconds on x64, warm or cold.Simplification pass
The ACL commit reworks the first implementation rather than adding to it:
WindowsAclclass with aWINDOWS_ACLconst holding two functions. The old class tracked the last prepared directory so thatsecure()could refuse a file outside it, butSshConfig.save()is the only caller and already calls them in order. Removing that state removed three tests with it.parseWhoamiUserSidintocurrentUserSidand stopped exportingisFullyQualifiedWindowsPath, which existed only so a test could assert on it. The same decision is reachable throughWINDOWS_ACL.secure().FilePermissionstoManagedPermissions. It prepares a directory, so "File" was wrong, and the name now hints that absence means unmanaged.src/remote/windows/acl.tstosrc/remote/windowsAcl.ts, since the directory held one file.it.eachtables, command assertions became flat transcript strings instead of nested arrays, and the 60-second native test lost a duplicate fixture.CONTRIBUTING.mdsection and rewrote the changelog entry around the error users see.Validation
pnpm test: 2,751 passed, 6 skipped, 187 files. The native Windows tests are among the skips on Linux.pnpm typecheck,pnpm lint, andpnpm format:checkpass.*.confdirectory case against OpenSSH 9.6p1 on Linux: glibc opens a directory successfully, so OpenSSH reads zero lines and ignores it unless it is group-writable or unreadable. The Windows CRT fails the open instead, which aborts the wholeInclude, so the extension reports that entry rather than trying to fix it with an ACL change.Limits
A directory-preparation failure stops the write. A single file-reset failure logs a warning and still attempts the connection, so OpenSSH may reject a fragment the repair missed. The two directory commands are not atomic: a failure after
/resetcan leave the directory with its parent's grants. The path and link checks stop mistakes, not an attacker racing the check.Generated by Coder Agents on behalf of @EhabY.