Skip to content

Keep the sidecar worker out of the daemon's state and credentials - #152

Merged
tonibergholm-codento merged 6 commits into
mainfrom
isolate-sidecar-state
Nov 20, 2026
Merged

tonibergholm-codento merged 6 commits into
mainfrom
isolate-sidecar-state

Conversation

@tonibergholm-codento

@tonibergholm-codento tonibergholm-codento commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

In the ADR-0004 sidecar, the documented layout put the daemon's repo, including .agentic/refs and the schema/*.down.sql files 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 derived Debug output.

Startup checks:

  • The daemon creates <repo>/.agentic at 0700, or tightens an existing 0755 one. It refuses to start when .agentic is already group- or world-writable.
  • It refuses when <repo> is group- or world-writable, owned by another uid, or reached through a writable ancestor. A sticky directory such as /tmp counts 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:

  • The socket is created 0666, through the umask at bind time, only when the allowlist names a uid other than the daemon's own.
  • A stale socket path is checked without following symlinks.

Credentials:

  • New --postgres-url-file and AGENTIC_GCS_TOKEN_FILE inputs.
  • Manual Debug impls redact the GCS token and the Postgres URL.

Docs: docs/integration/executor-sidecar.md now puts --repo on 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.sh clears group and other write bits on the demo directory so umask-002 checkouts still work.

Limits, stated in the doc:

  • Containers in one Cloud Run instance share the service identity, so file-based secrets remove only env, argv and log exposure. Real isolation needs ADR-0015, which is still Proposed.
  • The layout has not been verified on Cloud Run.
  • The worker must not share the daemon's primary group.

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, and run-demo.sh under 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.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cb4bf72f-79bf-4ebd-b3a1-d239ff438f65
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T08:14:28.025632Z 047ff8b New commits
🔒 Security Review ✅ Completed 2026-11-20T08:18:51.411516Z 047ff8b New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment thread crates/agenticd/src/main.rs Resolved
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.
@tonibergholm-codento
tonibergholm-codento merged commit 8939949 into main Nov 20, 2026
14 checks passed
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