Repository navigation
Run the real replay's variant code in the candidate sandbox - #219
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
MaxGhenis
force-pushed
the
claude/sandbox-real-replay
branch
from
October 22, 2026 03:22
6114e5c to
1b6d3dc
Compare
…only offline Review of 1b6d3dc (security): the runner reads stderr as a second stream, so a command there with no trailing newline arrived after the resume token; setup-uv's python problem matcher reads plain lines that stop-commands does not stop; io_uring opens sockets without socket(2), and per systemd's docs RestrictAddressFamilies has no effect on the 32-bit x86 ABI. setup's offline probe now passes only by printing its last line.
…ts, pins Review of b359dd3 (correctness): the forged-output check would pass if GitHub stopped honouring set-output, so a control step sets one outside the fence; the stub also tries a name lookup, the channel seen leaking; both jobs get timeouts, and the hand-in makes input/ afresh so a planted FIFO cannot stall it; tests now pin stop_candidate's survivor check, the stub's report keys against the runner's expectation, the stub's leftover process, and the find step's program under the standard library alone. RUNNER_TEMP, unused by the replay, is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
claude/sandbox-real-replay
branch
from
October 22, 2026 04:01
497fb9a to
2e34d67
Compare
…links Second security review of 2e34d67: "cannot read the token" holds short of a kernel privilege escalation, and install runs without the system call filters; the account can leave files in /dev/shm and /dev/mqueue and System V IPC objects, which nothing later reads; a link at the copy's root still moves the hand-in, but only within what the sandbox can write; the runner's Python outside the sandbox runs with -E -s, not isolated mode; and the timeout comment no longer claims more than the timeout does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…find test Second correctness review of 2e34d67: the stub's newline-less stderr fragment landed first and glued onto the matcher-shaped traceback, so the merged stream never ended on the case the stderr join fixes; flushing stdout first puts it last. The find-step test now picks the newest certified variant, not any replay namespace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
marked this pull request as ready for review
October 22, 2026 04:32
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The push-only real replay (
uk-replay-determinism.yml) now runs a certified variant's third-party code only asuk_replay_sandbox.sh's unprivileged account, never as the runner user. A compromised package among a freeze's pins therefore cannot readPE_UK_PRIVATE_HF_READ_TOKENout of the runner's memory with sudo, which #215 left open.Problem
After #215,
real-replayfetched the dataset before any variant code, then installed the variant's freeze and ran its engine as the runner user. That user has passwordless sudo, and the runner keeps the job's secrets in memory until the job ends. The tj-actions compromise read secrets from exactly there. The freeze pins versions, not file hashes, so the pins alone do not stop a changed package.What changes
real-replayjob. After the unchanged token step:/usr/bin/python3 -Ifinds the fetched dataset by size and SHA-256 (find_dataset_bytes).uk_replay_sandbox.sh setupmakes the account and its private copy, and checks the sandbox from inside (unchanged checks, plus the new offline ones below).install: the variant's exact freeze is built in the copy, in the sandbox, with the network and without the dataset.replay: no account process is left running. The account then writes the dataset into a freshly madeinput/from a pipe, inside an offline service. Then it replays one measure-year withcompute_uk_event --dataset-file, offline.collect(always): no account process survives, andoutput/streams back./usr/bin/python3 -E -s -m pipeline.uk_replay_determinismcompares the returned artifact with the committed one, which the job names.The job has a 90-minute timeout. Nothing is uploaded or cached. The in-sandbox commands are in the new
.github/scripts/uk_replay_determinism.sh.Offline (
in_sandbox --offline) isPrivateNetwork=yes, plus:RestrictAddressFamilies=AF_INET AF_INET6 AF_NETLINK;SystemCallArchitectures=native;SystemCallFilter=~io_uring_setup io_uring_enter io_uring_register;SystemCallErrorNumber=EPERM.Each one is there because of something seen on a real runner or written in systemd's own docs:
PrivateNetworkalone,busctl … ResolveHostnamereached systemd-resolved over the system D-Bus socket and resolvedexample.com. DNS was a way out.InaccessiblePaths=-/runstops the service starting (exit 226/NAMESPACE).AF_UNIXblocks D-Bus.socketpair(), spawn pools andProcessPoolExecutorstill work.socket(2)only. Its docs sayRestrictAddressFamilieshas no effect on the 32-bit x86 ABI (socketcall), and io_uring can open sockets withoutsocket(2).setupchecks from inside an offline service that loopback is the only interface, that an IPv4 socket opens and a Unix socket does not, and thatio_uring_setupfails withEPERM. The probe passes only by printing its last line.Untrusted output.
installandreplayprint the variant's output, stderr joined to stdout, inside::stop-commands::<random token>. They first remove setup-uv'spythonproblem matcher, which setup-uv v5 registers for the rest of the job.The runner still honours the deprecated
::set-output; a probe step set one. The same command inside the fence set nothing and raised no annotation, and the runner masks the token in the log. Stderr has to be joined because the runner reads it as a second stream, where a last line without a newline arrives after the resume token.pipeline/uk_replay_determinism.py. It is standard library only now, with its owncanonical_bytes, so the runner's Python needs nothing installed. A replayed path that is not a regular file (a link to the committed artifact, say) is refused.ci.ymlreal replay sandbox(new, on every PR, no secrets). It runssetup,install,replayandcollecton the runner image with a stand-in dataset, a one-package freeze installed from PyPI in the sandbox, and a stub engine module in the copy.The stub reports what it sees offline. It also leaves a process behind, forges
::error::and::set-outputon stdout and (with no newline) on stderr, and prints a traceback shaped for setup-uv's matcher.The runner's comparison must reproduce byte for byte its own expectation:
loonly;A control step sets an output the deprecated way outside the fence, and the forged one must stay empty.
Docs.
docs/uk_replay/RELEASE_REPLAY.mdgets a new "The real replay in the sandbox" subsection under "Replay in CI", including what a malicious freeze can still do. The receiver section's "is weaker" paragraph becomes a pointer to it, and "Replay in CI" now counts four checks.What a malicious freeze can still do
/dev/shmand/dev/mqueue, and System V IPC objects, aftercollect; nothing later in the job reads them.installalso runs without the system call filters.Invariants (tested)
real-replaythe fetch comes before any step that hands anything to the account. After it, the steps are exactly find → setup → install → replay → collect (always()) → compare, each gated onfetched. After the fetch, the only Python outside the sandbox is/usr/bin/python3 -Ior-E -s, and no step uploads or caches anything.sudostub,installandreplayhandsystemd-runexactly the base properties (plus the offline set for bothreplayservices) and an environment of exactly the listed variables. The dataset path and the token are never in that environment.replay. It ispkill→ in-sandbox hand-in (dataset bytes on stdin) → offline replay. Nothing runs as the account outside the sandbox, and nothing as root inside its home. With a surviving process it hands nothing in. A missing setting stops it before anysudo.::stop-commands::<32 hex>and its token. The token differs on every run, and the exit status passes through.uvand engine. It runs exactly the freeze's three install commands. The replay's argv is exact, and only the replayed artifact (a regular file) returns. A failed engine returns nothing.canonical_bytesequalscompute_uk_event.canonical_bytesbyte for byte. The modules import underpython -I -S, and the find step's own program reachesfind_dataset_bytesunder-I -S.-Ekeeps aPYTHONPATHimpostorjsonout.ast. The expected values are loopback, no connections and pool 3, and the stub'sPopenis a real call.These mutations each fail a test:
--offline,untrusted_output,2>&1or the survivor check;-I;Checked on real runners
real replay sandboxpassed every step, andreceiver sandboxpassed with the offline checks.verify_installedand all six events' construction guards, offline, through the realreplaymode;Reviews
Two independent Opus 5.5 reviews (security, and workflow/test correctness); the Codex and Claude lanes were closed until about 07:15Z. Each re-checked its own findings against the final head.
Security found four issues, all fixed:
The 32-bit ABI gap came from systemd's docs.
Correctness found no bug in the step conditions, shell semantics or byte comparison. Its low items are all fixed:
input/against a planted FIFO;Main's 13 later commits (a third Opus 5.5 review on 2026-10-30, at merge head
38e615f0; all six Codex lanes held). Those commits changedcompute_uk_event.pyanduk_replay_variants.py, which run inside the sandbox, and no earlier review saw them. It found no interaction problem: the merge leaves this PR's own files unchanged, the find step still imports under-I -S, the replay's import closure and variant freezes are the same, and the private copy still holds everything the replay reads. Its one limit:real replay sandboxstubs the engine, so the real engine first runs in this sandbox on the push that merges this.Follow-ups (not here)
runmode still prints the drain's output without the fence. Its step has noid, so a forged output reaches nothing, but annotations would show.uv venv --python 3.12downloads one, forci.yml's replay-engine legs as much as here.axiom: n/a: CI only
🤖 Generated with Claude Code