Skip to content

fix(local-daemon): enforce privatefs ACLs on Claude credentials and secret peers (WHI-897) - #777

Open
Kilyn544 wants to merge 1 commit into
mainfrom
fix/whi-897-claude-credentials-acl
Open

Kilyn544 wants to merge 1 commit into
mainfrom
fix/whi-897-claude-credentials-acl

Conversation

@Kilyn544

@Kilyn544 Kilyn544 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes WHI-897 (P0 security: Claude .credentials.json and peer daemon secrets written without owner-only Windows DACL, inheriting CodexSandboxUsers:(OI)(CI)(M) from %TEMP%).

Root Cause

  1. writePrivateRuntimeFile (context_capabilities.go) used plain os.CreateTemp + os.Rename instead of privatefs, inheriting parent Windows ACEs.
  2. ConfigureClaudeContextHome, ClaudeProbeEnvironment, ClaudeModelInvokeEnvironment, and configureClaudeCredentials used os.MkdirAll(..., 0o700) without privatefs.EnsureDir, and probes wrote temp dirs into %TEMP%.
  3. adoptClaudeCredential returned early on unchanged fast paths without tightening pre-existing loose ACLs/modes left by older builds.

Changes

  • internal/platform/privatefs/privatefs_{unix,windows}.go:
    • Added handle/fd-based privatefs.ProtectFile(path) that rejects symlinks, reparse points, hardlinks, directories, and foreign-owned files before applying 0o600 (Unix) or protected owner-only DACL (Windows), with a fast-path no-op when already private.
    • Short-circuited Windows privatefs.EnsureDir when validateHandle(file, "directory", true) == nil, avoiding redundant SetSecurityInfo DACL rewrites and recursive child ACE propagation on steady-state Operations (TestWindowsEnsureDirSkipsRewriteWhenAlreadyPrivate).
  • internal/workspace/{context_capabilities,claude_credentials,operation_temp,task_temp,codex_probe}.go & internal/provider/{detection_policy,discovery,protocol_probe,runtime_monitor,model_invoke,executor}.go & cmd/linger-computer-daemon/main.go:
    • Switched writePrivateRuntimeFile to privatefs.EnsureDir + privatefs.ProtectFile + atomic privatefs.WriteFile(..., false).
    • Extracted shared probeTempRoot(baseDir, prefix) for ClaudeProbeEnvironment and CodexProbeEnvironment, moving probes into daemon's lock-tracked <StateDirectory>/operation-tmp (auto-swept on crash by PruneOperationTemps) with explicit tempBase plumbing via runtimeDetectionPolicy.authenticationProbe.
    • Hardened all Claude configRoot entry points with privatefs.EnsureDir and added legacy self-healing in adoptClaudeCredential so pre-existing loose .credentials.json and marker files are tightened in place without retiring healthy resident Claude processes.
  • Local-daemon secret writer audit & peer private operation-tmp relocation:
    • Hardened PrepareOperationTemp, claimRuntimeHome, openProjectionRoot / CodexProbeEnvironment (Windows Codex auth.json), and clicredential.Store.writeAtomic.
    • Relocated newAntigravityHookEndpoint (ConfigureAntigravityHookTempBase), claudeWriteMCPConfig (Profile.TempBase), and runAgentCLI (Daemon.operationTempBase()) out of system %TEMP% into the daemon's already-validated private <StateDirectory>/operation-tmp (with .operation_lock + crash sweep + cleanup of sealed read-only hook subtrees), preventing Windows pinParents (ancestor permits another user) regressions when %TEMP% carries non-whitelisted SIDs such as LOCAL SERVICE.
    • Added Windows regression tests (TestWindowsPrivateTempDirsAvoidSystemTempWithNonWhitelistedSID, TestWindowsRunAgentCLIAvoidsSystemTempWithNonWhitelistedSID) and cross-platform tests verifying all three paths avoid system %TEMP% and clean up properly.

Remaining Per-Operation Overhead (Steady State)

Once directories and credential files are private, each Operation performs only metadata/handle validation (O(depth) handle opens + GetSecurityInfo checks in EnsureDir on configRoot, plus handle validation in ProtectFile on .credentials.json and .linger-auth-source.sha256 — zero SetSecurityInfo writes, zero recursive child ACE propagation, and zero file rewrites on unchanged credentials).

