Skip to content

taskcopy: macOS's own provenance attribute no longer blocks task review and apply - #2036

Closed
AbirAbbas wants to merge 3 commits into
app/v3from
fix/darwin-provenance-apply
Closed

AbirAbbas wants to merge 3 commits into
app/v3from
fix/darwin-provenance-apply

Conversation

@AbirAbbas

@AbirAbbas AbirAbbas commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Why

On macOS, reviewing or applying a private task root refused every file with "portable apply cannot preserve extended attributes or access-control metadata". That covers /task review N slot and /task apply N slot, with CODEAF_PROTOTYPE_WORKSPACE_OWNERSHIP=1 or a chat with a saved private-task policy.

macOS 13 and later attaches the system attribute com.apple.provenance to every file, directory and symlink that a provenance-tracked process writes. That includes every binary built on the Mac and everything it starts, so the engine and its tools tag all their output. review_metadata_unix.go refused any path with any extended attribute (Llistxattr size > 0).

Measured on the Mac (macOS 15.6, APFS):

  • The value is always 11 bytes (01 02 00 followed by 8 id bytes).
  • A tracked process cannot change or delete it: xattr -w, -wx and -d return 0 and the value stays.
  • 2 taskcopy tests and 28 session tests (TestTaskWorkspace*, TestPlanBacked*) fail there because of it. With test binaries that carry no provenance, all 30 pass.

Change

  • darwin: allow exactly one attribute, com.apple.provenance with an 11-byte value.
    • The attribute list is read no-follow into a fixed 21-byte buffer, and must be exactly that one name.
    • The value is read no-follow into a fixed 12-byte buffer, and must be 11 bytes.
    • The list is read again afterwards and must not have changed.
    • Every other attribute still refuses with the same message, with no prefix matching: quarantine, macl, FinderInfo (even zeros), a resource fork (also through ..namedfork/rsrc), every metadata:* name, and any user name.
    • The size bound also refuses any larger payload under the allowed name.
  • The provenance contract, stated plainly in the code and the manual. The attribute is not carried over: an applied file gets the provenance macOS gives it, whoever wrote the old value. Apply already writes new inodes. An untracked process (for example a launchd job) can store any 11 bytes there; those bytes are outside the portable contract like the attribute itself.
  • darwin ACL check. When a path has both an attribute and an ACL, macOS ls -l prints @ and not +. With provenance on every path, the + branch never fired, and ACLs were caught only by the line count. The listing check now also refuses any ACL entry line explicitly (indented, N: …). The line-count, failure and batching rules are unchanged.
  • Linux: the same size-only check, moved into review_metadata_linux.go, with the same syscalls, order, errors and text. Other platforms are unchanged.
  • Docs: the manual's Apply metadata section, and a change entry.

Tests

internal/taskcopy/review_metadata_darwin_test.go:

  • TestPortableMutationAllowsDarwinProvenance: a file, a directory, a symlink, a dangling symlink and a root, each with real 11-byte provenance.
  • TestPortableMutationRefusesOtherDarwinXattrs
    • The listed attributes are tried on a file, a directory and a symlink. A same-length lookalike name also refuses.
    • A link's verdict and its target's verdict stay independent.
    • An attempted 33-byte provenance overwrite is checked by what is actually stored.
  • TestPortableMutationRefusesDarwinResourceFork: the fork refuses, and its bytes are intact afterwards.
  • TestPortableMutationRefusesDarwinACLBesideProvenance
    • A file, a directory and a symlink with an ACL refuse, alone and inside a 201-path batch.
    • A file named " 0: fake" and a name with a newline still pass.
  • TestPortableDarwinXattrDecision: unit tests over exact name and size, every errno, a race between the two list reads, and bounded calls.
  • TestPortableDarwinACLListing: unit tests on captured listings.
  • The provenance tests fail (they do not skip) when the test binary itself carries provenance but a fixture it wrote has none.
  • Existing TestPortableMutationRefusesNativeDarwinMetadata and TestPortableMutationPreflightBatchesDarwinPaths are unchanged, and now pass on the Mac.

internal/session/task_workspace_metadata_darwin_test.go:

  • TestTaskWorkspaceApplyWithDarwinProvenance: folder and repository. Review and apply carry the exact reviewed bytes, and the private copy is kept.
  • TestTaskWorkspaceApplyRefusesDarwinQuarantine
    • Quarantine on the private output refuses review.
    • Quarantine added to a destination file after review refuses apply. That file keeps its bytes and its quarantine.
  • Both tests set a canonical TMPDIR first, because the Mac's symlinked TMPDIR breaks session workspace tests for a separate reason.

Six subcases skip on this Mac, and that is expected. The kernel drops an all-zero FinderInfo write, and it refuses or drops an empty resource-fork write. The decision unit test covers those names.

