Shipkeep is an open-source platform to deploy apps on your own servers. Since last week it also builds them: push to a Git repository, and the server that runs the application builds its image, from a Dockerfile or with Railpack or Nixpacks.
That means running a repository's build on a machine that also runs other applications, and on a single machine, the control plane itself. The repository is untrusted input, and so is everything in it.
I planned the sandbox around one question: what can a build reach on the host? Rootless BuildKit, its own account, its own network rule. Then an audit asked a different question, about one line I had not thought of: who decides which program reads the Dockerfile?
The sandbox
The server installer sets up a builder that has nothing to do with Docker:
- BuildKit v0.35.1, rootless, run by
rootlesskitas its own account,shipkeep-build. That account is in no group that reaches Docker. Its socket can be used by the agent's account and nothing else. - Its own user namespace, with 65536 subordinate ids placed after every range already given. Ubuntu's cloud images give 100000–165535 to the
ubuntuaccount, which I found in the lab. - Its own resources: a systemd slice capped at half the memory, and an OOM score that makes it the kernel's first choice when memory runs out.
- Its own network rule, an nftables chain matched on the account's uid. A build reaches the internet, the name servers on port 53, and the server's own Caddy on 443, which a single machine needs to push to its registry. Everything else on the server and its private networks is refused.
In the lab, a build reached the internet over plain HTTP. It did not reach 169.254.169.254, a private registry, or the server's own SSH port. BuildKit's own push to a private registry failed the same way: dial tcp 192.168.64.3:5000: i/o timeout.
What a Dockerfile can ask for
A Dockerfile can ask BuildKit for more than the defaults. Three requests matter here, and CI now builds each of them on every pull request, against a real BuildKit:
| Dockerfile step | BuildKit's answer |
|---|---|
RUN --network=host | network.host is not allowed |
RUN --security=insecure | security.insecure is not allowed |
RUN --mount=type=bind,source=/var/run/docker.sock | "/var/run/docker.sock": not found |
The first two are entitlements, and the agent asks for none. The third one never reaches the host at all: a bind mount reads from the build's context, the repository, never from the server.
Each step would print reached the host if it ran, and the test checks that the phrase never appears. The words are split in the command, echo "reached" "the host", so BuildKit's echo of the command line cannot produce the phrase by itself.
The line I had not thought of
A Dockerfile can start with a comment like this one:
# syntax=docker/dockerfile:1 It names an image, a frontend, and BuildKit runs it to interpret the rest of the file. Most people write that line to get the latest Dockerfile features. Nothing requires the image to be Docker's.
The frontend runs inside BuildKit with the build's session. That session is where the build gets its secrets, such as the short-lived token that fetched the repository, and the credentials to push the image. A repository that names its own frontend chooses the program that sees those.
The audit pointed at two ways in. The # syntax= line itself, which BuildKit honors by default. And BUILDKIT_SYNTAX, a build argument with the same effect: a repository could set it in its shipkeep.yml. On the Nixpacks path, the agent removed BUILDKIT_* names from the arguments it generated, then merged the repository's explicit arguments back in after that filter.
The audit was careful about its limits. It showed that the setting was accepted and reached BuildKit. It did not run a hostile frontend, and it did not take any credential.
There was already one mitigation: the Git token reaches BuildKit as a session secret under a random name. The issue asked for a fix that would not depend on that name staying hidden.
Two fixes, one rule
Reserved arguments are refused. The API rejects any build argument whose name starts with BUILDKIT_, with a reserved_build_arg error, before anything is deployed. The agent refuses them too, whatever the control plane sends.
The builder only runs two frontends. The installer writes them into BuildKit's own configuration:
[frontend."dockerfile.v0"] enabled = true [frontend."gateway.v0"] enabled = true allowedRepositories = ["docker.io/docker/dockerfile", "ghcr.io/railwayapp/railpack-frontend"] # syntax=docker/dockerfile:1 keeps working. Railpack's frontend, which the agent pins by digest, keeps working. Any other # syntax= fails the build with BuildKit's own message: … is not an allowed gateway source. An untrusted frontend never runs at all.
CI's BuildKit reads these sections from the installer itself, so the tests run under the policy the servers get. A test Dockerfile that names ghcr.io/shipkeepdev/not-a-frontend:1 is refused there, on every pull request.
One more name a build could compute
A review of the same build code found a smaller cousin of this problem. Build caches were isolated per application, by a namespace computed from the application's registry repository with a plain hash. A build that knew another application's identifiers could compute that name and write into its cache.
The namespace is now an HMAC of the repository, under a 32-byte key that only the agent holds. Dockerfile builds had no namespace at all before; they have one now.
What runs on every pull request
Besides the hostile Dockerfiles, CI builds a Python, a Go and a PHP application, each with Railpack and with Nixpacks, from the commit under test, and checks that the registry holds each pushed digest. In a local run from a cold cache, the six builds took 3 min 36 s in parallel. Node, and a plain Dockerfile, are covered by other tests.
Two things remain open:
- Ubuntu's restriction on unprivileged user namespaces (
kernel.apparmor_restrict_unprivileged_userns). The lab hosts do not have it, sorootlesskit's AppArmor profile still has to be checked on a real Ubuntu 24.04 VM. - Upstream images by tag. The builder and runtime images that the pinned Railpack and Nixpacks versions build from are referenced by tag upstream.
What I take from it
- "What can the build reach?" was the wrong first question. The better one is "who interprets the build?". It came from reading the input format, not the sandbox.
- Turn off what you don't use, in the component that enforces it. Filtering arguments in the agent had a gap. BuildKit's own allowlist applies however the frontend is named.
- A test that proves a refusal needs a phrase the refusal cannot print. Otherwise the error message itself can make it pass.
Where it stands
- Merged as #536, #542, #551 and #561, and shipped in v0.1.0-beta.2. A server installed earlier gets the frontend policy with
install.sh --migrate yes. - The design is in ADR 0030. The spec keeps an open question: should other frontends be allowed one day, and with which session capabilities?
Where you can help
- You have a disposable Ubuntu 24.04 VM with the default AppArmor settings: install a server and run a build. That is the one check the lab cannot do.
- You know BuildKit's session or gateway API well: read the builder's configuration in the installer and tell me what a frontend I allowed could still reach.
- First contribution: the good first issues each say what to change and when it is done.
And a question for the comments: do the builders you use let a Dockerfile's # syntax= line pick any image?

