C08 - Git
Purpose: The test cases for the git round trip: the transport, the pack scanner and the pre-receive check, git’s own limits behind them, and the data scope of what a session gets from the host repository.
Verifies: 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. (the data scope of B41-git-data-scopeB41-git-data-scope: Which git data may reach the guest, and how far does the host trust its own git?Serve the guest from a host-side export repository holding only the session's branch, scan carried-in files, clean remote URLs, and require a minimum git version.), S08-05-push-limitsS08-05-push-limits: Push LimitsCleanup after a push that failed, the size cap of landing.git, and the time and memory bounds of the git gateway. (“Bounds”), 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., X26-pre-receive-checkX26-pre-receive-check: Push checks before the quarantine landsCan a pre-receive check that Wraith Box owns, never the repository, refuse a push whose objects inflate past a cap, and repeat the ref checks git only runs in update(), so a refused push leaves nothing in landing.git…, X28-git-alloc-limitX28-git-alloc-limit: git's allocation cap against delta bombsDoes GITALLOCLIMIT in receive-pack's environment make both host gits refuse each delta bomb of X26-pre-receive-check before allocating its result?
Unit tests
Section titled “Unit tests”- The environment builder of
wb-hostdsetsGIT_ALLOC_LIMIT=104857601forreceive-pack.
Fuzzing
Section titled “Fuzzing”-
The git transport framing: the request header and the push command list (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.).
-
The input of the pre-receive check (X26-pre-receive-checkX26-pre-receive-check: Push checks before the quarantine landsCan a pre-receive check that Wraith Box owns, never the repository, refuse a push whose objects inflate past a cap, and repeat the ref checks git only runs in update(), so a refused push leaves nothing in landing.git…).
-
The pack scanner in front of
receive-pack. Its target checks that:- what it forwards equals its input when a pack passes, and is a prefix of it when one is refused;
- a refused prefix never holds the pack’s checksum (as long as the landing repository’s hash);
- the scanner’s heap stays under a fixed bound plus its slice of entry sizes, which the object count cap bounds (X28-git-alloc-limitX28-git-alloc-limit: git's allocation cap against delta bombsDoes GITALLOCLIMIT in receive-pack's environment make both host gits refuse each delta bomb of X26-pre-receive-check before allocating its result?).
Its seeds include REF_DELTA entries, delta chains, empty zlib stored blocks, and packs written by zlib-ng at level 1 and with
core.compression=0. -
A differential test passes the scanner’s corpus and the generated packs to
git index-pack --stdin --strict. The scanner and git must agree on entry boundaries and size fields, and every pack the scanner refuses as malformed git refuses too.
Conformance
Section titled “Conformance”The transport
Section titled “The transport”- Write into the host repository through the git transport.
- Fetch an object outside the session’s branch by its ID.
- Push outside
refs/heads/wb/<session-id>/, or a tree with a.gitentry. - Push with a first command that doesn’t ask for
side-band-64k, and see the ref filter refuse it. - With a pack that makes
receive-packwrite escape sequences and more than 4 KiB to its standard error, see the log hold one quoted field of at most 4 KiB with none of them. - Check that the landing repository holds none of a refused push’s objects (X26-pre-receive-checkX26-pre-receive-check: Push checks before the quarantine landsCan a pre-receive check that Wraith Box owns, never the repository, refuse a push whose objects inflate past a cap, and repeat the ref checks git only runs in update(), so a refused push leaves nothing in landing.git…): right after the push for each refusal of the pre-receive check (a ref too long for the file system, a stale old object ID, directory/file and case clashes, an object over the cap), and after the cleanup for a push that failed later.
- Kill
receive-packin the middle of a push, and see the cleanup leave noobjects/tmp_objdir-*and no*.lockunderrefs/heads/wb/.
The pack scanner
Section titled “The pack scanner”Push each of these, and see the scanner refuse it with its rule before
the pack’s checksum reaches git, and so before git resolves any delta,
with the memory of the git child and of wb-hostd measured
(X26-pre-receive-checkX26-pre-receive-check: Push checks before the quarantine landsCan a pre-receive check that Wraith Box owns, never the repository, refuse a push whose objects inflate past a cap, and repeat the ref checks git only runs in update(), so a refused push leaves nothing in landing.git…, X28-git-alloc-limitX28-git-alloc-limit: git's allocation cap against delta bombsDoes GITALLOCLIMIT in receive-pack's environment make both host gits refuse each delta bomb of X26-pre-receive-check before allocating its result?):
- a delta whose result, source size or own data length is over the per-object cap;
- a blob whose inflated size is over it;
- objects whose sizes add up to more than the per-push cap;
- REF_DELTA entries whose declared source sizes alone add up to more than the per-push cap;
- 10,001 REF_DELTA entries against distinct small bases in
export.git, refused before git reads a base; - a pack header that declares more objects than the count cap, with no entries after it;
- an entry that declares a size of 1 byte, followed by empty zlib stored blocks until the pack is one byte over the 256 MiB wire-byte cap, which the scanner refuses on that cap while its memory doesn’t grow.
Under the caps, the git child’s peak memory stays near what X26-pre-receive-checkX26-pre-receive-check: Push checks before the quarantine landsCan a pre-receive check that Wraith Box owns, never the repository, refuse a push whose objects inflate past a cap, and repeat the ref checks git only runs in update(), so a refused push leaves nothing in landing.git… and X28-git-alloc-limitX28-git-alloc-limit: git's allocation cap against delta bombsDoes GITALLOCLIMIT in receive-pack's environment make both host gits refuse each delta bomb of X26-pre-receive-check before allocating its result? measured, 207 MiB at a 100 MiB per-object cap.
- Push one tree of 100 MiB, and one commit with 100 MiB of
parentlines, each under the caps, and record the git child’s peak memory when the conformance suite is built. These cases have no measured value yet (S08-05-push-limitsS08-05-push-limits: Push LimitsCleanup after a push that failed, the size cap of landing.git, and the time and memory bounds of the git gateway., “Bounds”).
Git’s own limits, with the scanner off
Section titled “Git’s own limits, with the scanner off”With the scanner off and receive.unpackLimit=1, 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. sets it:
- push a pack one byte over 256 MiB, and see git refuse it on
receive.maxInputSize; - push the scanner’s packs, and see git refuse each one that asks for
more than the per-object cap in one allocation, with the git child
under 20 MiB, through
GIT_ALLOC_LIMIT(X28-git-alloc-limitX28-git-alloc-limit: git's allocation cap against delta bombsDoes GITALLOCLIMIT in receive-pack's environment make both host gits refuse each delta bomb of X26-pre-receive-check before allocating its result?). An object of exactly the cap passes and one byte more is refused. A pack header that declares 1,638,400 objects or more is refused; - push 64 deltas under the per-object cap without the pack’s checksum,
and see
index-packfail with no delta resolved, in under a second (X28-git-alloc-limitX28-git-alloc-limit: git's allocation cap against delta bombsDoes GITALLOCLIMIT in receive-pack's environment make both host gits refuse each delta bomb of X26-pre-receive-check before allocating its result?); - push a pack that names more than 4.2 million distinct object IDs (for
example trees that name many blobs), and see git fail when its object
hash table would grow past
GIT_ALLOC_LIMIT(S08-05-push-limitsS08-05-push-limits: Push LimitsCleanup after a push that failed, the size cap of landing.git, and the time and memory bounds of the git gateway., “Bounds”).
Time and the git binary
Section titled “Time and the git binary”- Record the wall-clock time of the slowest pushes the caps allow,
against the 5 minute watchdog: 256 MiB of empty zlib stored blocks
behind one entry, 256 MiB of trees under
--strict, and 256 MiB of bases that--fix-thincopies in fromexport.git, each just under its cap. Each one must finish well inside the watchdog. - Start
wb-hostdwith a stand-in git that ignoresGIT_ALLOC_LIMITand exits with 0, one that exits with 128 and another message, and one that hangs past the 5 s timeout, and see every push refused with the reason.
The git data scope of S08-workspace-and-git
Section titled “The git data scope of S08-workspace-and-git”Each refusal with its rule in the audit log:
- Start a session with an untracked file that holds a token the scanner
knows, and a tracked binary file changed to hold one. See the
untracked file absent from the guest, the tracked file at its
HEADversion, and both listed in the summary. - Start a session with an untracked symbolic link to a host file, and see a link in the guest whose target is the string only, with none of the file’s content.
- Give the host repository remotes with a token in the user info, an
ext::URL, agit+ssh://URL, an IP-literal host and a URL that doesn’t parse. See the guest get only cleanedhttps://URLs, and the rest listed as withheld. - Start
wbandwb-hostdwith a stand-in git that reports a version below the minimum, and one that reports a release candidate of the minimum, and see both refused with the reason. - Fill
landing.gituntil its size plus the worst case of one push is over the cap, and see the next push refused beforereceive-packstarts. - Remove a ref from the selection, start a session, and see a fetch of that ref’s tip commit by ID refused, and the ref not advertised.
Status: Draft