Review Updates

  • Addressed P2-1 (Windows EnsureDir fast-path skip + overhead note), P2-2 (shared probeTempRoot), P3-3 (explicit non-variadic params & policy-driven tempBase), P3-4 (zero issue numbers in code comments).
  • Addressed Windows %TEMP% pinParents regression on newAntigravityHookEndpoint, claudeWriteMCPConfig, and runAgentCLI by relocating all three into private <StateDirectory>/operation-tmp with Windows LOCAL SERVICE %TEMP% regression tests.
  • Rebased onto latest main (4ef3f8f7).

Verification

  • macOS (darwin/arm64): internal/platform/privatefs, internal/workspace, internal/linger/clicredential, internal/provider, internal/provider/native, internal/daemon, and go vet ./... all PASS.
  • Cross-compile & vet: GOOS=windows GOARCH=amd64 (go test -c on all 6 modified packages + go build ./... + go vet ./...) and GOOS=linux GOARCH=amd64 (go build ./... + go vet ./...) all PASS.
  • Pending Windows 11 host verification (with CodexSandboxUsers and LOCAL SERVICE ACLs on %TEMP%) and Linux regression on 118.

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve with nits (2 P2, 2 P3)

Scope: base main, merge base 53f7d21a, 1 commit, 23 files reviewed (local-daemon only). Helper skills loaded: coderbook, ponytail-review, karpathy-guidelines. The review ran in a separate session.

Findings

P2

1. Every Operation start now rewrites directory DACLs on Windows, and the PR body does not state the added cost on the user message → provider_ready path
internal/workspace/context_capabilities.go:24, internal/workspace/runtime_home.go:118,122, internal/workspace/operation_temp.go:34

  • ConfigureClaudeContextHome (called from provider/executor.go:455 at Operation start), claimRuntimeHome and PrepareOperationTemp now call privatefs.EnsureDir on long-lived directories on every call.
  • On Windows, EnsureDir always walks and pins every ancestor (pinParents). It then calls SetSecurityInfo with an OICI DACL (privatefs_windows.go:504), even when the directory is already private. SetSecurityInfo propagates inheritable ACEs to existing children. For <home>/.claude, those children include everything the Claude CLI stores there: projects, transcripts and snapshots.
  • So each Claude Operation start re-walks a tree that keeps growing. The fast path in adoptClaudeCredential adds two more ProtectFile ancestor walks.
  • These paths live under StateDirectory, which main.go:130 already protects with an owner-only DACL. Their children inherit it, and validateDescriptor (privatefs_windows.go:195) accepts inherited ACEs. On Windows, the rewrite adds cost there but no protection.
  • AGENTS.md requires PRs on this path to state any added file walk. The body does not.
  • I could not measure the size of the cost: there is no Windows host here.
  • Fix: in Windows EnsureDir, return early when validateHandle(file, "directory", true) already passes. ProtectFile already does this at privatefs_windows.go:544. Then state the remaining per-Operation work in the PR body.

2. The probe temp-root allocation is duplicated
internal/workspace/claude_credentials.go:186-205 and internal/workspace/codex_probe.go:27-46

  • These two blocks are near-identical. Each picks PrepareOperationTemp(baseDir) or os.MkdirTemp + privatefs.EnsureDir, and builds a removeRoot. Any future change to where probes live, or how they are cleaned up, has to be made twice.
  • Fix: extract one helper, e.g. probeTempRoot(baseDir, prefix string) (root string, remove func(), err error), and call it from both.

P3

3. Optional parameters are modeled as variadics, and the Claude probe bypasses the policy table
internal/provider/protocol_probe.go:234-244, 380-393; internal/workspace/claude_credentials.go:181; internal/workspace/codex_probe.go:19

  • baseDir ...string and options ...probeOptions are variadics, yet every non-test caller passes exactly one value.
  • probeRuntimeAuthentication now hard-codes runtimeType == "claude" and calls probeClaudeAuthenticationIn. The authenticationProbe entry in detection_policy.go:31 now only serves the != nil checks.
  • Fix: make these plain parameters. Pass tempBase through the probe function signature (or the policy), not through a Claude-only branch.

4. A test comment carries an issue number and history
internal/workspace/claude_credentials_windows_test.go:27

  • The comment says "... before the WHI-897 fix". AGENTS.md forbids issue numbers and history in comments.
  • Fix: describe only the ACL state being simulated.

Verified as fine

  • ProtectFile safety (Unix): it opens the file with O_NOFOLLOW, then checks the owner, that it is a regular file, and Nlink == 1 on the open handle. Only then does it call fchmod (privatefs_unix.go:83-107). Symlinks, hard links, directories and foreign-owned files are refused.
  • ProtectFile safety (Windows): it opens through openHandle with FILE_FLAG_OPEN_REPARSE_POINT, so ancestors are pinned. It rejects reparse points, directories and multi-link files before SetSecurityInfo (privatefs_windows.go:538-580).
  • ProtectDirectory behavior is unchanged: it still ignores ErrNotExist, which the old private protectFile swallowed internally (privatefs_windows.go:528).
  • writePrivateRuntimeFile writes atomically: privatefs.WriteFile(..., false) writes an owner-only temp file, syncs it and renames it into place (privatefs.go:35-75). The prior ProtectFile step is needed because WriteFile refuses a loose existing target (privatefs.go:44-47).
  • clicredential.writeAtomic keeps the same semantics: temp, sync, rename, then directory sync. The parent directory was already created by privatefs.EnsureDir (store.go:276).
  • Probe temp dirs are cleaned up: they now go under operation-tmp, which PruneOperationTemps sweeps at startup (main.go:147). Each dir is lock-held while in use and removed on Close (operation_temp.go:80-90). release is wrapped in sync.Once, so repeated release calls are safe.
  • TempBase reaches every probe and invoke path: discovery (main.go:178), model invoke (main.go:465) and the auth refresh in runtime_monitor.go:340-352. CLI-side discovery (computerconfig/runtime_discovery.go:68) passes no TempBase and falls back to %TEMP%, which EnsureDir hardens.
  • The fast-path repair does not retire a resident Claude process: it is covered by TestClaudeCredentialsRepairLegacyLoosePermissionsOnUnchangedFastPath, and on Windows by TestClaudeCredentialsRepairLegacyInheritedWindowsACLOnUnchangedFastPath.
  • No CJK in added lines or in the commit message. No contracts, env vars or cross-app imports touched.

Process notes

  • The branch is 10 commits behind main. main requires up-to-date branches, so it needs a rebase.
  • The commit author is yunhe <> with an empty email, so the commit is not linked to a GitHub account.
  • One commit, no merge commits, no fixup commits.

CI

  • All checks pass, including check (computer-go) and check (computer-go-windows). The other checks were skipped by path filters.
  • check (computer-go) runs the daemon's Go unit tests without -race.
  • I ran focused tests locally on Linux, without -race: go test -count=1 -p 4 ./internal/platform/privatefs ./internal/linger/clicredential ./internal/workspace -run 'ProtectFile|PrivateFile|PrivateModes|Claude|CodexProbe|WritePrivateRuntime|OperationTemp|RuntimeHome'. All three packages passed.
  • Not verified: the real cost of Windows DACL propagation (finding 1). The PR body also lists Windows 11 QA as pending.

Automated review by Claude Code


Automated review of adcba2a by Claude Code.

@Kilyn544
Kilyn544 force-pushed the fix/whi-897-claude-credentials-acl branch 4 times, most recently from bf4c62b to 777658b Compare November 26, 2026 12:04

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve with nits (1 P2, 1 P3)

Scope: follow-up on adcba2a, reviewing head 777658b. Base main, merge base 4ef3f8f7, 1 commit, 41 files. Helper skills: coderbook, ponytail-review, and karpathy-guidelines were not loaded in this headless run; the review applied their criteria from the review brief. Ran in a separate session. The PR was rebased after the previous review, so I reviewed the full merge-base diff, not an incremental one.

Previous findings

  • P2 – EnsureDir rewrote the DACL on every Operation: Resolved. privatefs_windows.go:480 now returns early when validateHandle(file, "directory", true) passes, and the PR body describes the steady-state overhead.
  • P2 – Duplicated Claude/Codex probe temp-root code: Resolved. Both probes now call probeTempRoot (internal/workspace/operation_temp.go:96) from claude_credentials.go:190 and codex_probe.go:24.
  • P3 – Variadic param and Claude special case bypassing the policy table: Resolved. probeRuntime and probeRuntimeAuthentication now take a probeOptions struct. The Codex shortcut is gone, and tempBase reaches every probe through runtimeDetectionPolicy.authenticationProbe (detection_policy.go:15). The remaining runtimeType != "claude" check at protocol_probe.go:374 was already in the base branch.
  • P3 – Issue number and history in a test comment: Resolved. The comment in claude_credentials_windows_test.go now only describes the simulated ACL state, and the diff adds no WHI- references.

Findings

P2

  • internal/provider/native/claude_mcp_config.go:26, internal/provider/native/antigravity_hook.go:131, internal/daemon/playground_tools.go:214: the PR adds probeTempRoot (internal/workspace/operation_temp.go:96) to share the "if baseDir is set, use PrepareOperationTemp; otherwise use os.MkdirTemp plus privatefs.EnsureDir" branch. It then writes the same branch three more times, each with slightly different cleanup. If the rule changes later (for example, another Windows ancestor check, or the sealed-subtree unlock), it has to be updated in four places. Fix: export the helper (for example workspace.PrivateTempRoot(baseDir, prefix) (string, func(), error)) and use it at all four sites.
    • In claudeWriteMCPConfig, the extra os.MkdirTemp(parent, ...) inside an already-fresh OperationTemp adds nothing; the config file can go straight into the temp root.
    • With one cleanup func, the closeOpTemp != nil branches in the error paths go away.

P3

  • cmd/linger-computer-daemon/main.go:152: main calls native.ConfigureAntigravityHookTempBase(operationTempBase) and defers CloseAntigravitySharedHookEndpoint(). Daemon.Run (internal/daemon/daemon.go:318-326) configures the same <StateDirectory>/operation-tmp again, then closes the endpoint and resets the base on exit. main passes StateDirectory to daemon.Options (main.go:457), so the main.go pair is redundant. Keep the lifecycle in Daemon.Run only.

Verified as fine

  • privatefs.WriteFile(path, data, false) is still an atomic temp-file write, sync, and rename (internal/platform/privatefs/privatefs.go:49-75). The switch in writePrivateRuntimeFile and clicredential.writeAtomic keeps crash atomicity and adds the owner-only check on any existing target.
  • ProtectFile runs before WriteFile because WriteFile refuses an existing loose file through CheckPath(path, "file", true) (privatefs.go:45). This ordering is what lets legacy loose credentials repair themselves.
  • The Unix ProtectFile (privatefs_unix.go:83) opens with O_NOFOLLOW and checks owner UID, regular-file type, and Nlink == 1 on the fd before fchmod.
  • The Windows ProtectFile checks reparse point, directory, and link count on the handle before SetSecurityInfo (privatefs_windows.go:550-559).
  • Every caller of the now-exported ProtectFile tolerates ErrNotExist: ProtectDirectory (privatefs_windows.go:531), writePrivateRuntimeFile (context_capabilities.go:66), protectClaudeCredentialFiles (claude_credentials.go:137), and clicredential/store.go:315.
  • Windows EnsureDir fast path: validateDescriptor with ownerOnly=true rejects every effective allow ACE for any SID other than the user, SYSTEM, or Administrators (privatefs_windows.go:220-237). A directory that inherited CodexSandboxUsers:(OI)(CI)(M) therefore still fails validation and gets rewritten.
  • The sealed Antigravity hook subtree can still be removed. Close unlocks it before closeTemp (antigravity_hook.go:233-237). After a crash, RemoveTaskTempDir retries through makeOwnerWritable on Unix (task_temp.go:81-90), and on Windows sealing is a no-op (antigravity_hook.go:194).
  • Production passes TempBase and StateDirectory everywhere (main.go:192, 457, 467, 481), so the OS-temp fallbacks are only reached in tests.
  • The new releaseOnce guards make probe release idempotent: claude_credentials.go:192 and codex_probe.go:28.
  • No CJK characters in added lines or in the commit message.

Process notes

  • The branch is 5 commits behind main. main requires up-to-date branches, so it needs a rebase.
  • The commit author is yunhe <> with an empty email, so the commit is not linked to a GitHub account.
  • No merge commits and no fixup commits.

CI

All checks that ran passed: check (computer-go), check (computer-go-windows), check (desktop), check (web), repository-gate, and CodeQL. The rest were skipped as not affected. I also ran focused tests locally on linux/amd64 with -count=1, and all passed:

  • internal/platform/privatefs, internal/linger/clicredential, internal/workspace: filtered with -run 'Protect|EnsureDir|Claude|Codex|Probe|OperationTemp|TaskTemp|Store|Write'
  • internal/provider/native, internal/daemon: filtered with -run 'Antigravity|MCP|TempBase|AgentCLI|Playground'

