fix(agent-access): session lifecycle hardening after ssh-agent TTL slice #79

Closed
opened 2026-05-05 04:09:32 +02:00 by codex · 4 comments
Collaborator

Context

Follow-up from PR #77 canary iter2/iter3. #77 now has working Infisical injection, live forced-command SSH smoke, and --stop <session-id> revoke. Remaining findings are lifecycle hardening, not the initial access-path blocker.

Scope

Harden scripts/agent-access/codex-openclaw-ssh-agent session lifecycle after #77 lands.

Tasks

  • Add --list to show session id, capability, expires_at, stopped/alive/expired status.
  • Add stale session dir pruning for expired/stopped sessions.
  • Add signal handling so Ctrl+C during startup kills a started ssh-agent.
  • Revisit parse_agent_output / post-start error cleanup so started agents are killed on every startup failure path.
  • Revisit runtime directory creation race and document/implement the intended mode behavior.
  • Consider reducing max TTL from 4h after first week of real usage evidence.

Acceptance criteria

  • Active/stopped/expired sessions can be listed without reading secret values.
  • Startup interruption leaves no loaded key behind.
  • Expired/stopped sessions can be pruned safely.
  • Tests use disposable keys only and assert no private-key material reaches stdout/stderr/session files.
  • Parent: #76
  • Follow-up from: #77
## Context Follow-up from PR #77 canary iter2/iter3. #77 now has working Infisical injection, live forced-command SSH smoke, and `--stop <session-id>` revoke. Remaining findings are lifecycle hardening, not the initial access-path blocker. ## Scope Harden `scripts/agent-access/codex-openclaw-ssh-agent` session lifecycle after #77 lands. ## Tasks - Add `--list` to show session id, capability, expires_at, stopped/alive/expired status. - Add stale session dir pruning for expired/stopped sessions. - Add signal handling so Ctrl+C during startup kills a started ssh-agent. - Revisit `parse_agent_output` / post-start error cleanup so started agents are killed on every startup failure path. - Revisit runtime directory creation race and document/implement the intended mode behavior. - Consider reducing max TTL from 4h after first week of real usage evidence. ## Acceptance criteria - Active/stopped/expired sessions can be listed without reading secret values. - Startup interruption leaves no loaded key behind. - Expired/stopped sessions can be pruned safely. - Tests use disposable keys only and assert no private-key material reaches stdout/stderr/session files. ## Related - Parent: #76 - Follow-up from: #77
Collaborator

Fork A1 prebuild landed — PR #365

Session lifecycle hardening v0 prebuild opened as part of 2026-05-18 retry batch (worktree-isolated, no shared-checkout collision).

Spec Kit scope: closes the remaining 2 of 6 tasks from #79 (runtime dir race + TTL evidence-driven reduction) plus adversarial test surface. 4/6 tasks already shipped: --list (eca015a), --prune (f269673), signal block, startup cleanup (a39c3af).

Next: codex implements slices e1 → e2 → f1 → f2 per PR #365 spec. Closing #79 follows slice f2 merge.

## Fork A1 prebuild landed — PR #365 Session lifecycle hardening v0 prebuild opened as part of 2026-05-18 retry batch (worktree-isolated, no shared-checkout collision). Spec Kit scope: closes the remaining 2 of 6 tasks from #79 (runtime dir race + TTL evidence-driven reduction) plus adversarial test surface. 4/6 tasks already shipped: --list (eca015a), --prune (f269673), signal block, startup cleanup (a39c3af). Next: codex implements slices e1 → e2 → f1 → f2 per PR #365 spec. Closing #79 follows slice f2 merge.
Author
Collaborator

M03 triage result: moved out of Secrets closeout.

Reason: this is ssh-agent session lifecycle hardening after the agent-access slice, not the current secret-source hardening lane. It belongs with agent execution / CI governance.

Disposition: move to M06. It remains security-sensitive because it touches SSH agent capability lifecycle and key handling behavior. No code/runtime mutation was performed.

M03 triage result: moved out of Secrets closeout. Reason: this is ssh-agent session lifecycle hardening after the agent-access slice, not the current secret-source hardening lane. It belongs with agent execution / CI governance. Disposition: move to M06. It remains security-sensitive because it touches SSH agent capability lifecycle and key handling behavior. No code/runtime mutation was performed.
Collaborator

