Skip to content

Windows: ancestor walk refuses app container / capability SIDs, so 0.10.0 cannot start inside a containerized host #1533

Description

@Kiborgik

Summary

On Windows, win_private_directory_tree_secure walks every ancestor of the runtime directory and refuses any that grants mutation rights to an identity it does not trust. App container and capability SIDs (S-1-15-2-*, S-1-15-3-*) are not on the trusted list, so when the process runs inside a containerized host application the walk refuses the container's own AppData and no endpoint can be created.

The result is that 0.10.0 cannot start at all from inside such a host, with no remedy available to the user: the offending ACE is on a directory the container owns, not on anything the user can edit.

Evidence

Instrumented build from main, printing ipc_validation_detail_buffer at the failing gate in cbm_daemon_ipc_endpoint_new:

DIAG gate=final dir=1 wide=1 names=1 pipe=1 mutex=1 tree_secure=0 err=0
     runtime_dir=C:\Users\petro\AppData\Local/cbm-daemon-c888acc3ae367a1e
DIAG detail=C:\Users\petro\AppData: DACL entry 0 grants mutation rights 0x000d0152
     to untrusted identity (other S-1-15-3-3557520199-3666692283-3112367039-3524159787-2791857073-3163583606-3692855932)

Every other condition in that gate passes. The refusal is on an ancestor (C:\Users\petro\AppData), not on the runtime directory itself.

Without instrumentation the only surfaced message is:

codebase-memory-mcp: secure CLI coordination could not be created (endpoint)

CBM_LOG_LEVEL=debug adds nothing, because the failure happens before the log layer is initialized.

Environment

  • Windows 11 26200, non-elevated standard token
  • codebase-memory-mcp 0.10.0 (also reproduced with a local build of main)
  • Host application runs the MCP server inside an app container, so its %LOCALAPPDATA% resolves to a container-owned object whose DACL carries the capability SID above
  • The same binary run from an ordinary terminal on the same machine works: that AppData has no such ACE

Version boundary

0.9.0 works from inside the same host. The ancestor walk is part of the strict permission gate introduced in 0.9.1-rc (#1416), so the regression window is 0.9.0 → 0.9.1-rc.

Why this differs from #1416

#1416 covers trees carrying Authenticated Users:(M) from a drive root, where both documented workarounds apply: move the install under the user profile, or strip the inherited grant. Neither works here.

  • The install is already under the user profile. The refused path is %LOCALAPPDATA% itself.
  • The runtime parent is not configurable. cbm_daemon_ipc_endpoint_new accepts a runtime_parent, but every production call site passes NULL (main.c:1486, 2399, 2559), and the only override is compile-gated behind CBM_ENABLE_TEST_SEAMS.
  • The ACE belongs to the container, not to the user, so there is nothing for the user to strip.

Proposal

Treat app container SIDs (S-1-15-2-*) and capability SIDs (S-1-15-3-*) as trusted in the ancestor walk only, leaving the final runtime directory under the existing exact-owner rule.

The argument for it: neither is a login-capable account. A grant to a capability SID is a statement about which packaged identity the OS will hand the token to, not a second user who can tamper with the tree. That is the threat the gate exists to stop, and it is not what these ACEs represent.

Two things I could not settle myself, which is why this is an issue rather than a PR:

  1. Whether an arbitrary local process can assume a chosen capability SID. If it can, the exemption is not safe and this should stay refused, in which case the request becomes "make the runtime parent configurable" instead.
  2. Whether the exemption should be ancestors-only. That is sufficient for this failure, and it is the narrower change.

Happy to write the patch either way once you have ruled on the direction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingeditor/integrationEditor compatibility and CLI integrationpriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.securitySecurity vulnerabilities, hardeningux/behaviorDisplay bugs, docs, adoption UXwindowsWindows-specific issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions