Skip to content
Toolkit

ADR-0125 — An archive is judged whole before a byte of it is stored

Status: Accepted · Date: 2026-08-30 · Track: 010 artifact hosting, phase 02 (first slice) · Supersedes: nothing · Related: 0102, 0122, 0123

Context

A zip has been accepted by the static-page allowlist since before this track and unpacked by nothing: it is stored, and the serving path 404s it. So the product already holds strangers' archives on disk, and holds them without having looked at what is inside.

Phase 02's charter row is the unpack. It is a phase-scale block — expansion under a per-resource prefix, a manifest, an addressing scheme, and the storage model is the charter's Blocker 1, an owner decision. Its first shippable slice is the half that does not depend on any of that: judging the archive. Every rule the expansion will need is a rule the refusal needs first, and shipping it first means the hostile-archive suite exists before there is anything for a hostile archive to do.

Decision

Every limit is configuration, read before the first byte. config.HostingLimits() declares six ceilings with stated defaults — per-file bytes, per-archive bytes, per-entry bytes, entry count, total expansion, compression ratio — each read from the environment, each falling back rather than unlimiting when a value is absent, zero or unparseable. Unlimited is not something a typo can say. These are the deployment's own ceilings; what a plan may store is Blocker 2 and remains the owner's.

The per-file cap moves with them: services.MaxUploadSize is demoted from the cap to the default that HOSTING_MAX_FILE_BYTES falls back to, and both storage backends are handed the set at construction. That is phase 04's line item arriving one phase early, and deliberately: the alternative was declaring a key in the configuration file that nothing read, which is an operator-visible knob that lies.

Nothing inside the archive is trusted. Names are checked as they arrived, not after cleaning — path.Clean turns a/../../b into ../b, so a check that runs after it inspects a name the archive never contained. Refused: traversal, absolute and drive-qualified paths, a backslash (a separator on one platform and an ordinary character on another, so a name carrying one means two things), a symlink, an irregular mode, and a duplicate name case-insensitively, because two entries differing only in case are one file on a case-insensitive filesystem and which survives would be decided by write order. Sizes are read rather than believed: UncompressedSize64 is a number in the archive's own header.

A refusal is the whole upload. The inspection runs after the type agreement and before SaveFile, on both the create and the replace path, so there is no state in which part of a hostile archive exists — and on the replace path the document the author already had is untouched.

Consequences

  • check:hosting reads 3 of 5 served, 4 of 5 caps configuration. The zip-bundle row does not flip: nothing serves a bundle, and the gate refuses to let the row say otherwise. This slice widened no promise; it closed a hole in one the product had already made.
  • H3 was relaxed. It forbade an unserved row from naming a bound, on the reasoning that nothing is stored under a kind nobody serves. Phase 02 makes that false — a zip has always been stored and is now bounded, while nothing serves it — so the limit half is now independent of served-ness. H3 still forbids the claims that would make an unserved row look served: store, reader, content type, test, hostile fixtures. Second refinement this track has made to its own gate by using it, after ADR-0124's to H7.
  • The hostile archive is a suite: traversal in two shapes, absolute and drive-qualified paths, a backslash, a symlink, a case-differing duplicate, an entry that lies about its size, a bomb, the entry count, the total expansion, an unreadable archive, and the archive-size bound checked before the archive is opened. Proved again end to end on a running stack, with archives built by Python rather than by the Go suite's own writer (evidence .station/jobs/010-artifact-hosting/evidence/phase-02-bounded-refusal-running-stack-2026-08-30.md).
  • What is not decided here: where expanded entries are written, what the manifest looks like, and how an entry is addressed. Those are the next slice and phase 03, and the storage model behind them is Blocker 1 — this ADR settles what may be accepted, which is a question the owner's answer does not change.
  • The inspection reads every entry to its end, so an accepted archive is decompressed once at upload without being kept. That cost is bounded by the same limits it enforces, and it buys the guarantee that the sizes the next slice writes against are the ones it measured rather than the ones the archive claimed.

Source: docs/decisions/0125-an-archive-is-judged-whole-before-a-byte-of-it-is-stored.md

Library