Skip to content

chore: compare native Windows ACL prototypes - #1109

Closed
EhabY wants to merge 8 commits into
mainfrom
chore/compare-windows-acl-prototypes
Closed

EhabY wants to merge 8 commits into
mainfrom
chore/compare-windows-acl-prototypes

Conversation

@EhabY

@EhabY EhabY commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Compare a Rust helper and Node-API addon for #1108 across manual ACL, low-level SDDL, and Microsoft typed-binding cores. Both alternatives retain one universal VSIX with Windows x64/ARM64. Neither is connected to production SSH generation; prototypes remain excluded from the production VSIX.

Static CRT follow-up — completed

At 1134c39, experiment run 34846540409 passed all five jobs: native x64, native ARM64, Linux/macOS bypass, and universal packaging. Seven configurations / fourteen universal packages were tested. Standard CI 34846540275 passed after retrying a macOS runner setup failure before repository checkout; no source fix was needed.

Typed bindings, opt s Dynamic CRT Static CRT Increase
Universal helper 160.9 KiB 255.4 KiB 94.5 KiB
Universal addon 231.7 KiB 321.2 KiB 89.5 KiB

Exact package bytes: helper 164748 → 261537; addon 237311 → 328950. Both packages include x64 and ARM64. Static helper native bytes: x64 259584; ARM64 254976.

  • Static typed payloads have no direct VC/UCRT DLL imports on either architecture. OS imports remain. Import checks fail the experiment if these runtime imports reappear.
  • Both interfaces passed OpenSSH rejection/repair/rewrite, idempotence, and final-junction rejection under Node 22 and Electron 37/42 on both architectures.
  • Independent typed-core exact-ACE, protection, inheritance, owner allow-list, and path tests passed on both architectures, with dynamic and static CRT.
  • Consolidated evidence: report.json in run 34846540409 artifact acl-universal-prototypes.

The user approved larger packages to reduce deployment dependencies. The measured tradeoff supports the typed static-CRT helper as the next deployment-validation candidate, not an approved production integration. No clean Windows environment without preinstalled runtimes was exercised. Direct imports do not prove absence of transitive/dynamically loaded dependencies. Signing, application control, DLL integrity/search, and production file handling remain unvalidated.

Earlier six-cell results (29de7d9)

At 29de7d9, prototype run 34840561914 and standard CI 34840562010 passed. All six configurations passed both native architectures under Node 22 and Electron 37/42; Linux/macOS bypass and all twelve real universal package inspections passed.

  • Typed-binding core: 352 production lines, versus 427 original and 438 low-level SDDL. Unsafe tokens: 20 versus 17 and 19; fewer lines are not a safety proof.
  • At equal opt s, typed bindings add 380 helper / 693 addon package bytes. Universal sizes: 160.9 KiB helper / 231.7 KiB addon.
  • SDDL alone did not reduce code or size at equal opt 3. Static CRT removed explicit CRT imports on both architectures but increased package sizes.
  • No suitable complete safe ACL wrapper was found in the dependency investigation. Typed bindings reduce some plumbing, not our policy/ownership responsibilities.

Draft comparison only. Recommendation for discussion: narrow to the typed-binding helper and test static CRT plus semantic-test parity. No production choice is approved. Timing distributions, clean-machine deployment, signing/application control, and typed-binding + static CRT remain unvalidated.

Investigation, experiment plan, measurements, and limitations

Issue #1108 follows #1061 moving generated hosts into included files under %APPDATA%\coder.coder-remote\ssh. POSIX modes do not repair Windows DACLs, and included files can inherit writable ACEs rejected by Windows OpenSSH.

The shared core follows VS Code's Rust ACL precedent: protected DACL, full control for the process user's SID, SYSTEM, and Administrators, with inheritance only on directories. It validates ownership and rejects final reparse points through an opened handle. Neither interface needs PowerShell or icacls; icacls only arranges the deliberately bad test fixture.

Precedents investigated: VS Code cli/src/tunnels/agent_host_registry_acl_windows.rs, Chromium base/win/security_descriptor.cc, Tailscale atomicfile/atomicfile_windows.go, and Windows OpenSSH contrib/win32/win32compat/w32-sshfileperm.c. Preserving the destination ACL during replacement does not repair an existing unsafe ACL.

Approved experiment sequence:

  1. Preserve handle-based policy and compare both interfaces on native x64/ARM64.
  2. Compare original/manual ACL with std handle ownership + SDDL at equal settings.
  3. Investigate maintained wrappers and measure Microsoft windows typed bindings.
  4. Build optimization levels 3/s/z and an isolated static-CRT cell.
  5. Exercise OpenSSH rejection/repair/rewrite, idempotence, final-junction rejection, Node/Electron compatibility, and non-Windows bypass.
  6. Inspect PE imports and package each alternative with both architectures.
  7. Present evidence and wait for user selection; do not integrate production behavior.

Universal package size

Each experimental package contains x64 and ARM64 assets for one interface.
These are compressed prototype sizes, not production extension sizes.

