Skip to content

fix(sandbox): address macOS deny-path test and config parity (#681 review)#1

Closed
PierrunoYT wants to merge 4 commits into
mainfrom
cursor/fix-pr681-macos-test-9245
Closed

fix(sandbox): address macOS deny-path test and config parity (#681 review)#1
PierrunoYT wants to merge 4 commits into
mainfrom
cursor/fix-pr681-macos-test-9245

Conversation

@PierrunoYT

Copy link
Copy Markdown
Owner

Summary

Addresses the outstanding review on Gitlawb/zero#681 (same commits pushed to agent/deny-zero-credential-reads).

  • [P1] Fix TestPermissionProfileDeniesZeroCredentialFiles on macOS: resolve the temp config home with EvalSymlinks and recompute the expected deny path after MkdirAll, so /var/private/var no longer mismatches between the pre-mkdir Clean fallback and the post-mkdir profile.
  • [P3] Add a parity test that sandbox.zeroUserConfigDir stays aligned with config.UserConfigDir (via export_test.go), so deny rules cannot silently target a different directory than the stores write to.
  • Drop a stale comment that still claimed on-disk existence filtering after that filter was removed.

Validation

  • go test ./internal/sandbox -count=1
  • go vet ./internal/sandbox/...
  • govulncheck ./internal/sandbox/... — no vulnerabilities
  • golangci-lint on changed files — no new findings (pre-existing sandbox findings unchanged)
Open in Web Open in Cursor 

PierrunoYT and others added 4 commits July 14, 2026 21:13
- Deny reads of mcp-oauth-tokens.json.secret in the default Zero
  config candidates: file-backed oauth stores keep their encryption
  secret in a sibling .secret file, so the default MCP token store
  needs the same protection as the override paths (CodeRabbit).
- Clarify that explicit credential-file overrides are still filtered
  by on-disk existence like every other candidate (Copilot).
- Align the zeroUserConfigDir doc comment with config.UserConfigDir:
  macOS honors XDG_CONFIG_HOME before falling back to ~/.config
  (Copilot).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Address code review on PR Gitlawb#681:

- Deny credentialDenyReadPaths' Zero-config candidate as the containing
  directory instead of an itemized filename list. The token/credential/
  config stores each publish through a randomly-named .tmp-<pid>-<nanos>
  sibling before their atomic rename, and the legacy MCP token store
  leaves a mcp-oauth-tokens.json.migrated backup after importing it —
  none of those names were covered by the old itemized list, so a
  sandboxed command could read them under the read-all posture.

- Stop dropping default candidates that don't exist yet at profile-build
  time. A store created later in a long-lived sandboxed session (e.g. a
  concurrent ) previously got no deny rule at all; every
  backend already treats a deny rule over a not-yet-existing path as a
  harmless no-op that still takes effect once the path appears.

- Resolve ZERO_OAUTH_TOKENS_PATH / ZERO_MCP_OAUTH_TOKENS_PATH overrides
  the same way the token stores resolve them (relative-to-cwd, no ~
  expansion) instead of through normalizeProfilePath, which tilde-expands
  and so could derive a deny path different from where the store actually
  writes.

Adds regression coverage for the directory-wide deny (including the
migrated backup and synthetic temp-file siblings), for building the
profile before the store directory exists, and for the tilde-override
resolution mismatch.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Recompute the expected Zero config deny path after MkdirAll and resolve
the temp base with EvalSymlinks so macOS /var -> /private/var does not
flake TestPermissionProfileDeniesZeroCredentialFiles. Add a parity test
that sandbox.zeroUserConfigDir stays aligned with config.UserConfigDir.

Co-authored-by: PierrunoYT <PierrunoYT@users.noreply.github.com>
@PierrunoYT PierrunoYT closed this Jul 17, 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