Skip to content

Windows Named Pipe has no ACL and is squattable #1498

Closed

Description

@malibio

Overview

On Windows the daemon creates its Named Pipe with the default DACL and first_pipe_instance(false). The "owning user only" guarantee that the Unix socket provides (mode 0o600) is therefore absent on Windows: the pipe is reachable by other local principals, and a malicious process can pre-create and squat it.

Problem Statement

Every gRPC method is reachable by any local user through the default-DACL pipe, and first_pipe_instance(false) permits pipe-squatting (credential/prompt capture, response tampering). The trust model (OS socket/pipe permission is the entire authorization boundary) does not hold on Windows.

Proposed Solution

Build a SECURITY_ATTRIBUTES/DACL restricting the pipe to the current user, and set first_pipe_instance(true) (fail loudly if already owned). Until then, Windows explicitly does not meet the trust model. Governed by ADR-052 (local trust boundary).

Acceptance Criteria

  • Named Pipe is created with a DACL restricting access to the current user
  • first_pipe_instance(true) set; startup fails if the pipe is already owned
  • Behavior matches the Unix 0o600 guarantee
  • Code passes bun run quality:fix; tests pass

Technical Specifications

Reference Files

  • packages/daemon/src/main.rs (~315, ServerOptions::new().first_pipe_instance(false).create(...); contrast Unix 0o600 at ~157/207)
  • Decision: ADR-052

Related Issues

  • (none)

Activity

  1. self-assigned this
    on Jul 7, 2026
  2. mstomar125 commented on Jul 7, 2026

    @mstomar125
    Contributor

    Not picked up today — Windows-only, unverifiable on our toolchain.

    This is security-critical Windows-only unsafe Win32 FFI (token→SID, SDDL, SECURITY_ATTRIBUTES lifetimes, first-instance special-case, a Send-across-await subtlety). The entire #[cfg(windows)] block compiles out on our macOS dev box, and PR CI can't catch it either — release.yml is the only workflow touching windows-latest and it triggers solely on release/workflow_dispatch, never on PRs. Merging it here would ship a security change to Windows entirely unverified. Needs a Windows box (or a manual release run) to build/run/test before it can be merged safely.

  3. malibio commented on Jul 23, 2026

    @malibio
    CollaboratorAuthor

    Doc reference (July 2026): the target posture and acceptance criteria for this are now in nodespace-docs/architecture/security-posture.md threat T7 and the v1 hardening bar — the OS socket/pipe permission must hold identically on every platform: a Windows named-pipe DACL granting the owner SID only, with the first instance claiming the name (first_pipe_instance(true)). Governed by ADR-052 (local trust boundary), already cited above.

  4. mstomar125 commented on Aug 7, 2026

    @mstomar125
    Contributor

    Board → Blocked (needs a Windows build environment). This is #[cfg(windows)] code; the current remote is darwin, and the pre-push gate builds the macOS nodespaced and never compiles the Windows cfg block — so it can't be implemented or verified here. Pick up on a Windows toolchain. (Note: #1498 unblocks nodespace-sync#246.)

  5. self-assigned this
    on Sep 14, 2026
  6. mstomar125 commented on Sep 14, 2026

    @mstomar125
    Contributor

    Starting implementation. Building a SECURITY_ATTRIBUTES/DACL restricting the named pipe to the current user's SID, and flipping first_pipe_instance(true) so pipe creation fails loudly if the name is already squatted. Will verify on a real Windows 11 box via a standalone minimal cargo binary (same approach as #1452/PR#2610) since the full daemon crate can't build there (no libclang). Working in worktree issue-1498-windows-pipe-acl.

  7. added a commit that references this issue on Sep 14, 2026
    ef200d2
  8. mstomar125 commented on Sep 14, 2026

    @mstomar125
    Contributor

    Fixed in PR #2612: #2612

    Implementation

    • owner_only_security_attributes() builds a SECURITY_ATTRIBUTES via an SDDL descriptor O:{sid}D:P(A;;GA;;;{sid}) -- owner set to the current user's real SID, DACL grants that same SID (and only that SID) access. No ACE for Everyone/Authenticated Users/any other principal, so they're implicitly denied -- the Windows equivalent of bind_uds_owner_only's 0o600 on Unix.
    • create_owner_only_pipe(name, first_instance) wraps ServerOptions::create_with_security_attributes_raw with that DACL. The pipe name is now claimed once via first_pipe_instance(true) before the accept loop starts, so serve_grpc/serve_headless fail loudly at startup if the name is already owned/squatted, rather than silently serving on a name someone else pre-created.
    • Both Windows server loops (serve_headless, serve_grpc) share this helper; every acceptance-criterion box in the issue is checked.

    Real Windows verification (hardware, not simulated)

    The full nodespaced binary can't build on the available Windows box (no libclang for nlp-engine's bindgen), so -- same approach as #1452/PR #2610 -- I extracted the exact code into a standalone cargo scratch project (tokio + windows-sys only) and validated it live over SSH, including a run of the verbatim production code (not retyped) to rule out transcription drift.

    DACL genuinely attached to the live pipe (read back via GetSecurityInfo, the same Win32 API icacls/Get-Acl use):

    live handle security descriptor (SDDL): O:S-1-5-21-...-1001D:P(A;;FA;;;S-1-5-21-...-1001)
    owner is current user: true; has ALLOW ACE for current user SID only: true; total ACE count in DACL: 1 (expected 1); no Everyone/Authenticated-Users/other-principal ACE: true
    

    (FA = FILE_ALL_ACCESS, the resolved form of the GENERIC_ALL we requested for a pipe/file object -- expected.)

    first_pipe_instance(true) genuinely rejects a pre-squatted name (the exact attack from this issue):

    squatter pre-created \\.\pipe\nodespace-pipe-acl-test-squat-3176: OK (simulating a malicious pre-existing pipe)
    legitimate first_pipe_instance(true) create FAILED as expected: Access is denied. (os error 5)
    

    Normal serial-reconnect still works once legitimately claimed (first_pipe_instance(false)): confirmed OK.

    Verbatim production code (copied straight from the final packages/daemon/src/main.rs, not hand-retyped) compiles clean and all 6 unit tests pass on the real machine, including the live-handle DACL readback test.

    Honest gap: this Windows box has only one real usable local account, so true cross-user connect denial (actually opening the pipe as a different Windows identity and observing ERROR_ACCESS_DENIED) was not verified end to end -- creating a second account there was out of scope (same "needs human sign-off to modify the physical machine" reasoning that blocked installing LLVM in the earlier session). What was verified directly and programmatically is that the security descriptor attached to the live kernel object is exactly the restrictive one intended, which is what the OS access-check evaluates against any other principal's connection attempt.

    Full evidence and commands are in the PR description. bun run test:all and bun run quality:fix both clean; pre-push gate (including cargo build --bin nodespaced and test:e2e) passed in full.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions