Repository navigation
feat(sandbox-relay): the sandbox_exec audit line carries wid and call_id, and harness Execs get one - #981
Conversation
…_id, and harness Execs get one
A relay audit line could not be joined exactly to the worker's record of the same Exec: the line
held only the caller's req_id, while the worker logs the id the relay mapped it to (workerReqId).
The line now carries that id as wid (absent only when the relay refused the Exec before mapping
it), an optional call_id from gRPC metadata x-moca-call-id (kept only when it matches
[A-Za-z0-9._:-]{1,64}, otherwise dropped and never echoed; never read for auth or routing), and the
harness's own Execs (MOCA_RELAY_EXEC_TOKEN) write the same line with caller=harness, no sub, sbx or
cmd, and wid = req_id, which the relay forwards unchanged. Lines are still written only on a relay
with sandbox keys, and SH_SANDBOX_AUDIT_COMMANDS is unchanged.
Logging wid keeps the spec's rule: a wid reveals nothing about the relay's key, so a sandbox still
cannot predict another sandbox's. Spec §3.5 and the runbook list the new fields.
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
…IdFrom's bounds The relay keeps its own copy of the client's x-moca-call-id pattern (sandbox-client exec-conn.ts). The test fails if the copy changes, so the two can't drift apart unseen. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
The join is done at the right seam. call_id is the client's label and is validated before it is ever echoed (callIdFrom keeps only [A-Za-z0-9._:-]{1,64}, drops everything else — including a Buffer, which it decodes first), wid is set only after the Exec is mapped, so a refusal before mapping has none (as the spec now says), and the harness path is honest about what it cannot know: no sub/sbx/cmd, wid = the req_id the worker received unchanged. The one-line-per-Exec invariant survives on every path I traced: sandboxExec's log() is logged-guarded and called from the expiry/cancel hooks and the finally, and the harness line is written after a pumpExec that cannot throw (it records thrown in the PumpResult rather than rejecting), so a route failure still leaves outcome: "error" rather than no line.
Verified at 370558e:
npx tsc --noEmitclean inpackages/sandbox-relay.npx vitest run test/audit.transport.test.ts test/sandbox-token.transport.test.ts— 85/85 pass, including the three new tests (workerwid, valid/invalidx-moca-call-id, the harness line withcaller=harnessand no command even withSH_SANDBOX_AUDIT_COMMANDS=1).- Full package suite: 342 passed, 5 skipped. The two integration suites (
template-affinity,tier-affinity) fail to collect here because they need a live Redis (ECONNREFUSED 127.0.0.1:6379); nothing in this diff is on those paths.
No findings.
Author: webchang (MEMBER — maintainer)
Areas reviewed: TypeScript (packages/sandbox-relay audit path and tests), spec and runbook docs
Agent/IDE config (.claude/.vscode): none
Commits: 2, all signed off: yes
CI status: passing (k8s-kind-e2e, lint, microvm-gates, proto, shellcheck, trivy-scan)
All checks pass. Ready for human review.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Review — relay audit joins (wid, call_id, harness)
Approving. wid is captured only once the Exec is mapped (auditWid = wid right after workerReqId), so refusal lines correctly omit it while every later line carries it. call_id is read once per Exec and callIdFrom keeps only [A-Za-z0-9._:-]{1,64}; anything else is dropped and never echoed, and it is a label only.
Harness Execs always get their line (pumpExec returns rather than throws), with caller: "harness", wid = req_id, and no sub/sbx/cmd, even under SH_SANDBOX_AUDIT_COMMANDS=1; a relay without sandbox keys still writes nothing. The two tests that encoded the old design are updated and the new ones fail without the change. CI 18/18; both commits DCO-signed; MEMBER author; no .claude//.vscode/ changes; no injection content.
Upstream rossoctl#972, rossoctl#977, rossoctl#978, rossoctl#979, rossoctl#981, rossoctl#983, rossoctl#985, rossoctl#988 and rossoctl#990 (44 commits past 49cce28). No conflict. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Closes #980
The relay's
sandbox_execaudit line now joins the worker's record of the same Exec exactly, can carry a client's own correlation id, and covers the harness's Execs too.wid: the id the worker knows the Exec by, which its journal logs asreq=(workerReqIdfor a sandbox token; thereq_iditself on the harness path, which forwards it unchanged). It's absent only when the relay refused the Exec before mapping it. Logging it doesn't weaken spec §3.6: awidreveals nothing about the relay's key.call_id: from gRPC metadatax-moca-call-id, when it matches[A-Za-z0-9._:-]{1,64}. Any other value is dropped and never echoed. It's a label only, never read for auth or routing.MOCA_RELAY_EXEC_TOKEN) write the same line withcaller: "harness", nosub,sbxorcmd, andwidequal toreq_id.SH_SANDBOX_AUDIT_COMMANDSbehaves as before.Tests (
packages/sandbox-relay):wid, equal to the id the fake worker received;x-moca-call-idappears ascall_id, and an invalid one is dropped and not echoed;caller: "harness"line withwid=req_idand no command, even withSH_SANDBOX_AUDIT_COMMANDS=1.Two existing tests asserted the old design (no worker id in the line; no line for a harness Exec) and are updated. All four fail without the change. The package's tests (347) and typecheck pass.
Assisted-By: Claude Code