The Windows-only tests (*_windows_test.go) are covered only by check (computer-go-windows). The PR body still lists verification on a real Windows 11 host as pending.

Automated review by Claude Code


Automated review of 777658b by Claude Code.

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve with nits (2 P3)

Scope: follow-up on 777658b. Base main, merge-base 4ef3f8f7, 1 commit, 41 files reviewed in full against the merge base. The 6 files changed since the previous review got a closer look. Ran in a separate session. Helper skills coderbook, ponytail-review and karpathy-guidelines were not loaded in this run; the review follows the linger-pr-review checklist directly.

Previous findings

  • P2: private temp-dir allocation copied four times. Resolved. probeTempRoot is now the exported workspace.PrivateTempRoot (internal/workspace/operation_temp.go:98). Claude and Codex probes, prepareAgentCLIConfig (internal/daemon/playground_tools.go:214), newAntigravityHookEndpoint (internal/provider/native/antigravity_hook.go:129) and claudeWriteMCPConfig all call it.
  • P3: hook temp base configured and closed in two places. Not resolved. cmd/linger-computer-daemon/main.go:152-153 still calls ConfigureAntigravityHookTempBase and defers CloseAntigravitySharedHookEndpoint. Daemon.Run does the same at internal/daemon/daemon.go:318-326.

Findings

P3

  • apps/computer/local-daemon/internal/provider/native/claude_mcp_config.go:29: claudeWriteMCPConfig decides whether to create a linger-mcp-* subdirectory by checking whether filepath.Base(root) already has that prefix. That check is really asking which branch PrivateTempRoot took (the os.MkdirTemp fallback or PrepareOperationTemp). It works today, but it couples this file to the directory names another package chooses. If either prefix changes, the layout claudeRemoveMCPConfig expects changes silently. Simpler: always MkdirTemp(root, claudeMCPDirPrefix) (a nested dir in the fallback case is harmless), or have PrivateTempRoot return the final directory.
  • apps/computer/local-daemon/internal/provider/native/antigravity_hook.go:222: Close now calls removeRoot(), which returns nothing. If the hook directory can't be removed, Close returns nil. The old closeTemp error was passed into errors.Join, and the no-root branch still joins os.RemoveAll's error. On Windows a sealed hook subtree that fails to delete now goes unreported. Have the PrivateTempRoot cleanup return error, or log it.

Verified as fine

  • privatefs.WriteFile(path, data, false) is still atomic: it writes a temp file, syncs it, then renames (internal/platform/privatefs/privatefs.go:49-75). Replacing the hand-written CreateTemp/Rename in writePrivateRuntimeFile and clicredential.writeAtomic keeps the old crash semantics.
  • Unix ProtectFile (privatefs_unix.go:82-107) opens with O_NOFOLLOW, then checks owner, regular file and Nlink == 1 before Chmod. A symlinked or hard-linked credential is refused, not followed.
  • Windows ProtectFile and the new EnsureDir fast path rely on validateHandle (privatefs_windows.go:144-162), which rejects reparse points, the wrong type and multi-link files before it trusts the DACL. The fast path returns only after the full owner-only check passes.
  • ProtectDirectory still tolerates files that vanish: ErrNotExist handling moved from protectFile to the caller (privatefs_windows.go:531).
  • Every production caller passes a real temp base: discovery/runtime_monitor through options.TempBase, protocol probe through options.tempBase, Claude runtime through profile.TempBase, and live card through d.operationTempBase(). main.go:192,467,481 sets TempBase: operationTempBase. The %TEMP% fallback is only reached when the base is empty.
  • The fallback cleanup RemoveTaskTempDir (internal/workspace/task_temp.go:61-102) works on a directory without a lock marker, and the sync.Once wrappers make every cleanup idempotent.
  • adoptClaudeCredential repairs loose ACLs on unchanged-content paths without retiring the resident process (internal/workspace/claude_credentials.go:97-129).
  • No CJK in added lines or the commit message.

Process notes

  • origin/main is 9 commits ahead of the merge base and merge state is BLOCKED, so a rebase is likely needed before merge.
  • Single commit, no merge or fixup commits.

