Skip to content

fix(windows): accept AppContainer capability grants on runtime ancestors - #1447

Closed
mlandolfi90 wants to merge 2 commits into
DeusData:mainfrom
mlandolfi90:fix/ancestor-capability-aces
Closed

fix(windows): accept AppContainer capability grants on runtime ancestors#1447
mlandolfi90 wants to merge 2 commits into
DeusData:mainfrom
mlandolfi90:fix/ancestor-capability-aces

Conversation

@mlandolfi90

Copy link
Copy Markdown
Contributor

Symptom

On an ordinary Windows 11 developer machine, every CBM process died at startup:

codebase-memory-mcp: secure daemon endpoint could not be created

No CBM process was competing, and the same machine had run a daemon for days on an older build. The cause is environmental and, I suspect, increasingly common: an agent sandbox (Codex) had stamped the user's AppData with capability ACEs.

C:\Users\<user>\AppData  ->  S-1-15-3-3557520199-...  FullControl  (inherited to AppData\Local)

win_private_directory_tree_secure walks every ancestor of the runtime directory and refuses any mutation-granting ACE whose SID is not the exact user, SYSTEM, Administrators, TrustedInstaller, CreatorOwner (inherit-only) or OWNER RIGHTS. A capability SID matches none of them, so cbm_daemon_ipc_endpoint_new returns NULL and the process exits — including plain --version-adjacent paths that construct an endpoint.

Why I think accepting them on ancestors is sound

A capability SID (S-1-15-3-…, SECURITY_APP_PACKAGE_AUTHORITY) grants only to AppContainer processes that the same user's tooling provisioned. It cannot be used by another account, and it does not confer rights on a normal process. This is the same shape of argument the OWNER RIGHTS acceptance in 8b4e0fb already makes: the grant is reachable only by the party the walk is protecting.

The relaxation is deliberately narrow:

  • Ancestors only. win_directory_component_secure passes ancestor_capability_ok = true.
  • The runtime directory itself is unchanged. win_runtime_directory_secure passes false, so it still demands the exact-user owner and a protected DACL, and still re-stamps it.
  • The SID test checks the identifier authority (15) and the capability RID class (3) explicitly, so it cannot widen to other S-1-15-* classes.

Note on the trust model

This does move a trust boundary, so I understand if you would rather discuss it in an issue before reviewing code — happy to convert. I am also open to a narrower shape if you prefer one: gating it behind an opt-in, or restricting acceptance to ancestors that lie inside the user's own profile.

What I would push back on is leaving it as-is: the failure gives the user one sentence with no cause, and the only remedies available to them are removing ACEs their sandbox depends on, or not running CBM.

🤖 Generated with Claude Code

Sandboxing tools stamp the user profile's AppData with capability ACEs
(S-1-15-3-…) holding write rights. The ancestor DACL walk classified
them as untrusted grants, so cbm_daemon_ipc_endpoint_new returned NULL
and every process on such a machine died at startup with 'secure daemon
endpoint could not be created'.

A capability ACE grants only to AppContainer processes provisioned by
the same user's tooling, and the runtime directory itself still demands
the exact-user owner plus a protected DACL. Accept capability SIDs on
ancestor components only; the final directory validation is unchanged.

Observed in the field: AppData carrying two capability ACEs with mask
0x000d0152 (FILE_DELETE_CHILD, DELETE, WRITE_DAC among them) stamped by
an agent-sandbox provisioner.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: mlandolfi90 <mlandolfi90@users.noreply.github.com>
@mlandolfi90
mlandolfi90 requested a review from DeusData as a code owner August 4, 2026 19:09
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Thanks for opening this — it has been seen, and it is queued.

This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence.

Current review status: working through a backlog. 0.9.1-rc.1 is out, so the release freeze that held reviews is over — but it left a large queue of open pull requests behind it, and we are reading through them oldest-first. The background is in discussion #1144.

What that means for this PR, concretely:

  • It will not be closed for inactivity. No stale bot touches pull requests here.
  • It may still sit a while before a human reads it. That is on us, not on you.
  • Older PRs are read first, so a recent one is not being skipped — it is behind a queue.

Things that will genuinely speed it up whenever review does happen:

  • Keep it rebased on main — the tree is moving quickly right now, and a conflicting branch cannot be reviewed as the diff you intended.
  • Get CI green, or say which failures you believe are pre-existing.
  • Keep the change to one claim. Bundled features and refactors get split before they get merged, which costs you a round trip.
  • Every commit needs a sign-off (git commit -s) — CI enforces DCO.

If this fixes a bug, a reproduction we can run is worth more than a description of the symptom.

Thanks for contributing, and sorry in advance for the wait.

The bundle contract pins the ancestor validation call by literal text, so
adding the capability parameter turns it red on every platform (the check
reads source, it does not compile). Update the needle, and use the
opportunity to pin what actually matters about this change: the ancestor
call passes true, the final runtime directory still passes false, and the
capability test exists. A future edit that let a capability ACE satisfy
the published runtime directory now fails this contract.

Signed-off-by: mlandolfi90 <mlandolfi90@users.noreply.github.com>
@mlandolfi90

Copy link
Copy Markdown
Contributor Author

CI update — the platform-wide red was real and mine, and it is worth naming precisely because it is a good guard.

tests/test_windows_bundle_contract.sh pins the ancestor validation call by literal source text:

"win_file_security_secure(security, directory, false, mutation)",

Adding the capability parameter changed that text, so the contract failed on Linux and macOS too — the check reads the source rather than compiling it. That is the guard doing its job: it is exactly the line that decides how much an ancestor is allowed to grant, and it should not move quietly.

