Skip to content

Bound in-progress build disk usage and Railpack checkout storage #548

Done

Description

@samuelmbabhazi

Problem and impact

A build can fill the filesystem shared with running applications before BuildKit's cache garbage collection can reclaim space. Railpack also exports its repository and plan into the agent's state directory, outside BuildKit's cache budget. A single authorized build can therefore threaten the availability of other workloads on the same server; on a single-machine installation the shared disk may also hold control-plane data.

Priority: P2, security/availability hardening. Parent: #215. Audited main: deff5f611308aa538cd3981c3e66ca8dd22cced7 (2026-11-27). This is a known residual risk explicitly recorded in the SPEC, not a newly discovered undocumented exploit. The application writable-layer budget addressed by #347 does not bound BuildKit state or the Railpack copy.

Evidence and limits

  • SPEC open questions acknowledge both unbounded in-progress build storage and the Railpack copy.
  • The installer configures cache GC with maxUsedSpace = "20%" and minFreeSpace = "15%", plus a memory-limited slice. Those cache targets are not a hard quota for an active build.
  • BuildImage validation validates the magnitude of the disk limit field but does not enforce a corresponding storage budget there.
  • Railpack's export creates a private temporary directory and cleans it on return or on a later Railpack build, but applies no byte quota to the export.

Existing mitigations remain useful: one build per server, bounded build duration and memory, cache GC and cleanup of temporary directories. They do not guarantee free disk space during a build. Evidence here is source review and the documented risk; no disk-exhaustion experiment or production outage was induced.

Proposed correction

Choose and document an enforceable storage policy for both the builder state and the agent-side Railpack export: for example, dedicated quota-limited storage with a protected reserve. A monitoring/cancellation approach must account for its reaction delay, concurrent writes and the copy outside BuildKit; a free-space precheck alone is insufficient. Preserve existing application volumes and unrelated node data.

Acceptance criteria

  • State which filesystem paths and bytes the budget covers, including active snapshots, cache and Railpack exports.
  • Enforce a documented limit and reserve while a build is running, with predictable failure before shared application/control-plane storage is exhausted.
  • Refuse or stop builds safely when the reserve cannot be maintained; report a bounded, secret-free failure reason.
  • Clean abandoned temporary exports after interruption/restart without deleting active or unrelated data.
  • Validate the policy on a small disposable filesystem with ordinary, oversized and interrupted builds; demonstrate that a separate workload retains usable disk space.
  • Document supported filesystems, migration behavior and any remaining limits; update the SPEC/ADR accordingly.

Publication check (2026-11-27): main advanced to 817f6ac3b00fdb0e81331e519abc5668a1560aee through #539. The affected production paths cited above are unchanged; the source links retain the audited revision.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority:P2securitytrack:agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions