Skip to content

Add opt-in signed operator approval for Tier-3 confirmations - #299

Merged
rmednitzer merged 1 commit into
mainfrom
feat/operator-armed-confirmation
Nov 23, 2026
Merged

rmednitzer merged 1 commit into
mainfrom
feat/operator-armed-confirmation

Conversation

@rmednitzer

@rmednitzer rmednitzer commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

This PR adds an opt-in mode in which only the operator can arm a Tier-3 confirmation: RELAY_SHELL_CONFIRM_APPROVAL=signature (ADR 0015). It addresses a gap found in a review against a sibling MCP control plane.

Problem. With RELAY_SHELL_CONFIRM_TIER3=true, ADR 0009 lets the same client that received a token arm it. That is friction, not a human approval. A deployment with the broker on pays for the extra step without getting one.

Why not a host-side approval verb. relay-shell --confirm <id>, or a marker file the server reads, would not help. shell_exec runs as the service account, which has sudo on the privileged deployment, so the model could approve its own call. The approval has to come from a key the host does not hold.

How it works:

  1. Plan. A Tier-3 plan returns one ASCII line: relay-shell-confirm v1 {"args":…,"exp":…,"id":…,"op":…,"server":…,"tool":…}.
    • args is the redacted audit view, so no raw secret reaches the operator.
    • op is the existing sha256(tool \0 op_key) binding.
    • The broker stores the line with the token.
  2. Sign. The operator signs the line on their own machine with ssh-keygen -Y sign -n relay-shell-confirm -f <key> <file>. The client passes the .sig contents to operation_confirm(token, signature=…).
  3. Verify. The token is armed only if all of these hold:
    • the signature verifies over that token's exact line, with or without a trailing LF/CRLF;
    • it is in the relay-shell-confirm namespace, which relay-shell checks itself, so a git or file signature by the same key is refused;
    • the key is listed in RELAY_SHELL_CONFIRM_ALLOWED_SIGNERS.
    • Verification is asyncssh.validate_sshsig, already a runtime dependency; there is no custom crypto.
  4. Strict loading. The allowed-signers file is read once at startup. Any of the following refuses startup (and fails --check-config): an unparsable line, a wildcard or negated principal, a cert-authority entry, an empty file, or a file writable by group or other. On its own, asyncssh silently skips unparsable lines.
  5. Audit. The arm record adds approver (the verified principal) and signature_sha256. server_info.confirm adds approval and signers (principals and fingerprints). The raw token and the signature body are never logged.

Unchanged: the default (client, ADR 0009 behaviour, byte-identical record), binding, TTL, single use, client binding (A14-C10b), deny/mode-first ordering, and re-classification of the retried call. No new tool.

Residual risk (documented in the ADR, the deployment guide and the module docstring):

  • A service account with root can replace the signers file and restart. That is not prevented, but it is made visible: startup-only load, fingerprints in server_info, and coverage by AIDE or a drift check is recommended.
  • An operator who signs without reading the line can be misled by the model's summary (CS-4).

Type of change

  • Bug fix
  • New capability (tool / transport / auth provider): an opt-in approval mode and an optional tool argument, no new tool
  • Security hardening
  • Documentation
  • Build, CI, or release automation
  • Refactor / cleanup (no behavior change)

Runbook §3.1 checklist

  • CI is green on the PR head commit. Pending.
  • The new module approval.py is in the docs/architecture.md table, the runbook §3.3 security-sensitive list and the PR template list.
  • No new tool. operation_confirm has an optional signature argument; docs/tools.md is updated.
  • New env vars are in .env.example (template test passes), Settings and docs/deployment.md (§8a and §8c).
  • No permissive setting is added; the new setting only makes things stricter. The default configuration still refuses no command (ADR 0013 tests pass).
  • No dependency changes. It uses asyncssh.sshsig from the pinned asyncssh 2.24.1.

