X07 - Git round trip
Question: Does the git round trip work as S08-workspace-and-gitS08-workspace-and-git: Workspace and Git Round TripHow code gets into the guest and how the agent's work gets back out, without sharing the host filesystem.
describes: a remote helper over vsock, read-only upload-pack against
the user’s repository, restricted receive-pack into the landing
repository, and flagging of risky paths?
Answer: Yes, with conditions. The transport, the read-only fetch,
the restricted push and the flagger all worked, with a socketpair in
place of vsock, on the Go repository (680,000 objects), with Homebrew
git 2.56.0 and Apple git 2.54.0. No write to the user’s repository and
no push outside refs/heads/wb/<session-id>/ succeeded. As written,
S08-workspace-and-gitS08-workspace-and-git: Workspace and Git Round TripHow code gets into the guest and how the agent's work gets back out, without sharing the host filesystem. is wrong in two places. upload-pack on the
user’s repository serves hidden objects by ID over protocol v2. And the
first push into an empty landing repository sends the whole history.
The conditions below fix both.
For review
Section titled “For review”- Decides: the answer to X07-git-round-tripX07-git-round-trip: Git round tripRemote helper over vsock, read-only upload-pack, restricted receive-pack into the landing repository, flagging of risky paths., and the mechanism that
restricts pushed refs: a Go filter in
wb-hostdthat reads thereceive-packcommand list before git sees it, withreceive.hideRefsas a second layer. - You are approving: the conditions below and the
S08-workspace-and-gitS08-workspace-and-git: Workspace and Git Round TripHow code gets into the guest and how the agent's work gets back out, without sharing the host filesystem. changes in this pull request: fetches from
projects/<id>/export.gitas I41I41 (closed): S08-workspace-and-git: which git data reaches the guest, and host git as a parserS08-workspace-and-git says how bytes move, but not which data the guest may get or how much the host trusts its own git when it parses guest data: decided, the ref filter, strict object checks, cleanup after a refused push, bounds on the transport, and a landing repository that borrows objects fromexport.git. - Controls touched: SEC02-no-host-fs-shareSEC02-no-host-fs-share: No host filesystem sharingNo host directory is mounted into the guest, read-only or otherwise. (no host directory shared with the guest) and SEC03-no-host-execSEC03-no-host-exec: No host code execution via returned workNothing the agent produces executes on the host without an explicit user action; returned changes to files the host may later execute are flagged. (returned work runs nothing on the host) are kept, and the push path is now specified in more detail. SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential. (no secrets in the guest) is kept only with condition 1, which the I41I41 (closed): S08-workspace-and-git: which git data reaches the guest, and host git as a parserS08-workspace-and-git says how bytes move, but not which data the guest may get or how much the host trusts its own git when it parses guest data: decision already made.
- Assumed: that vsock behaves like the socketpair used here (a
reliable byte stream with half-close), which X18-vsock-handoffX18-vsock-handoff: Host-guest socket and descriptor hand-offCan wb-guestd, written in Go, open AFVSOCK sockets in a macOS guest? tests.
That v2
upload-packalso serves objects from an alternate object store. It follows from v2 serving an unreferenced object, but no run tried it. Howupload-packbehaves under v0 against a hostile client: every v0 refusal came from the guest’s own git client, which wouldn’t send the request. - Open decisions: none. I41I41 (closed): S08-workspace-and-git: which git data reaches the guest, and host git as a parserS08-workspace-and-git says how bytes move, but not which data the guest may get or how much the host trusts its own git when it parses guest data: still decides the export repository’s lifecycle (item 6), with a new constraint from condition 4.
- Brief: B21-git-round-tripB21-git-round-trip: Does the git round trip work, and what keeps the guest's pushes on its own branches?Yes, with conditions.
Conditions
Section titled “Conditions”- Serve
upload-packfrom an export repository, never from the user’s repository (as the I41I41 (closed): S08-workspace-and-git: which git data reaches the guest, and host git as a parserS08-workspace-and-git says how bytes move, but not which data the guest may get or how much the host trusts its own git when it parses guest data: decision chose). Withuploadpack.hideRefshiding everything but the session’s branch, and everyallow*SHA1InWantsetting off, a protocol v2 client still fetched by object ID: the commit of a hidden local branch, a commit only on a release branch, and an unreferenced blob. The export repository refused all three on the server side under v2 (“not our ref”). The guest’s git client refused to send the v0 request (“Server does not allow request for unadvertised object”), so the server side under v0 against a hostile client wasn’t tested. The export repository stores a copy of every object it serves: noobjects/info/alternatesto the user’s repository (inferred, not run), and nogit clone --local, which hard-links everything underobjects/(git help clone,--local). - The remote helper asks for protocol v2. Git tells a
connecthelper the service but not the protocol version, andupload-packspeaks v0 unless asked, sogit-remote-wbsends the version in its request andwb-hostdpasses onlyversion=0,1or2on to git. - A Go filter in front of
receive-packenforces the ref restriction. It reads the command list (pkt-lines up to the first flush), refuses the whole push unless every ref is strictly underrefs/heads/wb/<session-id>/, refuses deletes, push options and signed pushes, and only then forwards the bytes to git. The filter parses guest bytes, so it gets a fuzz target.receive.hideRefsstays as a second layer, and hides other sessions’ branches from the push advertisement. On its own,receive.hideRefsdoesn’t suffice: it let a push createrefs/heads/wb/<session-id>itself (it matches the prefix as a whole path component), which then blocks everyrefs/heads/wb/<session-id>/*branch. It also applied the allowed half of a push with one allowed and one forbidden ref, and git parsed the pack before refusing. - The landing repository borrows objects from the export
repository (
objects/info/alternates). Without that, the first push of a session sends the whole history: 425 MiB for the Go repository, refused by a 64 MiBreceive.maxInputSize. With it, the push sent 12 objects, under 1 KiB. The export repository’s garbage collection must then keep every object a landing branch needs (I41I41 (closed): S08-workspace-and-git: which git data reaches the guest, and host git as a parserS08-workspace-and-git says how bytes move, but not which data the guest may get or how much the host trusts its own git when it parses guest data:, item 6). receive-packruns with strict object checks.receive.fsckObjects=trueturns fsck warnings into errors but leaves the INFO-level checks alone: a tree with file mode100666was accepted untilreceive.fsck.badFilemode=errorand the other object-level INFO checks were raised to errors. Alsocore.hooksPathpointing at an empty location,receive.denyDeletes,receive.maxInputSize,receive.autogc=false, push options off.
Abuse cases
Section titled “Abuse cases”Each ran against throwaway repositories in a temp directory. None succeeded, with both gits. “Refused” includes what the guest saw.
| Attempt | Result |
|---|---|
Fetch a hidden branch, a note, refs/remotes/* by name |
refused: not advertised |
| Fetch a hidden commit, a release-branch commit, an unreferenced blob by ID, from the user’s repository, protocol v2 | succeeded, so condition 1 |
| The same by ID from the export repository, protocol v2 | refused by the server: “not our ref” |
| The same by ID, protocol v0, either repository | refused by the guest’s own git client before it asked; the server side wasn’t tested |
v2 object-info for a hidden blob |
refused: not advertised, invalid command |
Write to the user’s repository: push commands and a pack sent to upload-pack |
refused: protocol error; the user’s .git file names, sizes and times unchanged |
Service other than upload or receive (/bin/sh, git-upload-archive), extra arguments, bad protocol value, oversize header |
refused by wb-hostd before git runs |
Push to refs/heads/main, a tag, another session, wb/S10/* for session S1, refs/heads/wb/S1 itself |
refused by the filter, nothing written |
| Delete the session branch; push options | refused |
| One allowed and one forbidden ref in one push | whole push refused by the filter |
| Pack over the size limit (20 MiB against 16 MiB) | refused: “pack exceeds maximum allowed size” |
Trees with .git, .GIT, git~1, .., a .gitmodules or .gitattributes symlink, mode 100666; a commit with a bad date; a .gitmodules URL starting with - |
refused by fsck, nothing written |
| Bad pkt-line length, NUL in a later command, command list cut off | refused by the filter |
| Garbage, a truncated or bit-flipped pack, a header claiming 4 billion objects, a ref to a missing object | refused by receive-pack, nothing written |
results/run1.txt shows a v0 fetch by ID as succeeded. In that run the
v0 case reused the clone into which the v2 case had already fetched the
object, so git found it locally and asked nothing. Later runs use a
fresh clone for each case. The case of refs/heads/wb/S1 itself under
receive.hideRefs alone ran once, with Homebrew git
(results/run5.txt).
S08-workspace-and-gitS08-workspace-and-git: Workspace and Git Round TripHow code gets into the guest and how the agent's work gets back out, without sharing the host filesystem. adds rules to the filter that the spike never
tested: it refuses shallow lines, which the spike’s filter accepts,
and caps ref components at 255 bytes and refs at 1024. They exist only
in the spec.
Measurements
Section titled “Measurements”Apple M2, 16 GB, macOS 27.0.1, Homebrew git 2.56.0 on both sides, the Go
repository at master~200, then at master. Other agents’ VMs ran on
the same machine during the runs. The table gives the median and the
range over the five Homebrew runs in results/: run1, run2,
run4, run5 and run6. Under
that load a few runs took two to four times as long. One run with Apple
git 2.54.0 on both sides (run3-apple), also under load, took 19 to
45 s for a first clone and matched the incremental steps.
| Step | Median (range) | Runs | Transferred |
|---|---|---|---|
Local clone without the tunnel (--no-local), for comparison |
17.1 s (16.8 to 54.9) | 5 | 679,335 objects, 426 MiB |
| First clone through the tunnel, protocol v2 | 16.3 s (16.1 to 56.5) | 5 | same |
| First clone through the tunnel, protocol v0 | 16.6 s (16.3 to 22.6) | 5 | same |
| Build the export repository (first session of a project) | 16.2 s (15.7 to 61.5) | 5 | |
| First clone from the export repository | 16.6 s (16.4 to 32.4) | 5 | same |
| Update the export repository, 200 new commits | 0.83 s (0.69 to 1.19) | 5 | |
| Incremental fetch from the export repository, 200 commits | 0.57 s (0.57 to 0.72) | 5 | 2,590 objects, 912 KiB |
| Fetch with nothing new | 0.05 s | 5 | |
| Push 3 commits, landing borrows from export | 0.10 s (0.09 to 0.23) | 5 | 12 objects, under 1 KiB |
| Push 20 MiB of random data | 1.0 s | 5 | 20 MiB |
| Push into an empty landing repository (no borrowing) | 19.3 s (19.0 to 19.4) | 5 | 681,925 objects, 425 MiB |
wb land: the user’s git fetches the session branch |
1.1 s | 5 |
The tunnel doesn’t measurably slow a clone down. A session start in an existing project costs an export update and an incremental fetch, about 1.4 s for 200 Go commits. That fits NFR01-startupNFR01-startup: StartupGoals: a warm VM reaches the Claude prompt in about 4 s and a suspended VM in about 7 s, and no start takes more than 10 s (p95), excluding first-time project setup and the first boot after a host restart., whose budget leaves out first-time project setup.
Risky-path flagger
Section titled “Risky-path flagger”The prototype matched the S08-workspace-and-gitS08-workspace-and-git: Workspace and Git Round TripHow code gets into the guest and how the agent's work gets back out, without sharing the host filesystem. list on paths, used the
git file mode for executables (100755), symlinks (120000) and
submodules (160000), and read the content for symlink targets,
package.json scripts and bin, and the go and toolchain lines of
go.mod. Over the last 400 first-parent commits (all 43 for Wraith Box):
| Repository | Commits flagged | Commits per rule |
|---|---|---|
| golang/go | 9 of 400 (2%) | lockfile 7, agent configuration 1, toolchain pin 1 |
| wraithbox/wraithbox | 22 of 43 (51%) | agent configuration 14, toolchain pin 12, CI 7, build entry 3, lockfile 3, git behavior 2, package scripts 1, new executable 1 |
| Express | 69 of 400 (17%) | CI 65, package scripts 3, build entry 1 |
The mean time per commit was 11 to 18 ms, including reading blobs. The
examples checked by hand, six per repository, were all deserved, for
example a new src/simd/AGENTS.md in Go and .gitattributes and
.claude/settings.json changes here. Projects that edit their agent
configuration or CI often get many flags. Reviewers need to see those
changes, and grouping the flags per rule in the summary keeps a long
list short to read.
What changes in the specs
Section titled “What changes in the specs”- S08-workspace-and-gitS08-workspace-and-git: Workspace and Git Round TripHow code gets into the guest and how the agent's work gets back out, without sharing the host filesystem.: fetches come from
export.git(the I41I41 (closed): S08-workspace-and-git: which git data reaches the guest, and host git as a parserS08-workspace-and-git says how bytes move, but not which data the guest may get or how much the host trusts its own git when it parses guest data: decision), and everything in its object store counts as readable by the guest. The spec names the ref filter and its rules, the second layer, thereceive-packsettings, cleanup after a refused push, the transport bounds, the landing repository borrowing fromexport.git, and how the flagger detects executables, symlinks andpackage.jsonscripts. - S11-verification-and-spikesS11-verification-and-spikesthe filter's fuzz properties, including one that replays the filtered output and the exit reset into a headless emulator and checks it is back in its initial state, and a conformance case that prints every dropped seq…: a fuzz target for the request header and the push command list. Conformance cases cover fetch by ID, pushes outside the session’s refs, and the landing repository after a refused push and its cleanup.
- I41I41 (closed): S08-workspace-and-git: which git data reaches the guest, and host git as a parserS08-workspace-and-git says how bytes move, but not which data the guest may get or how much the host trusts its own git when it parses guest data: (git data scope) gets conditions 1, 4 and 5 as input: item 1 is confirmed with both gits, item 4 learns that Apple git 2.54.0 behaved the same as 2.56.0 here, and item 6 must keep the objects that landing branches borrow. Item 5 is settled by condition 3.
Throwaway code on branch spike/x07-git-round-trip, commit
f810207:
the helper, the host side, the filter with its fuzz target, the flagger,
the harness, and the output of each run under results/.
Status: Answered: yes, with conditions