Configuration Helper (KiB) Addon (KiB)
Original manual ACL, opt 3 190.7 246.6
Low-level SDDL, opt 3 194.2 250.1
Low-level SDDL, opt s 160.5 231.1
Microsoft windows + SDDL, opt s 160.9 231.7
Low-level SDDL, opt z 159.5 223.0
Low-level SDDL, opt s, static CRT 254.7 320.4

All cells use LTO, one codegen unit, stripping, and unwind panic strategy. The
original source at 22a751efc2fc859641e387921e115d01829db1ac was rebuilt on the
same runners. At equal opt s, typed bindings add only 380 helper package bytes
and 693 addon package bytes. Size reductions versus original include compiler
optimization changes; they are not solely a dependency benefit. No latency
distributions were measured.

Handwritten Rust and dependency maintenance

Counts include production-core comments/blanks and exclude the line containing
its first #[cfg(test)] and everything after it. Unsafe-token counts are rough
indicators, not safety scores.

Core Physical lines Nonblank lines unsafe tokens
Original manual ACL 427 381 17
Low-level SDDL 438 395 19
Microsoft windows + SDDL 352 317 20

The typed implementation has 75 fewer lines than original (~18%), but more
unsafe sites. Some reduction comes from implementation choices such as
IsWellKnownSid, not the dependency alone. SDDL with windows-sys did not
reduce total code or package size at equal opt 3; it replaces manual ACL layout
arithmetic with parser/conversion lifetime handling.

windows = 0.62.2 supplies typed API signatures and some error plumbing, not a
complete safe ACL abstraction. We still own descriptor allocation lifetimes,
aligned token/SID storage, handle sequencing, and owner/reparse policy. It adds
11 registry packages to this experimental lockfile, not separately shipped DLLs.
A selected implementation would retain only one core.

The published-source dependency investigation found no complete maintained safe
wrapper matching this boundary. winsafe 0.0.29 lacks the central security-info
and SDDL APIs; windows-acl and windows-permissions use older winapi bindings
and do not cover the whole policy; qiongli-windows-security has a specialized
owner-only policy rather than the required existing-handle protected-DACL write.
SID-only helpers and descriptor parsers cannot replace the central operation.
The Microsoft typed binding was therefore implemented and measured rather than
rejected on dependency count alone.

Runtime linkage

All dynamic cells import VCRUNTIME140.dll and UCRT API-set DLLs on both
architectures. Static CRT removes these explicit imports for both interfaces,
with approximately 94 KiB helper / 89 KiB addon universal-package growth versus
low-level opt s. Windows OS DLL dependencies remain.

The typed-binding plus static-CRT combination was not tested. Neither hosted
runner success nor import inspection proves clean-machine portability. Signing,
application control, DLL search/integrity, and addon CRT ownership boundaries
remain deployment review work. No production linkage choice has been made.

The consolidated measurements are in report.json of the
acl-universal-prototypes artifact from run 34840561914. The workflow rebuilds
all cells and records source revisions, compiler versions, PE imports, native
bytes, runtime outcomes, and package bytes.

The helper has separate process memory/crash containment, not a sandbox. The addon executes native code inside the extension host. Both retain the user's authority. Prior keyring binary issues affected macOS; bypass tests do not prove risk-free distribution.

Remaining gaps: typed-core independent exact-ACE/directory-inheritance test parity; latency distributions; clean Windows without preinstalled runtime; signing/application control; DLL search/integrity and addon CRT ownership review. Secure creation, parent-chain/hard-link hardening, migration, and production atomic writing are excluded. Prototype activation is inert.

CI harness corrections included semantic rather than textual SDDL assertions, mandatory real architecture payload checks, and an explicit empty-path fixture independent of the runner's Electron environment.

The initial harness commit b698931 was unexpectedly pushed by a delegated agent before authorization and was disclosed. It remains intact; the user subsequently authorized this draft PR and Windows runner tests. No history was rewritten.

Generated by Coder Agents on behalf of @EhabY.

@EhabY

EhabY commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator Author

Final validation at 22a751e: all 17 checks passed, including native Windows x64/ARM64, Linux/macOS bypass, universal VSIX assembly/archive inspection/upload, and standard repository CI. Prototype workflow run: 34836599732. This supersedes the pending packaging status in the initial results.

Both native interfaces remain viable in the tested environments. Outstanding deployment concern: both inspected x64 binaries import VCRUNTIME140.dll; clean-machine portability, signing/application-control behavior, and ARM64 DLL dependencies still need validation before production adoption. No implementation choice or production SSH change has been made.

Generated by Coder Agents on behalf of @EhabY.

@EhabY

EhabY commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by draft #1110, implementing the selected typed Windows static-CRT helper and universal production packaging. Comparison evidence remains in this PR and its retained branch; no experimental history was merged. Closing as requested after opening the successor. Generated by Coder Agents on behalf of @EhabY.

@EhabY EhabY closed this Sep 14, 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.

1 participant