Repository navigation
Keep the sidecar worker out of the daemon's state and credentials - #152
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e3c3f2a365
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
e3c3f2a to
6480b9e
Compare
In the Cloud Run sidecar the worker shares a volume with agenticd, and nothing set file modes on the state directory, so a worker could edit refs and the reverse-migration SQL that rollback runs against Postgres. The daemon now creates `.agentic` with mode 0700 and refuses to start unless it owns the repo and `.agentic`, the repo is not group- or world-writable, and `.agentic` is not a symlink. Credentials no longer have to travel through argv or the environment: `--postgres-url-file` and `AGENTIC_GCS_TOKEN_FILE` read them from secret volumes. Debug output for `GcsObjectStore` and `MemoryBackendSpec` omits the bearer token and database URL. The sidecar doc now describes the separate-uid layout that these checks assume.
The ownership check covered only the repo and `.agentic`, but the daemon reopens those paths for its whole life, so a directory above the repo that another uid can write is enough to swap the state out. Startup now resolves the repo to its canonical path, uses it from then on, and refuses when the repo or any ancestor can be modified by another principal. An existing `.agentic` that is group- or world-writable is now refused instead of tightened. The socket is no longer chmodded after bind. It is created 0666, via a umask held only across the bind call, only when the allowlist names a uid other than the daemon's. The sidecar doc now keeps `--repo` on a volume only the daemon mounts and states what has not been verified on Cloud Run.
The repo directory now refuses any group or other write bit, sticky bit or not, since it is where `.agentic` gets planted. The ancestor exemptions apply only to strict ancestors. A sticky ancestor such as a root-owned `/tmp` passes when its child on the path is owned by the daemon or root, which the previous check wrongly refused. `--trusted-volume-root` lets an operator exempt one ancestor they assert only agenticd mounts, for volume roots that are world-writable. The default socket path is built from the repo as given again, and a dangling symlink at the socket path is removed before binding. The demo script drops group write on its repo directory and `.agentic` so umask-002 checkouts still run.
…aths early The ancestor checks read metadata through symlinks, so a component swapped for a link after canonicalization would have been judged by its target. Every entry in the resolved chain, and the child used for the sticky check, is now read with symlink_metadata and refused if it is a symlink. The default socket path is built from the canonical repo again, and a path over the sun_path limit fails at startup with a message that says to pass `--socket`. A trusted volume root now skips only the write-bit checks and must still be owned by the daemon or root.
An ownership refusal cannot be fixed with --trusted-volume-root, so do not suggest it there.
The default socket lives in the 0700 state directory, which another uid cannot traverse, so an allowed worker could never connect. Refuse at startup with an actionable error instead.
21b9f7f to
047ff8b
Compare
In the ADR-0004 sidecar, the documented layout put the daemon's repo, including
.agentic/refsand theschema/*.down.sqlfiles that a plain Rollback executes, on the volume the adversarial worker also mounts. Nothing in the daemon set a file mode or checked ownership. The GCS token came only from the environment, the Postgres URL with its password only from argv, and both sat in derivedDebugoutput.Startup checks:
<repo>/.agenticat 0700, or tightens an existing 0755 one. It refuses to start when.agenticis already group- or world-writable.<repo>is group- or world-writable, owned by another uid, or reached through a writable ancestor. A sticky directory such as/tmpcounts as safe, and so does a group-writable ancestor in the daemon's own group.--trusted-volume-root <dir>exempts a private volume root, such as a Kubernetes-style emptyDir that only agenticd mounts.Socket:
Credentials:
--postgres-url-fileandAGENTIC_GCS_TOKEN_FILEinputs.Debugimpls redact the GCS token and the Postgres URL.Docs:
docs/integration/executor-sidecar.mdnow puts--repoon a volume mounted only into agenticd and shares only the socket.Breaking for existing sidecar deployments: a repo on the old shared, world-writable volume now refuses to start until it moves to the new layout.
run-demo.shclears group and other write bits on the demo directory so umask-002 checkouts still work.Limits, stated in the doc:
Proof: startup tests refuse world-writable, sticky world-writable and own-group-writable repos, writable ancestors, and writable existing
.agentic. Other tests cover sticky/tmp, the trusted root, socket modes, dangling stale-socket links, secret-file parsing and Debug redaction. They fail without their fixes.cargo test --workspace, the Postgres suites, andrun-demo.shunder umask 002 pass.Reviewed with sol-loop: 5 rounds with gpt-6.2-sol. Sol verdict: approved. Mythos 5.2 security review: approved (round 3).
Created with Claude Opus 5.5 and Claude Sonnet 5.5 in Claude Code.