I have pushed an update to the needle, and used the occasion to pin the property this PR actually needs to be true rather than just the call shape:

"win_file_security_secure(security, directory, false, mutation, true)",
"win_private_mutation_rights(), false)",
"win_sid_is_app_capability",

The middle one is the important addition: it pins that win_runtime_directory_secure still passes false. If someone later let a capability ACE satisfy the runtime directory the daemon actually publishes into — the thing this relaxation must never reach — that contract now fails.

If you would rather this guard not be touched by a contributor PR at all, say so and I will drop the test commit and let you land the needle change yourself.

The remaining security / codeql-gate red is a timeout with the analysis still queued (BLOCKED: CodeQL timeout), not an alert.

🤖 Generated with Claude Code

timothybrush pushed a commit to timothybrush/codebase-memory-mcp that referenced this pull request Aug 14, 2026
…me dir strict

Six independent machines in DeusData#1533 and DeusData#1574 cannot run cbm at all, and none of
them is exotic: a domain-joined UAC-filtered admin, a secondary volume, orphaned
ACEs from an uninstalled application, and an AppContainer package SID belonging
to a shipping desktop application.

The ancestor walk was identity-blind to all of it. win_directory_component_secure
demanded that no ancestor DACL entry grant any private-mutation bit to any SID
outside the trusted set, so a single ACE anywhere up %LOCALAPPDATA% refused the
endpoint before logging started. Every mode failed, config list included, so the
product could not even be reconfigured out of it, and CBM_CACHE_DIR does not help
because the runtime directory is %LOCALAPPDATA%\cbm-daemon-<hash>, whose ancestor
chain relocating the cache never touches.

Ancestor components now also tolerate AppContainer identities: package SIDs
(S-1-15-2-*) and capability SIDs (S-1-15-3-*), under identifier authority 15.

The boundary is ancestor-only. The private runtime directory is validated with
ancestor=false and keeps demanding the exact current user with a protected DACL;
the flag is threaded explicitly through win_file_security_secure and
win_file_acl_secure rather than inferred, so the strict path cannot acquire the
tolerance by accident.

Why these identities are admissible on an ancestor: a process cannot choose which
AppContainer it runs in. The identity is stamped by the OS at process creation
from the package it was launched from, so such an ACE cannot be exercised by
arbitrary local code the way a live local group can. What it does permit is the
packaged application itself — that is the residual risk this accepts, and it is
the same trust already extended to whoever installed that package.

BOTH forms are covered deliberately. The most common real ACE of this shape is
S-1-15-2-*, a package SID; on reported machines it resolves through the registry
AppContainer mappings to Anthropic Claude Desktop, which many of our users run and
cannot be asked to uninstall. Covering only capability SIDs leaves exactly that
case failing.

This narrows a deliberate policy: the strict gate was chosen on purpose and a
middle ground was previously declined. It is reopened here by explicit maintainer
decision, and narrowed as far as the evidence allows rather than relaxed wholesale
— a live local group, Authenticated Users on a secondary volume, and orphaned
unresolvable SIDs all still refuse. Those need CBM_RUNTIME_DIR or a separate
change; orphan tolerance in particular needs LookupAccountSid bound first and has
an offline-domain-controller caveat, so it is not bundled in here.

Approach and the ancestor-only boundary follow @mlandolfi90's PR DeusData#1447, extended
from capability SIDs to package SIDs.

Co-Authored-By: mlandolfi90 <mlandolfi90@users.noreply.github.com>

Contract-pinned in tests/test_windows_bundle_contract.sh and revert-checked in
both directions: reducing it to capability-only fails, and passing ancestor=true
for the runtime directory fails.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
@DeusData

Copy link
Copy Markdown
Owner

Thank you for this — and I owe you an apology, because the way this played out is not how it should have gone.

Your approach shipped. It is on main as 9a53074 (PR #1623), and the commit says so and names you as co-author:

Approach and the ancestor-only boundary follow @mlandolfi90's PR #1447, extended from capability SIDs to package SIDs.

The one thing we changed is the SID class. You tested S-1-15-3-* (capability SIDs); on the machines in #1533 and #1574 the blocking ACE turned out to be S-1-15-2-* — a package SID, resolving through HKCR\...\AppContainer\Mappings to a shipping desktop application that no user could reasonably uninstall. Covering capability SIDs alone would have left the headline case still failing, so the merged change tolerates both, under identifier authority 15.

Your ancestor-only boundary is the part that made it safe to do at all, and it is preserved exactly: the private runtime directory is still validated with ancestor=false and still demands the exact current user with a protected DACL. The flag is threaded explicitly through win_file_security_secure and win_file_acl_secure rather than inferred, so the strict path cannot pick up the tolerance by accident.

It ships in v0.10.5, going out today.

What I'm sorry about: you opened four PRs on 2026-08-04 (#1444, #1445, #1446, #1447), three of which turned out to be fixed independently, and nobody told you — including on this one, where your work went into the product. That is a bad experience for someone who showed up with a correct diagnosis and a working patch, and the silence was ours, not a judgement on the work. I'm going through the other three now.

@DeusData

Copy link
Copy Markdown
Owner

Closing as shipped: your approach is on main in 9a53074 (#1623) with you as co-author, extended from capability SIDs to package SIDs to cover the field case. It ships in v0.10.5 today. Thank you — the ancestor-only boundary you drew is what made this safe to do at all, and it is preserved exactly.

@DeusData DeusData closed this Aug 15, 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.

2 participants