CI

All checks pass, including check (computer-go), check (computer-go-windows), check (desktop), repository-gate and CodeQL. I ran no tests locally: the changes since the previous review are temp-dir plumbing with no new concurrency, and the Windows job covers the new Windows tests. CI runs Go tests without -race. The PR's own manual Windows 11 and Linux host checks are still listed as pending in its description.

Automated review by Claude Code


Automated review of 8b509df by Claude Code.

@Kilyn544
Kilyn544 force-pushed the fix/whi-897-claude-credentials-acl branch from 8b509df to 9c5dad9 Compare November 26, 2026 17:58

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve with nits (2 P3)

Scope: follow-up on 8b509df. Base main, merge-base 4ef3f8f7; 1 commit, 42 files in the PR (3 changed since the previous review: clicredential/store.go, store_test.go, store_windows_test.go). Helper skills loaded: coderbook, ponytail-review, karpathy-guidelines. Ran in a separate session.

Previous findings

  • Not resolved: P3 MCP config dir layout keyed on the basename prefix (apps/computer/local-daemon/internal/provider/native/claude_mcp_config.go:29). Unchanged.
  • Not resolved: P3 AntigravityHookEndpoint.Close drops the temp-root removal error (apps/computer/local-daemon/internal/provider/native/antigravity_hook.go:222). removeRoot still returns nothing, so a failed removal still yields nil.

Findings

P3

  1. apps/computer/local-daemon/internal/provider/native/claude_mcp_config.go:29: carried over from the previous review. Whether a subdirectory gets created depends on whether PrivateTempRoot returned a directory named with claudeMCPDirPrefix. That ties this code to how PrivateTempRoot names its directories. Fix: always create the claude-mcp- subdirectory, or have PrivateTempRoot return the final directory.
  2. apps/computer/local-daemon/internal/provider/native/antigravity_hook.go:222: carried over. When removeRoot fails, Close returns nil. The old os.RemoveAll path joined that error into the result. Fix: make the cleanup return error and errors.Join it in Close.

Verified as fine

  • New since 8b509df: Store.Lookup and Store.Current now run privatefs.EnsureDir on the agent directory and privatefs.ProtectFile on the credential, state and profile files (internal/linger/clicredential/store.go:155-183, :202-228, :301-325). This repairs loose permissions left by older builds. A file that disappears between Lstat and ProtectFile still maps to ErrNotInstalled or "not stored", not to an error. All three callers (internal/daemon/context_view.go:113, internal/daemon/playground_tools.go:348, internal/daemon/agent_runner.go:105) already handle these results.
  • ProtectFile rejects foreign-owned files, files with more than one hard link and directories before it changes any permission. It is a no-op when the file is already private (Unix internal/platform/privatefs/privatefs_unix.go:83-107, Windows privatefs_windows.go:541-581). On the steady-state Lookup path it therefore only opens and checks handles and writes nothing.
  • writeAtomic and writePrivateRuntimeFile still publish through a temp file plus rename (internal/platform/privatefs/privatefs.go:53-75), so the switch to privatefs.WriteFile(..., false) keeps the writes atomic.
  • Over the whole PR: PrivateTempRoot puts probe, MCP and hook directories under the lock-tracked operation-tmp when a base directory is set, and its fallback hardens the directory with EnsureDir (internal/workspace/operation_temp.go:98-117). I found no P0/P1 in the unchanged code.
  • No CJK in the added lines or in the commit message.

Process notes

  • mergeStateStatus is DIRTY: the branch conflicts with main and needs a rebase.
  • The commit author is yunhe with an empty email, so the commit is not linked to a GitHub account.
  • The PR body says Windows host verification is still pending. The Windows-only tests (store_windows_test.go, temp_base_windows_test.go, playground_tools_windows_test.go, privatefs_windows_test.go) have not run anywhere I can see.

CI

Only CodeQL has reported (pass); Analyze (actions) is pending. Because of the merge conflict, none of the other checks have run. I ran go test -count=1 -p 4 on ./internal/linger/clicredential/ ./internal/platform/privatefs/ ./internal/workspace/ ./internal/provider/native/ on Linux and all passed, plus GOOS=windows go vet on clicredential and privatefs with no findings.

Automated review by Claude Code