Security-sensitive diff (runbook §3.3)

  • This PR is security-sensitive. It touches broker.py, the new approval.py, config.py, and in server.py the confirmation block of Relay.run() and operation_confirm.
  • I walked the manual §3.3 checklist. /security-review was not run.
  • Audit-record fields are unchanged in the default configuration. In signature mode only, two additive argument keys appear on operation_confirm. The output body is still only hashed.
  • policy_text passed to Relay.run() is unchanged.
  • No redaction pattern changes. The challenge uses the existing redacted view.

STPA: in ADR 0015.

  • Losses, hazards and constraints: L-2, H-2..H-4, SC-2..SC-4.
  • Unsafe control actions, each with its test: UCA-4..UCA-7.
  • Causal scenarios: CS-4 (misleading summary), CS-5 (root replaces the signers file), CS-6 (restart drops tokens).
  • STRIDE notes are included.

Test plan

  • ruff check ., ruff format --check ., mypy and pytest -q pass locally (Ubuntu 26.04 / CPython 3.14, development-py3.14.txt): 1542 passed, 19 skipped. The skips are the root-, chattr +a- and CAP_SYS_ADMIN-gated tests. The py3.12 profile was not run locally; CI covers it.
  • pytest -m fuzz passes.
  • tests/test_confirm_signature.py has 31 tests, with keys generated per test by asyncssh. They cover:
    • challenge format (one ASCII line, truncation still bound by op);
    • namespace parsing of malformed armor;
    • verifier accept and refuse cases: wrong namespace, other data, other plan, unlisted key, tampered, oversize, empty, altered line, and LF/CRLF variants;
    • strict file loading (9 failure shapes);
    • broker behaviour: arm refused, signed arm, single use, cross-plan refusal, foreign client, expiry, read-only check_signature; the client-mode broker is unchanged;
    • settings validation;
    • end to end: the secret is redacted in the challenge, the client alone cannot arm, a forged key does not verify, the operator signature arms and executes, the audit approver is recorded, the raw token and signature body are absent from the audit log, and a replayed signature does not arm the next plan;
    • server_info signers;
    • startup refusal on a bad file.
  • The docs site build (mkdocs) was not run locally; CI's docs job covers it. The ADR is added to mkdocs.yml nav.

Not verified

  • A real ssh-keygen -Y sign with a hardware -sk key against this server. The tests use asyncssh's create_sshsig, which produces the same SSHSIG format.
  • How MCP clients (ChatGPT connector, Claude) present the multi-line plan response.
  • Any deployment. Merging does not deploy anything; enabling the mode is a separate operator change (signers file plus env).

🤖 Generated with Claude Code

RELAY_SHELL_CONFIRM_APPROVAL=signature (ADR 0015) makes a Tier-3
confirmation token armable only by an SSH signature (SSHSIG, namespace
relay-shell-confirm) over the one-line challenge the server issued with
that token. The challenge names the tool, the redacted arguments, the
operation hash and the expiry. Allowed operator keys come from an
OpenSSH allowed_signers file (RELAY_SHELL_CONFIRM_ALLOWED_SIGNERS), read
once at startup with strict parsing. Verification is asyncssh's.

A host-side approval verb would not work here: shell_exec runs as the
service account, which has sudo on the privileged deployment, so the
model could approve its own call. An off-host key cannot be used that
way.

operation_confirm gains an optional signature argument. In signature
mode the arm record adds approver and signature_sha256, and
server_info.confirm adds approval and signers. The default (client)
keeps ADR 0009 behaviour and a byte-identical record. Binding, TTL,
single use, client binding and deny/mode-first ordering are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 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-23T20:24:28.715821Z cb00ccc PR opened
🔒 Security Review ✅ Completed 2026-11-23T20:29:10.440529Z cb00ccc PR opened
ℹ️ 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.

@rmednitzer
rmednitzer enabled auto-merge (squash) November 23, 2026 20:25
@rmednitzer
rmednitzer merged commit 8a37bea into main Nov 23, 2026
15 checks passed
@rmednitzer
rmednitzer deleted the feat/operator-armed-confirmation branch November 23, 2026 20:27
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