S08-06 - Landing on the Host
Purpose: How wb land and wb diff bring a session’s work into
the user’s repository, and the checks that keep that fetch from running
anything.
Design
Section titled “Design”Landing on the host
Section titled “Landing on the host”wb land <session> runs git fetch from the landing repository into
wb/<session-id> in the user’s repository. It uses the git binary of
S08-08-host-gitS08-08-host-git: Host GitWhich git binary runs on the host, the oldest version Wraith Box accepts, and where that is checked.. It never checks out, merges, or runs anything. A
fetch only writes objects and refs.
landing.git is only ever the remote of a fetch. wb never runs git
with it as its repository, or with any other directory wb-hostd can
write (S04-06-git-confinementS04-06-git-confinement: Git and the `wb-hostd` ProfileHow git runs on data from the guest, what the wb-hostd profile lets it write, and what wb takes from wb-hostd., “wb takes no path, URL or program from wb-hostd”).
The user’s repository
Section titled “The user’s repository”wb land and wb diff resolve the user’s repository from the current
directory, by the rules wb claude uses (S05-04-namingS05-04-naming: NamingHow wb identifies a project, a session and its branch, and how projects are registered, checked, moved and removed.). They
never take it from a path in state.db or from wb-hostd. They
refuse:
- a session that doesn’t belong to that project;
- a project key under
<data>,<config>or<logs>.
The landing path
Section titled “The landing path”wb derives the landing repository’s path itself, as
<data>/projects/<project-id>/landing.git. It checks the project ID
against the project ID format first. It compares that path with the
one wb-hostd reports, and refuses on a mismatch.
wb never passes git a path or URL that wb-hostd handed it. So a
compromised wb-hostd can’t make it fetch from an ext:: URL or
another repository (SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts.).
Checks before the fetch
Section titled “Checks before the fetch”Before each fetch from landing.git, wb checks it, and refuses the
command when a check fails:
- With
lstat, each of these is a directory and not a symbolic link: the projects root, the project directory,landing.git,objects,objects/infoandrefs. objects/info/alternatesholds exactly one line,<real path of the projects root>/<project-id>/export.git/objects.- There is no
commondir,gitdir,info/grafts,shalloworobjects/info/http-alternates. - There is no ref under
refs/replace/, loose or inpacked-refs.
wb-hostd can write landing.git, so these checks only narrow what it
can do. It can swap the directory between the check and the fetch. It
can rewrite objects/info/alternates and the refs. And it can put
objects of any project in the session’s branch (T16-hostd-landingT16-hostd-landing: A compromised `wb-hostd` decides what
`wb land` brings inwb-hostd faces the guest, and it may read every project's export.git and write every project's landing.git (S04-03-self-sandboxing, "Each host daemon is self-sandboxed").).
Object checks
Section titled “Object checks”The fetch checks every object it receives, with these settings on git’s command line:
fetch.fsckObjects=trueandtransfer.fsckObjects=true;- each check that
receive-packsets to an error, set to an error here too (fetch.fsck.<msg-id>=error).
A failed check refuses the land, and the fetch doesn’t update a ref in
the user’s repository. This repeats the checks of the push, for objects
that reached landing.git another way (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.).
Fetch settings
Section titled “Fetch settings”The fetch runs with core.hooksPath=/dev/null,
maintenance.auto=false and gc.auto=0 on git’s command line. Git
then doesn’t run a hook or maintenance in the user’s repository during
it.
Only the local transport is allowed:
GIT_PROTOCOL_FROM_USER=0in its environment;protocol.allow=never, followed byprotocol.file.allow=always, on its command line.
Every other transport is refused, ext::, https, ssh and git
among them. With GIT_PROTOCOL_FROM_USER=0 and without
protocol.file.allow, git 2.54.0 and 2.56.0 refuse the local fetch too
(transport 'file' not allowed).
The fetch runs with --no-recurse-submodules.
fetch.recurseSubmodules defaults to on-demand, and
protocol.file.allow=always would then also apply to submodule
fetches of commits the guest chose.
Protected configuration
Section titled “Protected configuration”The fetch starts upload-pack in landing.git, whose configuration
wb-hostd can write. That relies on git’s rule for protected
configuration. upload-pack runs uploadpack.packObjectsHook only
when the setting comes from the system, global or command-line
configuration, never from the repository’s own (git-config(1),
“Protected configuration”, and git-upload-pack(1), “SECURITY”).
wb diff
Section titled “wb diff”wb diff reads the session’s commits the same way, and writes nothing
in the user’s repository.
- It creates a scratch bare repository with
git init --bare --template=. The repository is in a new directory, readable only by the user, in the user’s temporary directory, outside<data>,<config>and<logs>. - It writes the scratch repository’s
configitself. - It writes an alternates entry to the user repository’s objects, so the session’s base isn’t copied.
- It runs the same checks and the same fetch into the scratch repository.
- It runs
git --no-pager diffandgit --no-pager logthere, with--no-ext-diff,--no-textconvandcore.hooksPath=/dev/null.git logalso gets--no-show-signature. - It removes the scratch repository when it is done.
Every git command in the scratch repository runs with
GIT_NO_LAZY_FETCH=1. A missing object then never makes git fetch it
from a promisor remote of the user’s repository.
Status: Draft