A read-only path inside a read-write grant can be bypassed by renaming one of its ancestors (macOS: the grant root too; Windows: folders inside the grant)
SDK: @microsoft/mxc-sdk 1.1.0 (v1 API), macOS 26.7 arm64 (Seatbelt). Windows 11 26200.9711 (ProcessContainer) for comparison.
What we do. A shared folder is granted read-write, and its .git is granted read-only inside it (readwritePaths: [shared, tmp], readonlyPaths: [shared/.git]), so that a contained agent can edit the files but not the repository's hooks or config.
What happens on macOS. A direct write to shared/.git/hooks/post-commit is refused (EPERM), as expected. The contained process can still do the following, and each step succeeds:
rename(shared, tmp/moved), moving the shared folder into another read-write grant;writeFile(tmp/moved/.git/hooks/post-commit, ...);rename(tmp/moved, shared).
The hook is then in place on the host. The same works one level down, for a nested shared/sub/.git and a rename of sub inside shared. Seatbelt's path rules match the path at the time of the access, so a path that is moved away is no longer covered.
On Windows step 1 (renaming the read-write root) is refused with EPERM. Renaming a folder inside the grant that holds a read-only path (shared/pkg, holding a read-only shared/pkg/.husky) succeeds there too, and the write after the move succeeds.
What would help. An option in ContainerRequest.filesystem that refuses rename and unlink of:
- a read-write root itself, and
- every ancestor, inside a read-write grant, of a read-only path.
Codex CLI denies the unlink of its writable roots in its own Seatbelt profile for the same reason.
Repro. A self-contained Node script (about 40 lines for this case) is available on request.