Build executor
A build_image job turns one verified source snapshot into one pushed OCI image. It publishes that image’s digest through the lease-fenced publish_release_artifact contract (migration 0021). This document covers the current trust boundary and what is not built yet.
Flow
- Targeting (
crates/pushleft-scheduler/src/builds.rs). A queuedbuild_imagejob stays untargeted until itssource_snapshotsrow exists. That row exists only after the ingester has verified and stored the exact bytes. The scheduler checks that the job’s provenance (snapshot, digest, plan hash, repository, artifact ID) matches the snapshot. A mismatch fails the job. It then picks an active, schedulable node in thebuildpool, seen in the last 60 seconds, whose capabilities include{"oci_build":1,"isolated_build":1,"vm_isolated_build":1}.vm_isolated_buildis required unlessPUSHLEFT_REQUIRE_VM_ISOLATED_BUILD=false(development and macOS test hosts, which have no KVM). The gateway applies the same rule when it leases a build and serves its source (pushleft_core::required_build_capabilities). It usesselect_node_in_poolwith a nil network segment, because build nodes never join tenant networks. It prefers the node that ran the project’s last completed build, because that node holds the project’s build cache. It addsproject_id,archive_bytes,manifest_yaml,cache(read_writefor production,readfor previews) and placement to the payload. No credential is ever written tojobs.payload. - Lease (
crates/pushleft-agent-gateway/src/build.rs). Builds for inactive deployments are not leased. A lease carries no registry credential; the agent asks for a push token when it pushes (Registry tokens). - Execution (
crates/pushleft-agent/src/build.rs). The agent advertisesoci_build/isolated_buildonly when it runs with--buildkit-image <repo@sha256:…>. It advertisesvm_isolated_buildonly when, in addition,/dev/kvmexists and--build-runtimenames a runtime that Docker lists indocker infoas a Kata runtime. At start, before it leases anything, the agent sweeps what a killed agent left behind: every container and network labelledcom.pushleft.managed=buildand everything under--build-root. It then installs the build egress table (below). Either failing stops the agent. For each attempt it does the following:- It creates a fresh 0700 workspace under
--build-root(also 0700). Any leftover from a crashed attempt is removed first. - It downloads the archive from
POST /v1/agent/jobs/{id}/source. It retries only on503, with backoff.409means the lease is lost. Every other status fails the attempt. It requires the exact media type,Content-Lengthand identity headers. It bounds the body to the leasedarchive_bytes(at mostpushleft_source::MAX_ARCHIVE_BYTES). It then checks the SHA-256 against the lease payload; the response headers alone are never trusted. - It calls
pushleft_source::extract, which runsverifyand then writes fresh files with explicit 0644/0755 modes. - It re-applies the build egress table. If that fails, the attempt fails (
build_firewall_unavailable) and no container starts. - It creates the per-build network
pl-build-<job>-<lease>with the Linux bridge nameplb-<11 hex>, which the egress table matches. - With a build cache configured, it attaches this project’s cache (Build cache).
- It builds the Dockerfile with BuildKit (see below): the root
Dockerfileand context, or the manifest’sbuild: { dockerfile, context, target }(manifest). The paths must be relative and inside the checkout. They must name a regular file and a directory in the extracted source. The image is written as an OCI tarball to the container’s stdout. - It treats that tarball as untrusted. Only
oci-layout,index.jsonandblobs/sha256/<hex>entries are accepted, and each blob is hash-checked as it is written. Exactly one OCI image manifest is required. The config must beapplication/vnd.oci.image.config.v1+jsonor the Docker equivalent, and every layer one of the six standard OCI/Docker tar layer types (plain, gzip, zstd). A descriptor withurls(a foreign layer) is refused. - It scans the verified blobs with Trivy and makes the SBOM (Image scan, SBOM and signature). A blocked image is never pushed.
- It asks the gateway for a registry token (
POST /v1/agent/registry/token, mTLS) for the lease’s repository. Then it pushes the blobs and the manifest by digest itself with that bearer token. The digest the registry reports (Docker-Content-Digeston the PUT, then a HEAD by digest) must equal the manifest digest. A local image ID is never used. - It pushes the SBOM as an OCI referrer of the image. It gets the platform signature of the digest from the gateway and pushes it as a cosign signature.
- It reports
{"image_digest":"sha256:…","image":"<repo>@sha256:…","log":{…},"scan":{…},"sbom":"sha256:…","signature":"sha256:…"}. - A drop guard runs
docker rm -fon the container, removes the per-build network and the workspace. This happens on success, on failure, on the 30-minute timeout, and when the attempt future is dropped (lease loss, SIGINT). If the agent itself is killed, the container still dies: its entrypoint istimeout -s KILL 1860, and the next agent start sweeps it.
- It creates a fresh 0700 workspace under
- Publication (gateway
complete_job). In the same transaction that records the result and completes the job, and before the lease is cleared, the gateway callspublish_release_artifact(org, job, token, node, artifact, repo@digest). It then appends abuild_completeddeployment event. The function can reject the call: wrong repository, a different digest after a prior publication, a stale or non-build node, or a lost lease. Then the gateway returns409 artifact_rejectedand commits nothing. A failed attempt appends abuild_failedevent with the bounded log, and the normal attempt/backoff logic runs. Migration0024creates the NOLOGIN rolepushleft_agent_gatewaywith EXECUTE on the function. Operators grant this role to the gateway’s BYPASSRLS login role.
Build logs are a tail of at most 16 KiB with 2 KiB lines. Control characters are stripped. total_bytes, dropped_lines, truncated_lines and truncated report every cut. The log goes into the job result and the deployment event. Logs are not streamed live yet. They appear when the attempt finishes.
Superseded builds
A new production deploy cancels the older deploys of its environment that are still queued or building (decided 2026-11-10). A queued build is never leased. A running build loses its lease at the next heartbeat, within about 12 seconds: the agent stops it and removes its container, network and workspace. The older deploy gets a deployment_cancelled event, and its pl up ends with exit code 0, because the newer deploy carries the change.
- A deploy past its build (
deployingor later) finishes. The release run may be migrating a database. The newer deploy then supersedes it. - A
pl up --only <role>deploy cancels nothing: it carries one role’s change. - Previews are not cancelled.
So a CI pipeline does not need its own deploy queue, such as a GitLab resource_group.
Build cache
Decided 2026-10-20: a cache per project, so a second build of the same project does not start from nothing. Each project’s BuildKit cache lives on the build node and, as a snapshot, in the blob store.
Fresh OS packages despite the cache. A cached RUN apt-get upgrade (or apk upgrade) layer is replayed from an old build, so fixed distribution packages never arrive and the image scan keeps reporting fixable findings. Every build passes the build argument PUSHLEFT_OS_REFRESH, set to the UTC date (2026-11-07). Declare it right before the upgrade step, and that layer is rebuilt at least once a day while every layer above it stays cached:
ARG PUSHLEFT_OS_REFRESH
RUN apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/*
A Dockerfile that does not declare it is unaffected. A build.args entry of the same name in the manifest overrides it.
How a build uses it. BuildKit’s own state stays per build (tmpfs, discarded). The cache is BuildKit’s local cache format (an OCI layout written by --export-cache type=local,mode=max), one per project, under PUSHLEFT_BUILD_CACHE_ROOT/<project id>/gen-<lease>:
| Build | Mounts | buildctl |
|---|---|---|
production (cache: read_write) | the project’s production cache read-only at /cache/in, plus a new empty directory at /cache/out | --import-cache type=local,src=/cache/in --export-cache type=local,dest=/cache/out,mode=max,ignore-error=true |
preview on an agent advertising build_cache_scopes (cache: read_write, cache_scope: preview) | the project’s preview cache (<project id>-preview) read-only at /cache/in, plus /cache/out | the same |
preview on an older agent (cache: read) | the project’s production cache read-only at /cache/in | --import-cache type=local,src=/cache/in |
Two caches per project (decided 2026-11-05), as GitLab CI keeps protected and unprotected branches apart. Until then only production builds wrote a cache. So a project deployed only to previews started every build cold. Previews now write a cache of their own. Production builds never import it, for two reasons. Members can push preview branches but not the production branch. A layer’s cache key also does not cover every input of the layer, such as network responses during a RUN. So a preview could seed what production builds use. An older agent keeps one directory per project. So the scheduler gives a preview write access only on agents that advertise build_cache_scopes. On other agents, a preview reads the production cache, as before.
A writing build first builds without --export-cache. It exports the cache in a second buildctl run in the same container only if a Dockerfile step ran. A build in which every step was cached keeps the cache it imported and skips the export (about 40 s on a large image). The second run reuses the container’s BuildKit state, so it only solves and exports.
After a writing build succeeds, the agent checks the export before it keeps it:
- only
index.json,oci-layoutandblobs/sha256/<hex>regular files (no symlinks); - every blob’s SHA-256 equal to its name;
- every descriptor reachable from the index present with its size;
- at most
PUSHLEFT_BUILD_CACHE_PROJECT_MAX_MB.
A valid export becomes the project’s new cache. Any other export is dropped and the old cache stays. Before every build, the agent takes a fingerprint of the read-only cache: path, size, inode, mtime and ctime of every entry. Userspace cannot set ctime back. After the build, the agent compares the cache with the fingerprint. If anything changed, it deletes the cache. So even a guest that bypassed the read-only mount could not leave a change behind. A cache failure never fails the build: it builds without the cache, and the report says why.
Where it is kept.
- On the build node:
PUSHLEFT_BUILD_CACHE_ROOT(0700, its own partition). WithPUSHLEFT_BUILD_CACHE_QUOTA=xfs, each project directory gets an XFS project quota of twice the per-project limit (the old and the new copy during a swap). The agent refuses to start if the partition does not enforce project quotas. Before and after each build, the agent evicts the least recently used caches of other projects. It stops when all caches fitPUSHLEFT_BUILD_CACHE_MAX_MB(default: no limit) and the partition has room for two more per-project maximums. The cache of the build that is running is never evicted. After each build and at agent start, the agent also removes every cache unused forPUSHLEFT_BUILD_CACHE_IDLE_DAYS(default 14). A deleted project never builds again, so its cache goes within that time. A later build of an idle project only starts cold. - In the blob store: after a writing build changed the cache, the agent uploads it as a tar through the gateway (
PUT /v1/agent/jobs/{id}/cache). The gateway keys itcache/<org>/<project>/<uuidv7>-<sha256>.tar(a scoped preview’scache/<org>/preview/<project>/…) in the blob store’scacheuse (retention.md) and keeps the newest two per project. A new node, or a node that evicted the project’s cache, has no local cache. Before it builds, it asks the gateway for the newest snapshot (POST /v1/agent/jobs/{id}/cache). It checks the digest and the layout, then uses it.
Build nodes hold no bucket credential. The gateway serves and stores snapshots only for the caller’s current targeted build_image lease, the same check as the source download. It takes the project and the scope from the lease’s deployment and job, never from the request. A production lease always gets the production cache, and a scoped preview gets its preview cache. Any other preview reads the production cache, and a write is refused (403 cache_read_only). Snapshots are not sealed per organization. They hold the same kind of bytes as sources and image layers, and the blob store holds them the same way.
Placement. The scheduler prefers the node that ran the project’s last completed build. That node can have other builds queued or running while another eligible node is free. Then the build waits up to 120 seconds, counted from source verification. It then takes the free node, which warms from the snapshot. With no free alternative, it queues on the cache node at once. An unavailable cache node is skipped without waiting. The 120 seconds are far below the stale-deployment reaper’s minimum (PUSHLEFT_REAP_QUEUED_AFTER ≥ 600 s).
Report. The build result and the build_completed event carry cache: mode, imported (local, snapshot or none), exported, uploaded, bytes and build_ms. Evictions are logged on the build node only; they name other projects.
Rust and sccache. Layer caching covers what a Dockerfile separates into layers. Put dependency builds in their own step (for example cargo chef cook before COPY . .). That step is reused while Cargo.lock is unchanged. BuildKit cache mounts (RUN --mount=type=cache,..., which sccache or a cargo target directory would use) are not kept. They live in BuildKit’s state, which stays per build, and the local cache format does not export them. To keep them, Pushleft would have to keep BuildKit’s whole state directory per project (on Kata, over virtio-fs). Pushleft does not do this.
Settings on a build node (/etc/pushleft/agent.env):
| Setting | Default | Meaning |
|---|---|---|
PUSHLEFT_BUILD_CACHE_ROOT | unset (no cache) | absolute path of [A-Za-z0-9/._-], ideally its own XFS partition |
PUSHLEFT_BUILD_CACHE_PROJECT_MAX_MB | 10240 | one project’s cache at most; a larger export is dropped |
PUSHLEFT_BUILD_CACHE_MAX_MB | no limit | all projects together (LRU beyond it) |
PUSHLEFT_BUILD_CACHE_IDLE_DAYS | 14 | a cache unused this long is removed (deleted projects’ too) |
PUSHLEFT_BUILD_CACHE_QUOTA | none | xfs: per-project XFS project quota, checked at start |
On the gateway: a cache blob store (PUSHLEFT_CACHE_S3_*, the shared PUSHLEFT_BLOB_S3_*, PUSHLEFT_CACHE_LOCAL_ROOT or PUSHLEFT_BLOB_LOCAL_ROOT), and PUSHLEFT_GATEWAY_CACHE_MAX_MB (default 10240) for the largest snapshot it accepts. Without a blob store, builds use only their node’s local cache. PUSHLEFT_CACHE_LOCAL_ROOT selects only the cache backend. PUSHLEFT_BLOB_LOCAL_ROOT also changes source and other blob backends. So do not set the shared variable just to enable caching on an existing installation. Allow tar headers above the node’s per-project limit when setting the gateway limit. The agent also checks a downloaded tar against its per-project limit, so avoid sizing exports right at that limit.
npm run test:build-executor measured BuildKit time on Docker Desktop (rootless BuildKit), with a fixture whose RUN step sleeps 8 seconds:
- cold 9.9 s, warm 1.8 s;
- preview 1.8 s (hit, nothing written);
- another project with the identical step 10.0 s (no hit);
- a node without the local cache, warmed from the snapshot, 1.9 s (hit).
These times are not measured on Kata.
Role images
A role with its own build: gets its own image (decided 2026-11-15, after Phase previews spent about 5 minutes on 5 unchanged role images):
- In parallel. Role images build at the same time as the release image, at most
PUSHLEFT_BUILD_PARALLELat once (1 to 8, default 2). Each runs in its own BuildKit container on the build’s network, with the build’s limits. Its live log lines start with[<roles>]. - Its own cache. Each role build has a cache directory
<project>[-preview]-role-<key>, where the key is a hash of itsbuild:. The scope, mode, quota and LRU rules are the release cache’s. The cache stays on the node: no snapshot goes to the blob store. - Reuse when unchanged. A build that may write its cache records the image it pushed, with a digest of its inputs: the
build:, the Dockerfile, every path, mode, content and link target in the context, the root.trivyignore, the BuildKit image, the runtime, the scan policy and the UTC day. The next build with the same digest takes that image, SBOM, signature and scan, if the registry still holds the image. It doesn’t build, scan or push it again. Because the day is in the digest, an image is reused on the day it was built only.
Build reuse
Decided 2026-11-05: a deployment whose build inputs equal a build the organization finished in the last 24 hours takes that image and does not build. A tenant that deploys one commit to four environments in three projects built the same image for about 10 minutes.
Same inputs. When it verifies an upload, the API also hashes the tree without .pl.yaml (tree_sha256 on the claim and the snapshot). The hash covers the path, mode and content of every other file. Two deployments match when the tree digest and the plan’s build: section (dockerfile, context, target, test, args) are equal. Roles, domains, environment and project can differ. Builds get no per-environment values other than build.secrets, so nothing else goes into a build. A build with build.secrets is not reused: each deployment builds it, from a layer cache that only builds with the same secret values share. The build context does not include .pl.yaml, because the manifest differs per environment. A step that copies the whole context gets the same cache key in each environment. Base images are the exception. FROM tags resolve at build time, so the base of a reused image is at most 24 hours older than a new build would get.
Who may reuse what. publish_reused_artifact (migration 0137) runs in the transaction that stores the verified snapshot. It looks for the newest matching build artifact of the organization whose image retention has not released yet:
- a preview reuses any match;
- a production deployment reuses only a production build, because its cache never held what a preview wrote (Build cache). The recorded scan must pass this project’s gate: no fixable critical finding, or the organization’s policy is
warn, or this project has an active waiver.
A match creates a release artifact with source = 'reuse' that names the original image (it stays in the building project’s repository). It also creates the role instances and their ensure jobs, and completes the build job without a node, like deploy by digest. The deployment gets a build_completed event with the original’s scan, SBOM and signature, plus reused_from (artifact, deployment, project). No match leaves the build job queued for the scheduler. Node pull grants follow the artifact’s image, so the deployment’s nodes may pull from the other project’s repository. Retention deletes the image (in the building project’s repository) through the artifact naming it that is released last, the original build or a reuse. So the image goes even after the building project was purged. A purge waits for the image of a reuse artifact like a build’s (migration 0139).
To build once for several environments, deploy a production first: the others reuse it. A preview first makes every production build again.
Image scan, SBOM and signature
Every build gets an image scan, an SBOM and a signature with a platform key (built 2026-10-30). They run in the build lease, after the image is made. The platform’s own CI uses the same tools: Trivy for the scan and a CycloneDX SBOM, cosign for the signature.
Scan (crates/pushleft-agent/src/build_scan.rs). Trivy parses tenant content, so it never runs on the host. It runs from the digest-pinned image PUSHLEFT_BUILD_SCAN_IMAGE with the build runtime (its own Kata VM). It has --network none, a read-only root and no capabilities, and the verified blobs mounted read-only as an OCI layout. It scans for vulnerabilities only, at all severities, with the full package list. A second container converts the same report to the CycloneDX SBOM (trivy convert, as scripts/runtime-image-scan.sh does). A report that is not a container image report, or has an unknown severity, fails the attempt (image_scan_failed, retryable).
Vulnerability DB. A separate container refreshes the Trivy DB and Java DB under <build root>/.scan-db before each scan (a no-op while they are fresh). It sees no tenant content, so a tenant image cannot change the DB that scans the next tenant. The scan mounts the DB read-only and runs offline. The DBs take about 3 GiB; the agent start sweep keeps them.
Gate. Only production builds are gated (decided 2026-10-30). A preview or test environment build records its findings and deploys, so branch deploys never wait on security fixes. In a production build, a CRITICAL finding with a fixed version fails the build: image_scan_blocked, permanent, with up to ten vulnerability IDs in the message. The repo’s .trivyignore does not change this (decided 2026-11-07: “Suppress, gate unchanged”). A listed fixable CRITICAL still counts in critical_fixable and still blocks, and the message says how many of the blocking findings are listed and that only pl security waive lifts the gate. See Findings.
Daily re-scan. A production release keeps the scan of its build, but vulnerability databases change after it went live. Once a day, the scheduler gives each live production release whose last check is a day old a rescan_image job on a build node. The node fetches only the release’s CycloneDX SBOM from the registry, with a pull token for that job. It scans the SBOM with a fresh vulnerability DB, in the same isolated container as a build’s scan. The image itself is not pulled. The result is recorded as image_rescanned on the deployment, and the console shows the newest check (build or re-scan). A re-scan can find fixable CRITICAL vulnerabilities. Then the owners and admins of the organization get one email for each release and set of findings (migration 0107). The email lists the findings. Each one, and its button, links to the console’s Findings page filtered to that deployment. The email uses the same layout as the ops alert mails (crates/pushleft-api/src/alert_mail.rs), with a plain-text alternative. The release keeps running. The next production deploy is gated by its own scan, and a waiver overrides that gate as for any build.
Pre-built images (decided 2026-11-07, Waseem: report only; migration 0173). A role with its own image: and a top-level image: deployment run images Pushleft did not build, so they have no SBOM. Once a day, each such image of a live production deployment gets a rescan_image job with prebuilt_image in its payload. The build node pulls the image with a pull token for that job, saves it as a tar in the job’s workspace, and scans the tar in the same isolated container. Then it removes the image from the node. The gateway records prebuilt_image_scanned with the image and its roles. It never records image_rescanned, so the release’s scan status in the console does not change. The findings are stored apart from the release’s, with the image in image_scan_findings.image, and the Findings page shows the image on each one. New fixable CRITICAL findings send the same email, which names the image and says that no gate applies. Nothing blocks a deploy: the image stays the deployer’s responsibility. No .trivyignore applies, because there is no source.
SBOM of a pre-built image (decided 2026-11-10, Waseem: kept and shown in the console). The same scan lists every package, and the agent converts its report to a CycloneDX SBOM. It sends the SBOM to the gateway (POST /v1/agent/jobs/{id}/sbom, authorized by the scan’s lease). The gateway takes the image name from the job, never from the request. It keeps the newest SBOM per deployment and image (image_sboms, migration 0208) and drops those of deployments that are no longer live. The console’s findings page of a deployment lists them under Package lists, with a download (GET /v1/deployments/{id}/sboms and GET /v1/deployments/{id}/sbom?image=). A built image keeps its SBOM in the registry as an OCI referrer.
Waivers. An admin can let a project’s production builds through for 1 to 168 hours, with a reason: pl security waive --reason "<why>" --hours 24. Use pl security waivers to list them and pl security revoke <id> to end one (API /v1/projects/{project}/security/waivers, migration 0105). Each waiver is audited (image_scan_waived, image_scan_waiver_revoked). The build job records the waiver it used (image_scan_waiver), and its findings are still reported. Unfixed CRITICAL and all HIGH, MEDIUM, LOW and UNKNOWN findings are recorded only. The platform CI rule (--ignore-unfixed) works the same way, narrowed to CRITICAL. The organization setting image_scan_policy (migration 0104, default block) can be warn: the build then records the findings and deploys. Only an operator sets it:
UPDATE organizations SET image_scan_policy = 'warn' WHERE id = '<org id>';
The scheduler copies it into the job payload (image_scan) when it targets the build. Anything other than warn blocks.
SBOM. The agent pushes the SBOM as an OCI 1.1 artifact (artifactType: application/vnd.cyclonedx+json) whose subject is the image manifest. zot serves it through the referrers API: GET /v2/<name>/referrers/<image digest>.
Signature. The agent asks the gateway, over mTLS, for a signature (POST /v1/agent/registry/signature {"repository","digest","sbom"}). The gateway signs only while the node holds a live build_image lease for that repository, the same bound as the push token. It writes the cosign simple-signing payload itself: the repository, the digest, and the SBOM digest as the sbom annotation. So a node cannot get a signature that names another repository. The agent pushes the signature in cosign’s format, tag sha256-<hex>.sig. The build node never holds the key.
Report. The result and the build_completed event carry three fields:
scan:critical,high,medium,low,unknown,suppressed,critical_fixable,policyandtrivyignore(the list the scan applied, below);sbom: the referrer’s manifest digest;signature: the signature manifest digest.
The agent’s scan also lists the findings (below). The gateway stores that list apart and leaves it out of the event and the job result. A build the gate blocked carries the same scan on its build_failed event. The console event log shows the event and its full payload.
Findings
The counts say how bad an image is; the findings say what to upgrade. Each scan (a build’s, or the daily re-scan’s) lists its CRITICAL and HIGH findings, and its MEDIUM findings that have a fixed version. The list holds at most 500 entries and 32 KiB, most severe and fixable first. LOW, UNKNOWN and unfixed MEDIUM findings are only counted (decided 2026-11-05). A Debian-based image carries hundreds that nobody can act on, and listing them overflowed the build result. Each finding has the advisory ID, severity, package, installed version, fixed version and title. It also has the Trivy target with its package type: the OS, such as debian 12.11, or a lock file, such as app/Gemfile.lock. The whole job result must also fit the gateway’s 64 KiB cap. If the log tail and the list do not fit, the agent halves the list, least severe first, until the result is under 60 KiB. A cut list sets findings_truncated in scan. Built 2026-11-05 after it took a manual Trivy run to learn that GHSA-f3w6-w445-fwh9 was activestorage 8.1.3.1, fixed in 8.1.4.1.
- The repo’s
.trivyignore(built 2026-11-07). A project that commits a root.trivyignoreof no-fix Debian CVEs, each with a reason, saw every one of them listed on its releases until then. At build time the agent reads.trivyignorefrom the source root, and from the build context directory (build.context) when that is another directory. It parses them as the source scan does: one ID per line,#comments, the reason after#, at most 1 MiB, regular files only, no links. A finding whose ID is listed is kept and listed (after the open ones) withsuppressed_by=.trivyignore: <reason>orapp/.trivyignore: <reason>. It counts only insuppressed, not incriticaltounknown, and the re-scan never alerts on it. The gate is unchanged: a listed fixable CRITICAL counts incritical_fixableand blocks a production build; only a waiver overrides it. The list the build applied (IDs andsuppressed_by, valid IDs only, at most 500 entries and 16 KiB) goes inscan.trivyignoreon the result and thebuild_completedevent. The daily re-scan has no source, so the scheduler puts that list in therescan_imagepayload (trivyignore) and the agent applies it the same way. The re-scan result addscritical_fixable_open, the fixable CRITICAL findings not listed; the gateway alerts on those only. - Storage. The gateway writes them to
image_scan_findings(migration0138, tenant RLS) in the transaction that records the build or re-scan. They replace the deployment’s earlier rows for the same image (imageis empty for the release image, or the pre-built image, migration0173). Entries with an odd ID, an unknown severity or no package are skipped, and the build does not fail. A reused build’s findings are copied to the reusing deployment. Rows stay for the newest 10 deployments of each environment and every live one, and go with the deployment when its project is purged. An agent from before 0138 sends no list: its deployments show counts only until the next scan (production: the daily re-scan).suppressed_by(migration0171) is null for an open finding. - API (viewers).
GET /v1/security/findings?project=&environment=&severity=critical,high&open=truereturns{"deployments": [...]}, one group per deployment: project, environment, status, the image check (security, as in the deployment list), the project’s active waiver, andfindings.open(the default) means each environment’s live deployments, plus its newest failed deployment when the scan gate blocked it and nothing went live after it.open=falsegives every deployment that still has findings stored. A severity filter drops groups left without findings. Withopen, findings the repo’s.trivyignorelists are left out, as suppressed source findings are, except a fixable CRITICAL: it still blocks production, so it stays in view with itssuppressed_by.GET /v1/deployments/{id}/findingsreturns one deployment’s group, whatever its status. Each finding hasfixable,suppressed_byand anadvisory_urlbuilt from the ID (GitHub for GHSA, NVD for CVE, else null), never from the scanned image’s text. - Console. The Findings page (organization menu) shows the groups, with critical fixable rows highlighted. It shows the version to upgrade to, whether a production deploy was blocked, and an active waiver. The image block’s header says “N suppressed in the repo’s .trivyignore”, as the Source block does for its ignore files. The URL filters it:
?project=&environment=,?deployment=(one deployment),&finding=<id>(marks and scrolls to one),?severity=critical|high,?fixable=1. The security alert mail links here. - CLI.
pl security findings [--environment <env>] [--severity critical,high] [--all]prints the same for the checkout’s project. Suppressed findings are printed only with--all, with what suppressed them.
Configuration.
| Where | Setting | Meaning |
|---|---|---|
| build node | PUSHLEFT_BUILD_SCAN_IMAGE | Trivy image by digest, aquasec/trivy@sha256:2416d1f74045b57274df1a340eee6b510cacd73c66a6ccb8da092b117eb7d222 (0.76.0). Required with PUSHLEFT_BUILD_RUNTIME: the agent does not start without it. |
| gateway | PUSHLEFT_IMAGE_SIGNING_KEY_FILE | PKCS#8 P-256 private key, 0600, owned by the gateway user. Unset: the gateway answers 404 image_signing_disabled, and a build node with a build runtime fails the build (image_attach_failed, retryable). |
Make the key on the gateway host and keep the public half for verification:
openssl ecparam -genkey -name prime256v1 -noout | openssl pkcs8 -topk8 -nocrypt -out image-signing.key
openssl ec -in image-signing.key -pubout -out image-signing.pub
chmod 0600 image-signing.key
The key is a file on the gateway host, like the registry token key: build hosts hold no Vault token. Treat it as tier 0. Verify an image with cosign 2 or 3 (there is no transparency log entry):
cosign verify --key image-signing.pub --insecure-ignore-tlog=true -a sbom=<sbom digest> <repo>@sha256:<digest>
A build node without a build runtime (development) and without PUSHLEFT_BUILD_SCAN_IMAGE records "scan":{"status":"not_configured"}, and "signature": null when the gateway has no key. The event says so; nothing is skipped without a record.
Effective user
Roles run as a non-root user by default (manifest). Decided 2026-11-07.
At build. The agent reads config.User from the built image’s OCI config. A role with no user: and no run_as takes that user. An empty USER is root, and a number is that uid. A name is looked up in the image’s own /etc/passwd, as the image’s merged layers show it: whiteouts hide lower layers, and symlinks are followed inside the image (an absolute target starts at the image root, at most 40 hops). A loop or a missing target leaves the name unresolved. So a name with uid 0, such as toor, is root, and a name the image does not define counts as root. The result lists the resolved uid (user.uid). The build result lists the image’s user and the roles that would run as root (user.root_roles). pl up prints a warning for each such role.
The gate. Migration 0164 adds organizations.root_role_policy. Every organization is on block since 2026-11-07, and a new one starts there (0168). For a production build of an organization set to block, the scheduler adds run_as: block to the build payload. A role that would run as root then fails the build with runs_as_root (a permanent failure that names the roles). Previews and test environments are never gated. Two more paths check it:
- Image by digest. The API cannot read the image’s user. In production under
block, each role needs a non-rootuser:orrun_as, or the upload answers 422runs_as_root. - Build reuse. In production under
block, reuse checks the new deployment’s roles against the uid the earlier build resolved (0167). If any role would run as root, or the build reported no user, the source is built again.
An operator can relax it for one organization:
UPDATE organizations SET root_role_policy = 'warn' WHERE id = '<org id>';
At start. Before it creates a role’s container, the agent resolves the effective uid:gid: the role’s user, else the image’s USER, with names looked up in the image’s /etc/passwd and /etc/group (a user without a group takes its passwd group, or 0, as Docker does). The result is stored on the instance (application_instances.effective_user) and shown on the deployment.
Volume ownership. For a role that is not root, each writable volume that is not shared is checked before the container is created. When any file or directory in it has another owner, the agent changes the owner of the whole tree to the role’s uid:gid. It runs chown -R -h in a throwaway container from the probe image, with only that volume mounted, no network, and only the CHOWN and DAC_READ_SEARCH capabilities. It never follows a symlink out of the volume, and under userns-remap the ids map as the role’s do. An owner outside the remapped range (a file written on the host as uid 501) shows as nobody in that container and cannot be changed there, so the agent first moves those entries from the host. It walks by directory descriptor and never follows a link. The deployment records volume_owner_aligned with the role, volume, old and new owner, file count and node. A second start finds the owner correct and changes nothing.
- Shared volumes are skipped, because their writers can run as different users.
- Only a new container triggers the check. A changed image or
user:always creates one.
Source scan
The image scan sees what ships in the image. The source scan sees the rest:
- secrets and misconfigurations in the checkout;
- dependencies that never reach an image (dev and test gems, mobile and CLI lock files);
- the application’s own code.
Built 2026-11-06, so that projects can drop their own bin/security-scan, Brakeman and bundler-audit steps. It never gates a deploy.
What is scanned. Since 2026-11-07 (migration 0166), two cases:
- The whole repository at the deployed commit, when the deployment recorded a git URL and a full commit SHA, and the organization has a git credential for that host (
pl git credential add, below).pl uprecords the checkout’soriginremote (https,ssh://orgit@host:path) andHEAD. The gateway fetches the git host’s archive of that commit. So parts of the repository that are never deployed are scanned too, and so are ignore files outside apl upsubdirectory. - Otherwise, the deployment’s verified source snapshot, which Pushleft already stores: the
pl upupload (a subdirectory and.plignore-filtered), or the pushed tree. This works the same for any git host and any stack.
The commit is the deployment’s. With uncommitted changes, pl up deploys files that are not in that commit, and the repository scan does not see those changes.
When. Once a day, the scheduler gives each live or degraded deployment a scan_source job on a build node, production and preview alike. A deployment qualifies while it has no source_scanned event from the last day, and, for a snapshot scan, while its source snapshot is still stored. A new deployment is scanned on the first pass after it goes live. A scan that fails is retried after an hour.
A repository scan is one job per repository and commit, however many deployments share them (several environments or projects on one repository). The gateway writes its result to every live deployment on that repository and commit: findings stay per deployment in the API, the console and alerts.
What runs. One container of the digest-pinned scanner image (deploy/images/source-scan.Dockerfile, entrypoint pl-source-scan) runs these tools:
| Tool | Finds | Category |
|---|---|---|
| Trivy fs (vuln, secret, misconfig) | dependencies in every lock file, secrets, Dockerfile and IaC misconfigurations | dependency, secret, misconfig |
gitleaks (dir, redacted) | secrets | secret |
| OpenGrep, security rules only (opengrep-rules at a pinned commit, packs chosen by the file types present) | code | code |
Brakeman, when a Gemfile at the root or one level down has rails | Rails code | code |
importmap: the pins of config/importmap.rb as a lock file, scanned by Trivy | Rails importmap JavaScript | dependency |
The container runs like the image scan:
- the build runtime (its own Kata VM),
--network none; - a read-only root, no capabilities, 4 GiB memory and a 20-minute limit;
- the source and the Trivy DB mounted read-only.
Each tool writes SARIF, except Trivy, which writes its JSON. The agent converts them all to one finding schema. A tool that fails is reported as failed, and the others still count.
Repository fetch. The scan VM has no network and never sees the token, so the gateway fetches for it. The agent posts its lease to POST /v1/agent/jobs/{id}/repository. The gateway authorizes it like the source download: a node advertising source_scan, the current lease, a live deployment, and the job’s repository and commit are the deployment’s own. Then it asks the git host with the organization’s read token:
- GitHub:
GET /repos/{owner}/{repo}/tarball/{sha}. The one redirect followed is tocodeload.github.com, and the token is not sent there. - GitLab:
GET /projects/:id/repository/archive.tar.gz?sha=<sha>. No redirect is followed.
The gateway streams the archive to the agent as it arrives. It does not store it: the archive is not a verified source snapshot and nothing else reads it. Limits: 2 GiB, 15 minutes, and the same address checks as the compare call (no private or reserved addresses). The agent extracts the archive into the scan workspace. It strips the top directory and writes only regular files, at paths with plain components. Links and special files are skipped, and a path that would leave the tree fails the scan. Extracted, the tree may hold at most 8 GiB and 1,000,000 files.
Not fetched: Git LFS objects (a scan sees the pointer file) and submodules (an archive does not include them).
History scan. Secrets removed from the tree stay in the git history. So a full repository scan (the first, then weekly) also runs gitleaks git over the whole history: every commit of every branch and tag. The agent posts its lease to POST /v1/agent/jobs/{id}/history, authorized as above. The gateway makes a bare clone over HTTPS into a private temporary directory on its host:
- The token goes in an
Authorizationheader, set through git’s environment. It is never in the command line or the URL. GitHub usesx-access-token, GitLaboauth2. - Git connects only to the address the gateway checked (
http.curloptResolve). Redirects are off, and https is the only protocol allowed. - Limits: 2 GiB on disk and 15 minutes. A larger history is answered
413 history_too_large. The agent then records the history scan asskipped, withhistory_reason, and tries again the next week. It is not retried every day.
The event’s history_at is the time of the last history scan that ran (or was skipped as too large). A history scan that fails keeps the earlier history_at and sets history_failed. The scheduler then queues the repository again after an hour, as a full scan with history, the same wait as for a failed scan.
The gateway then writes a git bundle of every ref and streams it to the agent, and removes the clone and the bundle. The scanner clones the bundle inside the VM, offline, and runs gitleaks with the tree’s .gitleaks.toml and .gitleaksignore. A .gitleaksignore line for history is gitleaks’ git fingerprint (<commit>:<path>:<rule>:<line>).
A history finding is a secret from the tool gitleaks-history, with the path, line, rule and the commit that added it (source_scan_findings.commit_sha). It never stores the author, the e-mail address or the commit message. A history finding with the same rule and path as a secret in the current tree is not listed: the tree finding covers it. .security-scan-ignore paths apply as for any finding. Between history scans, each scan carries the repository’s last history findings over. A history scan that fails or is skipped keeps the earlier findings.
GitLab: the history clone uses Git over HTTP. A token with only read_api can fetch archives and compares, but GitLab needs read_repository for a clone. Without it, the history scan is failed, the tree scans continue, and the history is retried every hour (see history_failed above), so add the scope.
Severity.
- Trivy: as reported.
- SARIF: the rule’s tags, else its
security-severityscore, else its level (error HIGH, warning MEDIUM, note LOW). - Secrets: always HIGH.
The list keeps CRITICAL, HIGH and MEDIUM findings, at most 500, most severe first. LOW and UNKNOWN are counted only.
No secret text is stored. A finding keeps the tool, rule, path, line and title, plus package and versions for a dependency. A secret’s title comes from its rule, never from the matched text.
Ignore files. The repository’s own files mark findings as accepted. Every .security-scan-ignore and .trivyignore in the tree counts, each for its own directory, so a project deployed from a subdirectory (app/.security-scan-ignore) or a monorepo keeps its waivers when the whole repository is scanned: an entry X in app/.security-scan-ignore matches app/X, and its vuln: and .trivyignore IDs apply only to findings under app/. Dependency and build directories (node_modules, vendor, target and the like) are not searched. Brakeman reads each Rails app’s own config/brakeman.ignore:
.trivyignore: one ID per line..security-scan-ignore:<path> # reasonorvuln:<ID> # reason. A path entry matches that file exactly, or a directory and everything under it, with or without a trailing slash. It is never a raw prefix:fixtures/a.jsonldoes not coverfixtures/a.jsonl.backup, andlib/vendordoes not coverlib/vendored/..gitleaksignore: gitleaks applies it itself.
An accepted finding is stored with suppressed_by (the file and its reason). It is not counted as open and never alerts. Repository files have no expiry: they are the repository owner’s call.
Storage and alerts. The gateway records the result in the transaction that completes the job, while the deployment is still live:
source_scan_findings(migration 0160, tenant RLS) replaces the deployment’s earlier rows.- A
source_scannedevent carries the counts and each tool’s status. - Open secrets or CRITICAL findings add a
source_scan_alertsrow once per set of findings. The API mails the organization’s owners and admins with the same layout as the image alert, linking to the Findings page. Only a project’s first alert is mailed (Security findings). - A repository scan alerts only for open secrets and CRITICAL findings whose fingerprint the repository has not alerted on yet.
source_scan_alerted(migration 0166) keeps each fingerprint alerted on per organization and repository. The alert goes to the job’s deployment only. So a finding alerts once, not once a week, once per deployment, or again when it leaves and comes back. A secret that is rotated but found again with the same fingerprint (the same rule, path and line, or for history the same commit) does not alert again.
Where it shows. The console’s Findings page has a Source block per deployment. GET /v1/security/findings and GET /v1/deployments/{id}/findings add source_scan and source_findings, and pl security findings prints them after the image findings. A history finding has commit (null otherwise): the console shows its short SHA, and the CLI prints @<sha> after the path.
Incremental scans. Added 2026-11-06 (migration 0162): most daily scans see unchanged code, so a scan reruns only what can change since the base scan. The base is the newest source_scanned event of the same project and environment. For a repository scan, the base is the repository’s newest scan in any environment: deps_only on the base’s commit, else changed (the compare below), and full as listed, or when the base’s history scan is a week old or never ran. The scheduler hints a mode in the job; the agent may scan more, never less.
| Mode | When | Runs | Kept from the base |
|---|---|---|---|
deps_only | the snapshot digest is the base’s | Trivy vuln and the importmap scan (the vulnerability DB changes daily) | every finding that is not a dependency |
changed | both snapshots are pushed commits of the same repository (webhook or push to Pushleft git), and the organization has a git credential for its host | Trivy and importmap over the whole tree; gitleaks and OpenGrep on the changed files; Brakeman only when a changed path is under a Rails app | gitleaks and OpenGrep findings on unchanged paths; Brakeman’s when it did not run |
full | anything else | everything | nothing |
A scan is full when:
- there is no base, or the base is from before 0162;
- the base’s rows were pruned or its list was truncated, or a tool failed in the base;
- the chain’s last full scan is 7 days old (weekly full);
- the snapshot came from
pl up: a working tree may hold uncommitted changes or be a subdirectory of the repository, so its commit says nothing exact about its files; - the git host’s diff is not complete and exact (see below);
- a file changed that affects more than itself:
.gitignore,.ignore,.plignore,.semgrepignore,.trivyignore,.security-scan-ignore,.gitleaksignore,.gitleaks.toml, aGemfile,Gemfile.lockorconfig/application.rb; - more than 2000 paths changed;
- a tool the incremental scan relies on fails. The same job then scans everything.
The changed files come from the gateway (POST /v1/agent/jobs/{id}/changed-files, authorized as the source download of the same lease). It asks the git host with the organization’s read token:
- GitHub:
compare/{base}...{head}. Onlyaheadoridenticalis accepted (the base is an ancestor, so the list is the tree diff), with fewer than 300 files (GitHub’s cap). - GitLab:
repository/compare?straight=true(the exact tree diff). It is refused whenoverfloworcompare_timeoutis set, or when a diff has no paths.
A rename counts as the old path deleted and the new path changed. The answer is recorded in the job for completion. On any error, or after 10 s, the answer is complete: false, and the scan runs full. The token and the host’s answer are never logged or returned.
At completion the gateway copies the base’s stored findings that the rerun did not cover, then adds the new ones. It recomputes CRITICAL, HIGH, MEDIUM, secrets and suppressed from the stored rows. LOW and UNKNOWN stay the rerun’s counts: they are never stored. Only findings the base did not have alert. Each event records mode, commit_sha, base_deployment_id, full_scan_at and stored. The result’s source_scan adds mode, reran (per tool all, changed or none) and fallback (why a hinted mode ran full).
Git credentials. One read token per git host per organization. It turns on the repository scan, its history scan and the changed mode. The token is in Vault at vault://organizations/<org>/git/credentials/<id>/token#value, never in the database:
pl git credential add gitlab.example.com --provider gitlab --token-stdin < token
pl git credential add github.com --provider github --token-stdin < token
pl git credential list
pl git credential rm <id>
- GitLab: a project, group or bot access token with
read_api, plusread_repositoryfor the history scan. A deploy token cannot call the REST API. - GitHub: a fine-grained token with Contents: read.
--api-urldefaults tohttps://api.github.com(GitHub) orhttps://<host>(GitLab).- Admins add and remove credentials (audited as
git_credential_addedandgit_credential_removed). Everyone in the organization can list them; the token is never shown. - The API is
POST /v1/git/credentials {host, provider, api_url?, token},PUT /v1/git/credentials/{id} {token}(replace the token),GET /v1/git/credentialsandDELETE /v1/git/credentials/{id}.
Repository access
Admins add tokens in the console under Settings → Repository access. Everyone in the organization sees the list.
- GitHub: github.com only. Use a fine-grained token with Contents: read on the repositories.
- GitLab: GitLab.com or a self-managed instance (an https URL). Use a token with
read_apiandread_repository.
Adding or replacing a token tests it first (POST /v1/git/credentials/test tests without storing). The test runs for each repository on the host that a live deployment of the organization records, at most 20, with 10 s per call:
| Check | GitHub | GitLab |
|---|---|---|
| Token | GET /rate_limit | GET /api/v4/personal_access_tokens/self: scopes and expiry |
| API | GET /repos/{owner}/{repo} | GET /api/v4/projects/:id |
| Commits (diff and archive) | GET /repos/{owner}/{repo}/commits?per_page=1 | GET /api/v4/projects/:id/repository/commits?per_page=1 |
| Clone (history scan) | GET https://<host>/<path>.git/info/refs?service=git-upload-pack, user x-access-token | the same under the instance URL, user oauth2 |
Each check is ok, denied (401, 403 or 404) or error. A token the host refuses is not stored. A token with a missing scope or a denied repository is stored, with the result. The console warns about a missing scope and an expiry within 30 days. The last result and its time are kept on the credential (last_check, checked_at, migration 0172). It never holds the token or the host’s answer. The calls use the SSRF guard and follow no redirect.
Configuration. On a build node, PUSHLEFT_SOURCE_SCAN_IMAGE is the scanner image by digest. It needs PUSHLEFT_BUILD_SCAN_IMAGE, whose Trivy keeps the vulnerability DB fresh. A node with both advertises source_scan, and only such a node gets scan_source jobs.
Not built yet:
- a source SBOM;
- per-finding waivers in Pushleft;
- gating production builds on source findings.
Isolation decision
Decided 2026-10-19: one Kata Containers VM per build on Robot build hosts. Docker starts the build container with --runtime kata, so it is a lightweight VM with its own guest kernel. A kernel bug reached from a tenant RUN step gives the attacker the guest, not the host. Hetzner Cloud servers have no nested KVM, so Cloud build nodes can no longer advertise vm_isolated_build and lose build eligibility while it is required.
The agent has two modes:
--build-runtime kata (production) | no --build-runtime (development) | |
|---|---|---|
| Boundary | the build’s own VM (guest kernel) | the host kernel |
Image (--buildkit-image) | moby/buildkit:v0.25.1 (rootful), sha256:79cc6476ab1a3371c9afd8b44e7c55610057c43e18d9b39b68e2b0c2475cc1b6 | moby/buildkit:v0.25.1-rootless, sha256:0c0ce4929976ace509f7a53878303504b2de8857829aea4932af9f7325a30f51 |
| Confinement | --cap-add SYS_ADMIN and NET_ADMIN (a # syntax= frontend runs in a container with its own network namespace), seccomp=unconfined, apparmor=unconfined, all inside the guest | seccomp=unconfined, apparmor=unconfined, systempaths=unconfined on the host |
vm_isolated_build | yes, if /dev/kvm exists and Docker lists the runtime | never |
Rootful mode: the entrypoint unmounts the read-only /sys/fs/cgroup that Docker gives a non-privileged container. It mounts the container’s own cgroup2 namespace read-write, so runc inside BuildKit can place RUN steps in cgroups. seccomp=unconfined is needed (with the default profile runc cannot create the session keyring). systempaths=unconfined is not needed. --privileged is never used. With Docker (no CRI privileged_without_host_devices), it would pass every host device into the VM.
Rootless mode follows the BuildKit primary documentation (docs/rootless.md, “Containerized deployment” → Docker): buildctl-daemonless.sh as UID 1000 inside its own user namespace. Rootless BuildKit needs the three unconfined options to create a user and PID namespace and a fresh /proc for each RUN step. Use it only where PUSHLEFT_REQUIRE_VM_ISOLATED_BUILD=false. The agent extracts the source as root into 0700 directories, so in this mode it hands the source tree to uid 1000 first. Until 2026-10-20, every rootless build on a Linux host failed to read its Dockerfile (Docker Desktop’s file sharing hid this bug). The Lima tenants harness built two sample apps this way on 2026-10-20 (removed 2026-10-23; staging builds them with Kata).
--build-runtime runc selects the rootful flags on the host kernel. It exists to test those flags on machines without KVM (PUSHLEFT_BUILD_E2E_RUNTIME=runc npm run test:build-executor). It never earns vm_isolated_build and must not be used in production.
The container never gets:
--privileged;- the documented
--oci-worker-no-process-sandbox, which would letRUNsteps signal or ptrace the daemon; - the Docker socket;
- host environment or secrets;
- the host network. It gets its own bridge network,
pl-build-<job>-<lease>.
Its other limits:
-
2 CPUs, 4096 PIDs, and a 30-minute timeout enforced twice. The agent enforces it (
docker rm -f), andtimeout -s KILLinside the container enforces it 60 s later, so a killed agent cannot leave a build running. The operator can set the timeout per build host withPUSHLEFT_BUILD_TIMEOUT_SECS(300 to 14400; any other value keeps 30 minutes). Then raise the scheduler’sPUSHLEFT_REAP_BUILDING_AFTERto at least the timeout plus 15 minutes. With a single build host, also setPUSHLEFT_REAP_QUEUED_AFTERabove the longest queue, or the stale-deployment reaper fails the waiting deployment. The Lima tenants harness (removed 2026-10-23) raised the timeout for a sample app’s release build on the nested Kata VM (G14 in examples/tenants/README.md); -
disk (M8): the root filesystem is read-only (
--read-only). Every writable path except the build cache export is a size-limited tmpfs:- the BuildKit state directory at 8 GiB:
/home/user/.local/share/buildkitrootless,/var/lib/buildkitrootful. The agent mounts it at exactly the image’sVOLUMEpath, so Docker creates no anonymous volume.PUSHLEFT_BUILD_STATE_GIBsets the size per build host, 8 to 48 (a large .NET publish needs about 24). The agent falls back to 8 unless the host’s RAM holds state + 4 GiB + 8 GiB for itself; - the home, runtime and
/tmpdirectories at 64 MiB each.
--log-driver nonekeeps the image tarball on stdout out of/var/lib/docker/containers. Nothing else the build writes reaches the host disk. The cache export goes to its own partition (Build cache). tmpfs pages count against the container’s memory cgroup. So the memory limit is the state size plus 4 GiB for processes, without swap (12 GiB by default). Builds reserve no fleet allocation. A build node runs several builds at once in itsbuildlane (migration0206, decided 2026-11-10):PUSHLEFT_BUILD_SLOTS(1 to 8, default 2), lowered to what the host’s RAM holds at half the state size per build plus 4 GiB, with 8 GiB left for the host. The scheduler never runs two builds of one project on one node at once, so a project’s cache has one writer. An agent without thebuild_lanecapability builds ingeneral, one at a time. With Kata the tmpfs lives in guest memory. The tmpfs limits work on any Docker storage driver.--storage-opt size=would need overlay2 on XFS withpquotaunder/var/lib/docker, which build hosts do not have; - the BuildKit state directory at 8 GiB:
-
existing limits bound the agent-side workspace. Extracted source is at most 4 GiB (
pushleft_source::MAX_EXPANDED_BYTES), the image tarball at most 4 GiB, and the verified blobs at most the tarball. Without caching, peak about 8.3 GiB under--build-root, plus about 3 GiB for the scan DBs. Caching also stages snapshot tar files there. Allow two per-project maximums plus tar overhead in addition to the image/source budget (about 28.3 GiB with the default 10 GiB project limit). The gateway stages transfers in its temporary directory too. PlaceTMPDIRon the snapshot filesystem when using a dedicated local cache disk (staging setup); -
egress (H2): the host nftables table
inet pl_buildis one table for everyplb-*bridge (rendered inpushleft_core::build_firewall_objects). It drops this traffic from a build bridge:- all traffic to the host itself except replies (input hook: every host address, including vSwitch, tailnet and Docker gateway addresses);
- all IPv6;
- IPv4 to
0/8,10/8,100.64/10,127/8,169.254/16(cloud metadata),172.16/12,192.0.0/24,192.0.2/24,192.168/16,198.18/15,198.51.100/24,203.0.113/24,224/4and240/4.
Nothing unsolicited is forwarded into a build bridge. Builds can still reach the public IPv4 internet, which they need for base images and package registries. The agent replaces the table atomically and reads it back at agent start and before every build. Without it, no build starts. The agent keeps the table between builds, because it only matches
plb-*interfaces and those disappear with their networks; -
the source is a read-only bind mount;
-
the registry token is never inside the container, and it is requested only after the build ends. Pushing from the agent was chosen so that tenant
RUNsteps cannot read the push identity from the daemon’s memory or environment.
The residual risks are:
- Without
--build-runtime, seccomp and AppArmor are off for the BuildKit container, so the host kernel’s user-namespace attack surface is reachable from tenantRUNsteps. With Kata, the same applies to the guest kernel; the host is reached only through the hypervisor (QEMU/Cloud Hypervisor) and virtio-fs. RUNsteps share the build container’s network namespace (BuildKit uses host-mode networking inside that container). They reach the public internet, so a build can still exfiltrate its own source or attack third parties.- Builds of different tenants on one host run one at a time (one serial workload lane). BuildKit state is per build and discarded. The build cache is per project, so no cache is shared between projects or organizations. Within one project, a production build can write anything into the production cache (it can put the same into its own image). A preview build can write anything into the preview cache, which production builds never import.
- Docker’s embedded DNS (
127.0.0.11) does not work inside a Kata guest (found on the multi-VM harness, 2026-10-20). It answers in the host-side network namespace, which the guest’s own network stack never reaches. So a VM build gets its own/etc/resolv.conf, bind-mounted read-only. It listsPUSHLEFT_BUILD_DNS(comma list) or the host’s upstream resolvers. Only public IPv4 resolvers are kept, becausepl_builddrops the rest. The agent refuses to start without one.
Builds are only targeted to the build pool, which hosts no tenant runtime or databases (migration 0041), and build hosts hold no Vault token (fleet.md).
Kata on build hosts
Hetzner Cloud servers expose no /dev/kvm; build hosts are Robot dedicated servers (runbooks/robot-hosts.md).
-
Check KVM:
ls -l /dev/kvmandkvm-ok(packagecpu-checker). Enable SVM/VT-x in the BIOS if it is missing. -
Install Kata Containers 3.x from the release tarball (
kata-static-<version>-amd64.tar.zstfrom github.com/kata-containers/kata-containers/releases, verify its checksum, unpack under/opt/kata), and linkcontainerd-shim-kata-v2andkata-runtimeinto/usr/local/bin. Addagent.hotplug_timeout=60tokernel_paramsin/etc/kata-containers/configuration.toml(robot-hosts.md section 6). -
kata-runtime checkmust pass (it checks CPU flags, KVM and kernel modules). -
Register the runtime with Docker in
/etc/docker/daemon.json, next to the"userns-remap": "default"the node bootstrap wrote. Keep that line: the build container opts out with--userns=host(seebuildkit_arguments). Then runsystemctl restart docker:{ "runtimes": { "kata": { "runtimeType": "io.containerd.kata.v2" } } } -
docker info --format '{{json .Runtimes}}'must listkata. Smoke test:docker run --rm --userns=host --runtime kata alpine uname -rprints the guest kernel version. Under the userns remap, it fails with EPERM without--userns=host. -
Agent environment:
PUSHLEFT_BUILD_RUNTIME=kata,PUSHLEFT_BUILDKIT_IMAGE=moby/buildkit@sha256:79cc6476ab1a3371c9afd8b44e7c55610057c43e18d9b39b68e2b0c2475cc1b6,PUSHLEFT_BUILD_SCAN_IMAGE(Image scan, SBOM and signature), noPUSHLEFT_VAULT_ADDR(no node has aPUSHLEFT_VAULT_TOKEN_FILE).pushleft-agent doctorreports the runtime and warns about a token file.
Networking stays NAT only. Kata attaches each VM to the build container’s network namespace (TC mirroring onto the plb-* veth). So its traffic leaves through the per-build bridge, the pl_build table and Docker’s masquerade like any container. Never bridge build VMs onto the public NIC (no macvlan, no host bridge with the uplink). Hetzner’s switches flag unknown MAC addresses on a dedicated server’s port and can lock the server.
Registry tokens
Decided 2026-10-19 (H1). No node and no service holds a registry login. The registry (zot) uses bearer token auth (auth.bearer), and the agent gateway (crates/pushleft-agent-gateway/src/registry.rs) is the only token issuer. It knows leases and placement, and it already authenticates every node by its mTLS certificate. Tokens are ES256 JWTs, valid 15 minutes, for one repository each. The header carries the signing certificate (x5c). zot verifies tokens with the key of the certificate in auth.bearer.cert.
| Caller | How it authenticates | What it gets |
|---|---|---|
| Build node | agent mTLS, POST /v1/agent/registry/token {"repository": "<host>/<name>"} | pull,push on that repository, only while the node holds a live build_image lease whose image_repository is exactly that string |
| Application node | same request | pull on that repository, only while an application instance of a release from it is placed on the node (active_node_id and a reserved/active deployment_role allocation on the node) |
| Scheduler (retention) | the realm, GET /v1/registry/token?service=…&scope=repository:<name>:delete, HTTP Basic with its own secret | delete only, only on a repository that holds a released artifact |
| Anything else | 403 (nodes), 401 (realm) |
Requests never name actions. Placement decides them. A refused request is 403. A gateway with no signing key answers 404 registry_tokens_disabled. Then the agent uses the registry anonymously (development registries without auth only).
How the token reaches the registry:
- Build push: the agent sends
Authorization: Bearer <token>on every blob and manifest request. The token is fetched after the build, so only the push must fit in 15 minutes. A slower push fails the attempt and retries with a new lease. - Application pull (
ensure_application,run_application): the agent writes a 0700 directory with a 0600config.jsonholding{"auths":{"<host>":{"registrytoken":"<token>"}}}, runsdocker --config <dir> pull <repo>@sha256:…, and deletes the directory. Docker sends aregistrytokenas a bearer token directly and never contacts the realm. Checked with Docker 29 on the containerd image store. Images from other registries (database, mesh, probe images) are pulled as before, without a token. - Retention delete: the scheduler gets a token from the realm per manifest and sends it as a bearer token.
The realm is a server-auth TLS listener on the gateway (PUSHLEFT_REGISTRY_TOKEN_BIND) and zot’s auth.bearer.realm. The scheduler uses it for delete tokens, people and CI for plr_ tokens (registry.md).
The registry is zot, run by deploy/systemd/pushleft-registry.service from deploy/registry/zot-config.json, which the gateway renders (registry.md). zot verifies tokens with /etc/pushleft/registry/pushleft-token.crt (= PUSHLEFT_REGISTRY_TOKEN_CERT_FILE).
Signing key and certificate (the key stays on the gateway host, 0600):
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -days 3650 \
-subj '/CN=pushleft registry token' -keyout registry-token.key -out registry-token.crt
openssl rand -hex 32 > registry-scheduler-secret # gateway and scheduler, 0600
What this bounds: root on a build node reaches push and pull on the repository of the build it is running, for that lease. Root on an application node reaches pull on the repositories of instances placed on it, which it can already read from its own Docker store. Neither can delete. The scheduler secret can delete manifests in any repository that has a released artifact (a registry token cannot be narrower than one repository). The gateway’s signing key can mint anything; it is tier 0 like the gateway’s Vault token. An issued token cannot be revoked: it stays valid up to 15 minutes after its lease or placement ends.
Migration from htpasswd
- Generate the signing key, certificate and scheduler secret (above).
- Do these steps in one maintenance window. Configure and restart the gateway (
PUSHLEFT_REGISTRY_TOKEN_KEY_FILE,PUSHLEFT_REGISTRY_TOKEN_CERT_FILE,PUSHLEFT_REGISTRY_TOKEN_BIND,PUSHLEFT_REGISTRY_SCHEDULER_SECRET_FILE). Configure and restart the scheduler (PUSHLEFT_REGISTRY_TOKEN_URL,PUSHLEFT_REGISTRY_TOKEN_CA_FILE,PUSHLEFT_REGISTRY_SCHEDULER_SECRET_FILE). Upgrade the agents. Then switch the registry fromREGISTRY_AUTH=htpasswdtotokenand restart it.PUSHLEFT_BUILD_REGISTRY_USERNAME/_PASSWORD_FILEare no longer read, so remove them. Between the gateway upgrade and the registry switch, pushes and new pulls get 401 and retry. Running containers are not affected. Keep the window short. An upgraded agent talking to an old gateway (404) pulls with the host’s Docker login and pushes anonymously, which an htpasswd registry refuses. - Once deployments go live again, delete the operator Docker login on every application node (
docker logout <registry>, or remove/root/.docker/config.json). Delete the old password files and the htpasswd file. Nothing reads the old password any more. - Retention deletes that failed in the window are retried by the next pass.
- Verify: a
pl upreacheslive, andcurl -s -o /dev/null -w '%{http_code}' https://<registry>/v2/answers 401 withWww-Authenticate: Bearer realm=….
Plain HTTP is used only for loopback registries (127.0.0.1/localhost, which local fixtures use). Every other registry requires TLS. A registry behind a private CA needs PUSHLEFT_REGISTRY_CA_FILE (PEM) on build nodes, because the agent’s push trusts only the built-in web roots. Docker on application nodes uses the host’s trust store.
Open items
-
Build cache on Kata. A small staging Kata fixture was verified on 2026-10-28 with enforced XFS quotas. It took 23.9 s cold, 15.0 s on a local-cache hit and 15.1 s on a snapshot-restored hit. Its cached dependency-stage bind mount also worked. The gateway used a separate local snapshot disk (staging-build-cache.md). Only the rootless harness above proves S3 snapshots. Robot hardware is still unmeasured. Cache mounts (
--mount=type=cache) are not kept (Build cache). -
Native Linux proof is partial. The staging fleet (runbook) runs rootful BuildKit in one Kata 3.32 VM per build. It runs on an Ubuntu 24.04 amd64 VM with nested KVM on the Proxmox lab host. It pushes with a gateway token over TLS and deploys the result (
staging.sh smoke; two sample apps instaging.sh isolation). From 2026-10-20 to 2026-10-23 a Lima harness did the same on nested arm64 (Apple Virtualization). AppArmor profiles, cgroup enforcement under load and escape resistance are still unexamined, and nothing has run on Robot hardware. -
Kata is proven on nested VMs only. The Lima harness (2026-10-20) and staging (since 2026-10-21) proved these parts: the rootful entrypoint’s cgroup2 remount inside the guest and
--read-onlywith the tmpfs mounts. They also proved the read-only source bind mount over virtio-fs, and the image tarball on stdout. Staging setsagent.hotplug_timeout=60in the Kata kernel parameters (staging.md). The arm64 settings the Lima harness needed (Kata’scpu_features = "pmu=off"cleared, a 180 s agent dial timeout) were removed with the harness. Boot time per build on a Robot host is still unmeasured. -
The nftables table on a kernel. On the Lima harness (2026-10-20), the agent installed
inet pl_build, and itsiifname "plb-*"readback passes on Linux 6.8. A probe build’sRUNreaches the public internet. It cannot reach169.254.169.254, the control plane, the private network, the build host ordocker0. -
There are no multi-platform images, live log streaming or provenance attestations (SLSA).
-
Image scan, SBOM and signature: the scan in a Kata VM is not verified yet (the DB is read over virtio-fs). The e2e runs it on Docker Desktop without Kata. The SBOM is an unsigned referrer, bound to the signature only through the
sbomannotation. There is no signed in-toto SBOM attestation. Application nodes do not verify the signature before they run an image. Only live production releases get the daily re-scan, and their pre-built images a report-only scan. Previews and test environments are scanned once, at build time. The signing key is not rotated by any tooling.image_scan_policyis set only in SQL. -
Builds reserve no fleet allocation. Concurrency is bounded only by the agent’s single serial workload lane. A job targeted to a node that dies stays targeted to that node; no retargeting is implemented.
-
Registry blob GC is zot’s online GC (retention.md).
-
Registry tokens:
registrytokenpulls were checked only with Docker 29 on Docker Desktop (containerd image store). They were not checked on a node’s Docker Engine with the classic store. The realm has no rate limit (the scheduler secret is 256-bit random). The signing key is not rotated by any tooling. zot trusts one certificate (auth.bearer.cert), so the old distribution rotation (two certificates inrootcertbundle) does not apply. Nobody has worked out a rotation without refused tokens.
Verification
npm run test:build-executor (scripts/build-executor-e2e.sh) first runs the migrated-PostgreSQL scheduler targeting tests and the gateway publication tests. It then runs the real path:
- The real CLI uploads
scripts/fixtures/web-only. - The scheduler targets the build to a build node.
- The real gateway (mTLS, source delivery) leases it.
- The real agent starts without a Vault token and sweeps a planted leftover container, network and workspace. It runs rootless BuildKit (or the rootful flags with
PUSHLEFT_BUILD_E2E_RUNTIME=runc). It pushes to a per-run zot with token auth, using a token from the gateway. The script setsPUSHLEFT_REQUIRE_VM_ISOLATED_BUILD=false, because Docker Desktop has no KVM.
The script checks that the release_artifacts digest equals the registry’s Docker-Content-Digest. It checks that the digest equals the SHA-256 of the manifest body, read with a token the script signs with its own test-only key. It checks that no token appears in any job, result or event. Then it checks the token scopes (H1):
- With no live lease, the build node gets 403 even for its own repository.
- With a live lease, it gets
pull,pushon that repository only. - The registry answers 401 when that token pulls from or pushes to another organization’s repository, or deletes a manifest.
Retention gets its delete token from the realm. The realm refuses a wrong secret (401) and a repository without a released artifact (403). It checks the build_completed event’s scan, sbom and signature. It checks that the SBOM is a CycloneDX referrer of the image, and that cosign verify accepts the signature with the SBOM annotation. It checks that the workspace, container and network are gone. It also checks that a failing Dockerfile records a build_failed event containing its log and publishes nothing.
Terminal failures and lease eligibility
A build_image lease is granted only while the node is still active and in the build pool. The node must also advertise oci_build, isolated_build and (unless disabled) vm_isolated_build. A job targeted at a node that no longer qualifies stays queued (it is not re-targeted automatically). Three cases mark the deployment failed: a permanent build failure, a retryable failure that exhausts max_attempts, or a final lease that expires without a result. Each appends a build_failed event with "terminal": true. Non-terminal failures append build_failed with "terminal": false and leave the deployment building for the retry.