Gates (on the Mac, Go 1.26.5)

  • gofmt; go vet ./internal/taskcopy on darwin and GOOS=linux; GOOS=linux go build ./internal/taskcopy: clean.
  • All darwin taskcopy metadata tests (the 8 above): pass.
  • Whole internal/taskcopy package: no new failures against the Mac baseline for app/v3 12dadd6, and the 2 R2 tests are fixed. The remaining 22 failures are the known symlinked-TMPDIR fixtures, the same names as the baseline.
  • With a canonical TMPDIR, all 28 R2 session tests plus the 2 new ones: pass. On app/v3 they fail with the extended-attributes refusal. Under the default (symlinked) TMPDIR, the 2 new session tests pass too.
  • Full Mac gate, go test -count=1 -p 6 ./..., compared by test name with the baseline: pending (queued behind the machine-wide heavy-job lock, which waits for the Mac performance baseline).
  • Engine CI dispatched on this branch (head 0174c83), judged by content against app/v3 12dadd6's fresh runs (PR gate 40925411112, Full check 40925415150):
    • PR gate 40935138265: the light gate's output is line-for-line identical to app/v3's (the same law complaints, none new). Touched packages pass.
    • Full check 40935142667: on the rerun, 28 failures, exactly app/v3's known set. On the first attempt, one factory test (TestAWarmNoSendsBackToThePlanWithTheWordsAndAsksAgain, a 10 s timing wait) failed; it passes 3 of 3 times on the Mac on this branch and on app/v3, and passed when the failed shards were rerun.

Manual verification (real terminal chat)

On an isolated home with CODEAF_PROTOTYPE_WORKSPACE_OWNERSHIP=1, the real codeaf chat ran in a private tmux terminal. /task BASH[printf r2-fixed > result.txt] was sent to a scripted local model, and the worker wrote result.txt in the private root. That file carries com.apple.provenance, because the engine is a locally built binary.

Step app/v3 engine this branch
/task review 1 work "could not review task root · portable metadata for result.txt: portable apply cannot preserve extended attributes or access-control metadata" the diff for result.txt and "Apply this root: /task apply 1 work"
/task apply 1 work "review this root first…" "task 1 root work: inplace (reviewed snapshot …)"; the original folder's result.txt holds r2-fixed
negative control: quarantine added to the private result.txt — review refuses with the extended-attributes message; nothing applied

Review and known limits

There were two adversarial Codex review rounds. Both explicitly tried to break the allowlist.

What was tried, and the verdicts:

  • Data smuggled under the allowed name:
    • Other sizes, lookalike or longer names, NUL tricks, and two short names filling 21 bytes are blocked.
    • Arbitrary 11 bytes from an untracked process are accepted and dropped. This is now explicitly outside the contract, as above.
  • Resource forks and FinderInfo: blocked.
  • Compressed and dataless files: blocked by the unchanged native-flags refusal.
  • ACLs with or without attributes, odd names and batches: blocked.
  • Symlinks: no-follow on every call.
  • Linux: unchanged.

Pre-existing limits, not widened here. The native metadata checks are not atomic:

  • An attribute added and removed between probes, or added after the last probe, is missed.
  • A directory removed after preflight is not checked again.
  • An inode swapped after Lstat is not detected.
  • Metadata-only tampering of the reviewed snapshot is not detected.

One new variant applies to the tolerated attribute: provenance grown from 11 bytes to a larger value between the value read and the second list read is not seen, because the second read checks names only. Only an untracked process can do that.

Round outcomes:

  • Round 1: 1 major (the 11-byte payload, resolved through the contract above) and 2 minor (test skips, now failures on a tracked binary; the change entry, now added).
  • Round 2: no blocker or major; all rebuttals accepted.

🤖 Generated with Claude Code

AbirAbbas and others added 3 commits October 29, 2026 19:15
…d apply

macOS 13+ attaches com.apple.provenance (11 bytes) to every file, directory
and symlink a provenance-tracked process writes, which is every binary built
on the Mac and everything it starts. Portable review/apply refused any path
with any extended attribute, so private task roots could never be reviewed
or applied on a Mac.

On darwin the check now allows exactly one attribute: com.apple.provenance
with an 11-byte value, read no-follow into fixed buffers, with the list read
again afterwards. Every other attribute (quarantine, macl, FinderInfo, a
resource fork, metadata:*, any user name) still refuses with the same
message. Apply writes new inodes, which get their own provenance, so
nothing of the project is lost.

The darwin ACL check also refuses ACL entry lines explicitly: with an
attribute present, ls -l prints '@' instead of '+', so the '+' branch never
fired and only the line count caught an ACL.

Linux keeps its size-only check unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ipping on a tracked binary

Review round 1: an untracked process can store any 11 bytes under
com.apple.provenance, and apply does not carry them. Say plainly, in the
code and the manual, that the attribute is outside the portable contract
whoever wrote it, and that an applied file gets the provenance macOS gives it.

The provenance tests skipped whenever a fixture had no attribute. A tracked
test binary tags everything it writes, so they now fail in that case and
skip only when the test binary itself carries no provenance.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AbirAbbas

Copy link
Copy Markdown
Collaborator Author

Closing unmerged: the Mac push stopped early to save usage. What this fixes and what is left is tracked in #2052. The branch fix/darwin-provenance-apply is kept.

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