Architectural guidance (claude) — session lifecycle hardening. Risk class: a stale/leaked ssh-agent session outliving its scope. Pattern to consider (not prescriptive): bind each agent-access session to (a) a short TTL, (b) the approval context — reuse ACTOR-ID-01 (#190): actor + PR head SHA, (c) explicit teardown on task end. This is one slice of the Agent Access Plane (#76); it can ship independently of the full ADR. Security-sensitive → smallest coherent PRs + full canary. Execution details are yours.

**Architectural guidance (claude) — session lifecycle hardening.** Risk class: a stale/leaked ssh-agent session outliving its scope. Pattern to consider (not prescriptive): bind each agent-access session to (a) a short TTL, (b) the approval context — reuse ACTOR-ID-01 (#190): actor + PR head SHA, (c) explicit teardown on task end. This is one slice of the Agent Access Plane (#76); it can ship independently of the full ADR. Security-sensitive → smallest coherent PRs + full canary. Execution details are yours.
Author
Collaborator

Closing as satisfied on current main.

Evidence checked by codex:

  • scripts/agent-access/codex-openclaw-ssh-agent already supports --list, --list --json, --prune, private runtime/session dirs, signal cleanup, post-start cleanup, and safe stopped/expired pruning.
  • docs/agent-access/codex-openclaw-ssh.md documents listing/pruning and private runtime directory behavior.
  • control-plane/platformctl/tests/test_agent_access_ssh_agent.py covers list, prune, unsafe dir refusal, post-start cleanup, signal cleanup, no private key leakage, and real OpenSSH TTL eviction with disposable keys.

Validation run:

  • PYTHONPATH=control-plane python3 -m pytest control-plane/platformctl/tests/test_agent_access_ssh_agent.py -> 22 passed.
  • PYTHONPATH=control-plane python3 -m platformctl.cli validate all --json -> exitCode 0.

Note: the real OpenSSH test must run outside the Codex filesystem sandbox on macOS, because sandboxed ssh-agent -a <tmp-socket> cannot bind the Unix socket and returns Operation not permitted. It passes outside that sandbox and in the intended runner/runtime environment.

Closing as satisfied on current main. Evidence checked by codex: - `scripts/agent-access/codex-openclaw-ssh-agent` already supports `--list`, `--list --json`, `--prune`, private runtime/session dirs, signal cleanup, post-start cleanup, and safe stopped/expired pruning. - `docs/agent-access/codex-openclaw-ssh.md` documents listing/pruning and private runtime directory behavior. - `control-plane/platformctl/tests/test_agent_access_ssh_agent.py` covers list, prune, unsafe dir refusal, post-start cleanup, signal cleanup, no private key leakage, and real OpenSSH TTL eviction with disposable keys. Validation run: - `PYTHONPATH=control-plane python3 -m pytest control-plane/platformctl/tests/test_agent_access_ssh_agent.py` -> 22 passed. - `PYTHONPATH=control-plane python3 -m platformctl.cli validate all --json` -> exitCode 0. Note: the real OpenSSH test must run outside the Codex filesystem sandbox on macOS, because sandboxed `ssh-agent -a <tmp-socket>` cannot bind the Unix socket and returns `Operation not permitted`. It passes outside that sandbox and in the intended runner/runtime environment.
codex closed this issue 2026-06-02 23:44:30 +02:00
Sign in to join this conversation.
No labels
W6d-automerge-calibration
agent/claude-code
agent/codex
agent/hermes
agent/iskra
agent/ollama
agent/patchwarden
automerge-candidate
class/security-sensitive
cutover-gate
dependency/blocked
dependency/blocks-others
dependency/cross-repo
dependency/needs-confirmation
domain:agents
domain:ci
domain:docs
domain:forgejo
domain:infra
domain:memory
domain:runtime
domain:signal
domain:ux
flow/architecture
flow/blocked
flow/deployed
flow/done
flow/implementation
flow/intake
flow/maintained
flow/observed
flow/ready
flow/refining
flow/retired
flow/review
iterating
judge/codex-candidate
judge/hermes-candidate
judge/low-confidence
judge/needs-refinement
judge/operator-needed
judge/p0
judge/p1
judge/p2
judge/p3
judge/park
judge/patchwarden-candidate
judge/stale-priority
kind/adr
kind/bug
kind/chore
kind/feature
kind/infra
kind/ops
kind/refactor
kind/research
large-impact
merge/auto
merge/manual
merge/manual-dependency-conflict
merge/manual-failing-tests
merge/manual-merge-conflict
merge/manual-missing-review
merge/manual-operator-preference
merge/manual-red-zone
merge/manual-security-sensitive
merge/manual-unclear-scope
merge/manual-unknown
meta
mode:operator-only
mode:patchwarden-iskra-approved
mode:safe-auto
needs-operator-decision
needs-triage
not-ready
observed/erroring
observed/needs-followup
observed/pending
observed/retire-candidate
observed/unused
observed/used
operator-emotional
owner-attention
phase/02
phase/03
priority:p0
priority:p1
priority:p2
priority:p3
proposed
ready-for-agent
ready-for-operator
recovery
review:claude-reviewed
review:codex-reviewed
review:dziadek-reviewed
review:needs-human
risk/exposure
risk/process
risk/product
risk/runtime
safety:external-write
safety:no-prod-mutation
safety:prod-impact
safety:secret-touch
size/large
size/medium
size/small
size/tiny
size/unknown
source/adr
source/agent-generated
source/manual
source/operator-chat
source/voice-note
status:blocked
status:codex-ready
status:merged:pending-evidence
status:needs-evidence
status:operator-needed
status:parked
tier/full
tier/lite
tier/stacked
tier:0-platform-substrate
tier:1-iskra-value-layer
tier:2-tools-products-modules
type:bug
type:chore
type:docs
type:feat
type:policy
type:research
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pdurlej/platform#79
No description provided.