Automated review of 9c5dad9 by Claude Code.

…ecret peers

- Add privatefs.ProtectFile on Unix and Windows (refusing symlinks, reparse points, hardlinks, directories, and foreign-owned files before applying owner-only permissions / protected DACL).
- Short-circuit Windows privatefs.EnsureDir when validateHandle already passes so steady-state Operation starts do not rewrite directory DACLs or propagate ACEs across child files.
- Update writePrivateRuntimeFile to protect parent dir and target file via privatefs and atomically publish with privatefs.WriteFile.
- Harden all Claude configRoot entry points (ConfigureClaudeContextHome, ClaudeProbeEnvironment, ClaudeModelInvokeEnvironment) and configureClaudeCredentials with privatefs.EnsureDir.
- Export workspace.PrivateTempRoot and reuse it across ClaudeProbeEnvironment, CodexProbeEnvironment, claudeWriteMCPConfig, newAntigravityHookEndpoint, and prepareAgentCLIConfig so all private temporary directories stay under the daemon's lock-tracked operation-tmp directory (never depending on system %TEMP% ACLs on Windows), with an idempotent, read-only-safe hardened OS-temp fallback; pass probe options and tempBase explicitly through runtimeDetectionPolicy.
- Self-heal legacy exposed .credentials.json and .linger-auth-source.sha256 files on unchanged fast-paths without retiring healthy resident Claude processes.
- Self-heal legacy exposed TeamHub CLI credential directories and files (agentDirectory, profile.json, state.json, credential) across clicredential.Store Lookup, Current, and Put via privatefs.EnsureDir and privatefs.ProtectFile while keeping permission/ownership/link refusals non-retryable.
- Allow RemoveTaskTempDir to sweep read-only crash-abandoned subtrees on Unix.
- Harden peer secret/config writers in local-daemon: PrepareOperationTemp, claimRuntimeHome, openProjectionRoot (Windows Codex auth.json copies), clicredential.Store.writeAtomic, claudeWriteMCPConfig, newAntigravityHookEndpoint, and runAgentCLI.
@Kilyn544
Kilyn544 force-pushed the fix/whi-897-claude-credentials-acl branch from 9c5dad9 to f780546 Compare November 26, 2026 18:45

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve (0 findings)

Follow-up on 9c5dad9. Merge base 6a511c15; 1 commit and 42 files reviewed. The branch was rebased since the last review, so I compared the two versions with git range-diff.

Previous findings

  • Resolved: the MCP config directory no longer depends on the basename prefix. claudeWriteMCPConfig now always creates a MkdirTemp subdirectory (internal/provider/native/claude_mcp_config.go:28).
  • Resolved: the hook endpoint Close no longer drops the temp-root removal error. removeRoot now returns error and Close joins it in (internal/provider/native/antigravity_hook.go:227). TestAntigravityHookEndpointCloseJoinsRemoveRootError covers it.

Verified as fine

  • writePrivateRuntimeFile still publishes atomically. It calls privatefs.WriteFile(..., false), which writes a temp file and renames it into place (internal/platform/privatefs/privatefs.go:35-73). Calling ProtectFile first is needed because WriteFile rejects an existing file whose permissions are loose (privatefs.go:44).
  • The new Windows EnsureDir fast path only skips the DACL rewrite when validateHandle passes. validateHandle already rejects reparse points, the wrong object type and non-owner-only descriptors (privatefs_windows.go:144-169).
  • Every PrivateTempRoot caller gets a cleanup that is safe to call more than once. With a base directory, the root is lock-tracked through OperationTemp.Close (internal/workspace/operation_temp.go:72-90), and main.go:146-152 and :192 pass TempBase to discovery, the monitor, model invoke and the Antigravity hook.

Process notes

  • The commit author yunhe has no email, so the commit is not linked to a GitHub account.

CI: check (computer-go), check (computer-go-windows) and check (desktop) were still pending; the other checks passed or were skipped. I ran the focused local-daemon tests myself; they passed:

  • go test on privatefs, clicredential, workspace (Claude/Codex/temp tests) and provider/native (Antigravity/MCP tests). TestCodexWarmMCPReadiness, which this PR doesn't touch, failed once on its 50ms timeout under host load and passed on rerun.
  • GOOS=windows go vet on the touched packages was clean.

Automated review by Claude Code


Automated review of f780546 by Claude Code.

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