brygge — Threat Model
| Document | brygge Threat Model (security) |
| Version | v0.15 |
| Date | 2026-11-27 (v0.15); 2026-11-26 (v0.14); 2026-11-25 (v0.13); 2026-11-24 (v0.12); 2026-10-30 (v0.11); 2026-10-29 (v0.10); 2026-10-21 (v0.9); 2026-10-20 (v0.8); 2026-10-17 (v0.7); 2026-09-25 (v0.6); 2026-09-24 (v0.5, v0.4 and v0.3 revisions; v0.2 2026-09-09; v0.1 2026-09-03) |
| Revised | v0.15 (2026-11-27, 0.10.0, RFC 021 Git submodules, contract 0.4.0) changes the owner’s Git floor, and the IR contract. The floor (owner, 2026-11-26): submodule is no longer refused. A submodule is carried as exactly what Git records, a path and the commit id it pins in another repository; its repository is never opened, fetched, followed or verified (no object lookup is made for the id, and there is no network, as before). Its path goes through C-2c’s checks like any entry’s, and its id must be 20 bytes (SHA-256 repositories stay refused). replace-ref, grafts, shallow clones and octopus merges beyond a target’s limit stay refused. C-1g / condition A: wherever a submodule appears (decode, inspect, encode git), the user reads one sentence, that the submodules’ own repositories were not read, imported or verified, so no output implies a check brygge did not make. Condition B: a target holds a submodule or refuses it by name. encode git writes it back as a submodule, and its check (G2) compares it, so a moved pointer is does-not-correspond. A future prikk encoder refuses it (letter 008, sent). C-3b: contract 0.4.0 adds one field (a submodule entry’s pinned id). An entry states a blob or a submodule, never both or neither, and the reader refuses anything else; verify refuses a Modify that changes an entry’s kind. The identity rule: a contract may add fields, but never re-encode an existing one, so every existing atom keeps its id (proven on the whole corpus: the same history decoded by 0.9.0 and 0.10.0 gives equal IRs, ids included). Readers of 0.3.0 and earlier refuse a 0.4.0 artifact at the version gate. T-6: .gitmodules is carried as file content, as before, so a URL that holds credentials is the source’s own published content (RR-1); running git submodule update on a result contacts the source’s hosts, which brygge never does, and the guide says so. No new parser, dependency or network path. v0.14 (2026-11-26, 0.9.0, RFC 020 Subversion at real size and shape) removes the cause of the amplification 0.8.1 bounded, and adds three options. C-2d: the Subversion decoder’s tree shares unchanged directories between revisions (reference-counted directory nodes, copied on write), so a retained snapshot or a directory copy costs O(depth), not a copy of the tree. Measured: the 0.8.1 shape (2,000 files, 160 tags) now decodes at about 432 MB (measured with the real binary), where 0.8.1 refused it at about 3.3 GB; the peak grows linearly in tags (about 2.6 MB a tag in the stated layer, which still records one Add per copied file, and about 0.5 MB with --branch-lines); codeblocks falls from about 1.5 GB to about 355 MB. Every artifact is byte-identical. The ceiling on retained snapshot entries is gone; max_tree_nodes (50,000,000) bounds the cumulative directory nodes and file entries the tree allocates, and max_tree_entries is checked where a tree is expanded into entries. max_copy_expansion and max_ir_ops are unchanged. RR-total-memory narrowed: 0.8.1’s residual (about 3.3 GB before refusal) closes; the stated layer’s per-file record of a tag copy is the remaining linear cost, and the guide points tag-heavy histories to --branch-lines. Input (TB-4): --layout-trunk, --layout-branches and --layout-tags are operator input, validated before decoding (relative, no .. or empty segment, no overlapping containers). The layout is recorded in provenance with %, , and = percent-encoded, so a path holding one is read back exactly; the default label is unchanged. C-3c: a recorded layout that cannot be read gives not-checked, never a silent comparison against the default layout. No new parser, dependency or output path. v0.13 (2026-11-25, 0.8.1, a security patch) discloses and closes an amplification gap in C-2d, present since 0.1.0. Two decoders could be made to use memory out of all proportion to a small input, an availability fault only, never a wrong or corrupt result. Subversion: a directory copy is a few bytes of dump, but the decoder kept a full copy of the repository tree for every revision a later copy named, so a dump of about 0.5 MB with 160 tag copies of a 2,000-file trunk reached about 4.4 GB. Git: trees that reuse one subtree at every level (about 108 paths from a 112 KB repository) ran without bound, because the ceilings covered depth and path length, not the number of entries a tree expands to. Fixed by four declared ceilings, each checked before the memory it protects is used: max_tree_entries (10,000,000 entries in one tree, Git and Subversion), max_copy_expansion (one Subversion directory copy, the same), max_retained_entries (20,000,000 entries across the Subversion snapshots kept for later copies, about 170 bytes each as measured), and max_ir_ops (200,000,000 operations in one artifact, in brygge-ir’s builder, so for every decoder and transform). Each refuses with a resource limit (exit 20). Every corpus repository stays at least 2.96× below every ceiling, and decodes byte-identically to 0.8.0. Not affected: Mercurial manifests and CVS RCS files are flat reads, already bounded by their byte ceilings (max_revision_bytes, max_rcs_bytes). C-2d now states the lesson: a ceiling must bound what an input can expand to, not only how many bytes it is. RR-total-memory: a hostile Subversion dump can still reach about 3.3 GB before max_retained_entries refuses it; 0.9 removes the cause by sharing unchanged directories between snapshots. v0.12 (2026-11-24, 0.8.0, RFC 019 Git as a target) adds a supported encoder, a new subprocess and a new output path. New TB-8 (brygge → git, for encode git). C-2b: git is a trusted external tool, like svnadmin: resolved on PATH among absolute entries only, never the current directory, spawned with no shell, under a cleared environment (an empty temporary HOME, an empty GIT_CONFIG_GLOBAL, GIT_CONFIG_NOSYSTEM=1, LC_ALL=C), so no user configuration, template or hook reaches the result; a hostile ~/.gitconfig and GIT_TEMPLATE_DIR are proven to change nothing. C-1g widened: the built-in encoder’s output is brygge’s own, so it is labelled and checked by brygge. Every commit and annotated tag ends with Brygge- trailers (who encoded it from what source, the source’s own id, every derived, transformed, supplied or altered value, and the artifact’s digest), which survive a clone, unlike notes. Before the repository is handed over, brygge decodes it with its own Git decoder and compares every commit with the artifact (parents, the full tree state, identities, the exact message bytes, every ref and nothing extra); a difference refuses the result and leaves nothing behind. verify --against-target git runs the same check on a kept repository; a git replace view is refused, not checked. The name git is reserved, so no plugin can stand in for the built-in. C-7: encode git builds the repository in a private sibling directory and renames it into place only after the check passes; <dir> and its report must not exist beforehand, and the report is renamed into place last. C-3b: the builder now refuses a repeated copy record, so an artifact its own reader rejects can no longer be written; this closed a released Subversion decoder fault (a directory copy whose files were also restated as copies wrote an artifact that failed verify, fail-closed, never a false pass). C-3c: a decoder’s floor list is aligned before --against-source compares, with a note when it differs, because two successful decodes prove the source holds nothing either floor refuses. Derived layers (HO-1): decode svn --branch-lines derives one line of history per branch, and CVS --reconstruct-refs derives the main line as trunk; both are opt-in and marked ReconstructedBranch. Every atom must be reachable from a ref, or encode git refuses, so no history is left for Git to garbage-collect. C-4d: faster-hex 0.10.1 closes RUSTSEC-2026-0306; autocfg 1.5.1 is a new build-time dependency of it, in the Git decoder only; brygge-ir’s closure is unchanged, and the encoder module is held to brygge-ir and std by a source-level check. RR-plugin-trust covers git as it covers any tool on PATH. Re-verified for 0.7.1 (2026-11-21), with no revision: 0.7.1 adds no parser, dependency, input path or format change. Its changes are in four places. Dependencies (C-4d): rustix moves from 1.1.4 to 1.1.6 for RUSTSEC-2026-0486 (unsound xattr functions). brygge cannot reach it: none of its dependents in brygge’s tree (gix-index, gix-prompt, tempfile) calls those functions. Nine new informational “unsound” advisories against heapless 0.8.0 (RUSTSEC-2026-0574 to 0582, 2026-11-18) are not reachable either. heapless is linked only through faster-hex 0.10.0, which uses it only when its alloc feature is off. gix-hash turns that feature on, so none of heapless’s code is in brygge. The patched heapless 0.9.4 needs a newer faster-hex, and that a newer gix. That upgrade waits for the next minor release, together with RUSTSEC-2026-0306 (RR-1). Tests: the plugin integration tests find the sibling binaries beside CARGO_BIN_EXE_brygge, because Rust 1.100 moved the test executables. Packaging (C-4f): brygge-bin’s .SRCINFO names each architecture’s attested tarball, and the AUR build container mounts the release tools read-only from the same trusted checkout of the workflow’s own commit. Documentation. Every control holds. v0.11 (2026-10-30, 0.7.0, RFC 018 contract 0.3.0) adds compression to the untrusted read path, and a second plugin boundary. C-3b: artifacts are DEFLATE frames. Every frame’s size is checked against the contract’s packing plan before it is inflated; inflation streams through a fixed 64 KiB buffer, stops at the declared size, and refuses a stream that is longer, shorter or left unconsumed. An artifact of about 256 KiB that inflates to 256 MiB passes verify within a 16 MiB peak. The digest now covers the logical (uncompressed) content, a function of the IR alone; the compressed bytes are outside it, and the canonical form is strict at the logical level. Artifacts of contract 0.2.0 are still read. New TB-7 (brygge → an external transform plugin). New C-3d: a transform records itself (a chain of records citing the digest each step read; a Transformed status that keeps the prior one; a Transform loss naming exactly what was removed), and brygge transform checks the output against the input (transform::check): every change marked, every removal recorded, nothing invented, provenance unchanged. It refuses the output otherwise and writes nothing. verify --against-source checks a chain’s root against the source (root-corresponds), never plain corresponds. C-3c: across brygge versions, --against-source re-stamps the re-decode before comparing, so an identical history is corresponds with a note and a different one is not-checked; until 0.7.0, every artifact from an earlier version was falsely reported as does-not-correspond. C-2b covers transform plugins under the same lookup rules. C-7: brygge transform writes a temporary file in --out’s directory, removed on every refusal. INV-4/C-4a: brygge-ir links miniz_oxide and adler2 (pure Rust, forbid(unsafe_code)). RR-total-memory: the artifact is 4.6×–7.5× smaller; the spill file still holds the uncompressed content; parallel compression adds a constant of about 100 MiB. New residual RR-transform-trust. v0.10 (2026-10-29, 0.6.0, RFC 017 Extensibility) adds one boundary: brygge encode <target> runs an external encoder plugin, a program the operator installed. New TB-6 (brygge → an encoder plugin). C-2b: running a plugin is not running source-provided code: brygge finds it on PATH only, among absolute entries, never in the current directory or a repository, and on Windows accepts .exe only; it spawns the resolved path directly, with no shell. INV-2 holds. New C-1g: an encoder’s output is never presented as brygge’s. brygge verifies the artifact first and refuses to run the plugin if that fails; it prints, before the plugin runs, that the plugin is not part of brygge and that brygge verified the artifact, not the plugin’s output; the name prikk is reserved for the built-in encoder, so no plugin can stand in for it. The encoder guide states the honesty rules an encoder must keep, and examples/encode-git (unsupported, never released) keeps them: every value it supplies or alters is marked in the commit. INV-4/C-4a: brygge-ir’s dependency closure is checked on every target platform at once; before, the check ran for the host only, and missed libc on aarch64 (through sha2). New residual RR-plugin-trust: a plugin runs with the operator’s privileges, and brygge does not vet it. v0.9 (2026-10-21, 0.5.0, RFC 015 Scale at real size and RFC 016 Arch Linux packaging) changes how brygge holds content, and adds a second publication channel. C-7: besides the artifact, decode (and verify --against-source) now writes one private spill file while it runs: created new, mode 0600, named .brygge-spill-…, in --spill-dir or the output’s directory, unlinked at once on Unix and deleted on close on Windows, so it is never left behind, even when the process is killed. Its location never reaches the IR. A full disk is a typed error naming the directory, with no artifact written. C-3b: the artifact reader is one streaming pass that hashes every byte and accepts nothing before the digest matches; a blob read later is re-hashed against its content address, so an artifact that changes while it is open gives ArtifactChanged, never different bytes. C-8: streaming with bounded memory is built. RR-total-memory narrowed: the peak now follows the metadata, not the content (fish-shell: decode 18.7 GiB → about 410 MiB; verify 9.1 GiB → about 64 MiB); there is still no aggregate ceiling. C-4f restated: it now names the dev-dependency guard, and covers the AUR packages: the attestations verified before packaging, the binary package checked byte for byte against the attested binary, the AUR host key pinned. New residual RR-aur-key: the AUR has no short-lived credential, so a stored SSH key, scoped to the owner’s AUR account, publishes there. v0.8 (2026-10-20, 0.4.0, RFC 014 Hardening) adds C-2g, adversarial (mutation) testing of every parser of untrusted bytes, of the IR artifact reader, and of verify’s checks. Disclosed and closed: five CVS RCS-reader defects present in 0.1.0–0.3.1, found by C-2g: an infinite loop on a truncated symbols/branches list; a crafted ed-script line number that spun the apply loop; a pre-allocation sized by an untrusted count; a subtraction panic on a malformed revision number; and a million-step walk on a cyclic chain. All are availability only. C-2a: RCS edit scripts that no tool writes are refused: out-of-order or overlapping commands, which CVS does not define; a zero-count add, which CVS 1.11 mishandles; and commands past the end, which CVS refuses too. C-4d: the scheduled check is the advisory watch, the one poll of an external source. C-4f: the release tools refuse a versioned dev-dependency on an unpublished crate, which a dry-run cannot see. New residual RR-total-memory: there is no aggregate memory ceiling; a real brygge decode peaks at about 4× its IR content (RFC 015 D-1 corrected RFC 014 D-4’s decode-only figure). v0.7 (2026-10-17, 0.3.1) discloses and closes a gap in C-2d. From 0.1.0 to 0.3.0, a crafted zstd-compressed Mercurial revlog chunk of under 128 KB could exhaust memory (RUSTSEC-2026-0344, in ruzstd before 0.9.1). The decoder expanded a whole block inside one read(), so brygge’s outer ceiling, a .take() on the stream, never got control back. It is a denial of service, never memory corruption. Fixed by ruzstd 0.9.1, which bounds each block, and by an explicit window cap at the revision ceiling. Audited and found bounded: hg zlib, the CVS RCS delta, the SVN svndiff reader, and gix-odb’s loose-object read. C-2d now states the lesson: an outer read limit bounds what a callee returns, not what it allocates. C-4c: the MSRV rises to 1.87, the floor of the only patched ruzstd. v0.6 (2026-09-25, 0.3.0, RFC 013 and batch I) reviews the three new input paths and closes RR-svn-special-toggle. New parsers, each bounds-checked, panic-free and ceilinged: the svndiff version 0 reader (SVN delta dumps; every length and offset checked before use, the target ceiling applied before a window runs, svndiff 1/2 refused by name), SVN property deltas, Mercurial’s complete store path encoding (hashed dh/ names computed from the logical path, never reversed; a missing file is a read error), and CVS branch history (per-branch clustering, the parent rule, the branch-point atom). C-2d gains the SVN per-node text ceiling (1 GiB) and the total a delta dump may reconstruct (the dump ceiling), so a small delta dump cannot amplify. C-2f gains the SVN dump checksums (MD5 and SHA-1 on every node where stated; a consistency check, not authenticity). C-3b: the reader’s canonical order for refs, drops and flags now follows the specified variant numbers; before, an artifact with drops of two classes or with both flag kinds (any CVS repository with branch revisions) failed its own integrity check, a false failure, fail-closed, never a false pass. Separately, the Mercurial decoder wrote two refs of one name for a branch with two heads, which the contract forbids: that artifact was invalid, and verify rightly rejected it. The decoder now writes one ref per branch, and the builder refuses to write any artifact with a repeated ref, drop or flag key, so brygge can no longer emit an artifact its own reader rejects. C-4d: one new dependency, md-5 (RustCrypto, MIT OR Apache-2.0, in the SVN decoder only); brygge-ir’s closure is unchanged. RR-cvs-reconstruction extends to branch points. Re-verified for 0.2.0 (2026-09-24): increments 5, 3 and 3b change how the Git and CVS decoders hold and compute state, not what they read or trust: no new parser, dependency, input path or output. The ceilings (C-2d) and every control hold, and the byte-identical output was checked by two-build comparison. v0.5 (2026-09-24, 0.2.0 batch C) closes RR-cvs-read-toctou: the CVS reader checks that the file it opened is the file its walk saw (C-2c), and a narrower note replaces the residual. v0.4 (2026-09-24) folds RFC 012 (release automation) and the new supported platforms. New control: C-4f the release pipeline (a verified, gated, tagged commit on main; published only on the owner’s approval; crates.io trusted publishing with no stored secret; SHA-pinned actions in the jobs that hold credentials; published crates checked byte for byte against the tag; binaries with checksums and build-provenance attestations; a published version’s tag never moved, by governance rule). C-4d gains the weekly advisory check. C-2c is proven on Windows (symlinks and directory junctions refused, in CI) and noted for macOS. New residuals: RR-release-agent-credentials and RR-release-dispatch-tools. v0.3 (2026-09-24) folds the 0.1.0 correction cycle (intake review CR-01…CR-21, reviews 002–011) and closes the model against the code as built. New controls: C-1f output neutralization; C-2f source-object integrity (Git objects re-hashed, the commit-graph cache not trusted, tag chains verified; every hg revision checked against its node with a collision-detecting SHA-1); C-6d only what the source would publish is imported (Git carried namespaces; the hg published view). Restated to match the code: C-2a (strict, typed refusal; the panic boundary; release overflow checks), C-2c (read confinement, and the floor refusals that enforce it), C-2d (the declared ceilings, checked before allocation), C-3a (the seven verify checks and the three-valued verdict), C-3b (IR contract 0.2.0: version gate first, critical bit, strict canonical form, digest over the stored bytes), C-7 (atomic write), C-8 (cancellation and progress are not built; stated as such), C-9 (no stated non-determinism remains in the IR). Residuals: RR-cvs-reconstruction, RR-cvs-read-toctou and RR-svn-special-toggle added; RR-git-loose-object-symlink, RR-git-object-id-unverified and RR-hg-node-unverified (found and closed in the same cycle) closed; RR-gix-sha1 narrowed; RR-4 and RR-svn-svnadmin-version updated to the rulings and the code. v0.2 (2026-09-09) folds the RFC 004 (gix) and RFC 006 (SVN Tier D) security-review deltas: C-2e/C-4b/INV-4 — a C surface may be isolated to a subprocess, not only a dedicated FFI crate; TB-2 acknowledges subprocess decoder producers; C-2b clarifies that invoking a trusted external tool is not executing source-provided code; and three residuals added — RR-gix-sha1, RR-svn-svnadmin, RR-svn-svnadmin-version. |
| Basis | brygge Requirements v0.2 (PU/NG/PR/HO/VF/ID/FA/BN/IR/UD/OQ) and External Design v0.2 (BD/CL/IX/FS/PX/CF/FL/CT/OP/GATED); RFC 113 (import contract); project rules (.git-exclude/rules/, §Release Deliverables — a threat model is a first-class release deliverable) |
| ID scheme | A- asset · TB- trust boundary · T- threat · C- control · INV- security invariant · RR- residual risk · ASSUME- assumption |
| Not | code, an API, or a dependency audit report. It states what brygge must defend, against whom, and how — so the design and tests can be checked against it. |
The essence, in one paragraph. brygge is unusual among the ecosystem’s tools: it reads untrusted input (a source repository is attacker-controllable in every byte), it links or drives heavy third-party code to do so (gix for Git; an svnadmin subprocess for SVN — the very reason it is a separate project from prikk, PU-5), and it produces artifacts that a target system will trust and import. Its two signature dangers follow directly: (1) manufactured verification — producing history that reads as native or verified when it is neither (the failure RFC 110 §4 and NG-3 name), and (2) hostile source input — a crafted repository that exploits a decoder, escapes the output directory, exhausts the host, or smuggles executable content. Everything below organizes the defense of those two, plus the supply-chain and boundary properties that keep brygge’s weight from becoming prikk’s.
1. Assets (A-…)
- A-IMPORT — the integrity and honesty of the produced IR (intermediate representation) and target proposal. This is the primary asset: downstream readers and the target trust it. Its value is not just correct bytes but the truthful marking of what was stated vs derived, what was preserved vs dropped, and that authorship is unverified (HO-1…HO-4).
- A-HOST — the operator’s machine and the brygge process. brygge parses attacker-controlled repositories with large parsers; a compromise or crash here is a real cost.
- A-TARGET-TRUST — the target’s trust boundary. The target (prikk first) decides admission/seal (BN-2); brygge must never produce output that induces the target — or a human reviewing it — to over-trust imported history.
- A-SUPPLY — brygge’s dependency supply chain. The heavy decoder libraries are both the enabling asset and the largest attack/audit surface.
- A-SOURCE-CONTENT — secrets and PII that live inside source history. brygge carries source content faithfully by design; that content may include committed secrets, private emails, and internal paths. brygge must not worsen their exposure.
2. Trust boundaries (TB-…)
| ID | Boundary | Direction & trust |
|---|---|---|
| TB-1 | source repository → brygge | Untrusted in. Every object, path, name, message, size, and delta is attacker-controllable. This is brygge’s defining boundary and has no analogue in stikk. |
| TB-2 | heavy decoder libraries (or tools) → brygge | Semi-trusted, large. gix/libgit2/SVN/CVS libraries — or a decoder subprocess such as svnadmin dump (RFC 006 Tier D) — process the untrusted bytes of TB-1; a vulnerability in them is a vulnerability in brygge, though a subprocess confines that vulnerability to a separate address space (C-2e/C-4b). |
| TB-3 | brygge → target system | brygge’s output is a claim, not authority. The target owns admission/trust/seal (BN-2). brygge’s obligation is honest, sufficient provenance (BN-3). |
| TB-4 | operator ↔ brygge | Trusted. The operator runs brygge, sets inference parameters (CF-01), and the owner sets the floor policy (CF-03). brygge trusts the operator’s host and configuration. |
| TB-5 | brygge output → third party / bundle receiver | The import’s honesty and provenance must survive the hop to someone holding only the output (VF-3) or the output plus the original source (VF-2). |
| TB-6 | brygge → an external encoder plugin (since 0.6.0, RFC 017 D-3) | The operator’s own installed code, trusted as the operator’s host is (TB-4, ASSUME-1), and never source-provided. brygge hands it an artifact it has just verified. What the plugin writes is outside brygge’s guarantee, and is labelled so (C-1g). |
| TB-7 | brygge → an external transform plugin, and back (since 0.7.0, RFC 018 D-6) | The operator’s own installed code, as TB-6, never source-provided. brygge hands it an artifact it has just verified. Unlike an encoder’s, its output comes back into brygge’s chain, so brygge does not trust it: the output is read as untrusted input (C-3b) and checked against the input (C-3d) before anything is written to --out. |
| TB-8 | brygge → git (since 0.8.0, RFC 019 D-1) | A trusted external tool on the operator’s host, as svnadmin is (TB-2, C-2b), run under a cleared environment. brygge writes the stream git fast-import reads, then checks what git wrote against the artifact before handing it over (C-1g), so a faulty or replaced git gives a refused result, not a wrong one. |
3. Threats and controls (T-…, C-…)
T-1 (Spoofing) — manufactured verification / authorship laundering
A source (or a careless run) yields history that reads as natively authored or prikk-verified. The archetype: a GPG-signed Git commit presented as a verified prikk author; or imported history that looks indistinguishable from sealed native history. This is brygge’s worst failure — a trust-destroying one for the whole ecosystem (A-IMPORT, A-TARGET-TRUST).
-
C-1a —
Unverifiableby construction (HO-3, NG-3). Imported authorship lands in exactly the target’s vocabulary for “present, readable, not verified as authored”; for prikk that isUnverifiable. It is never shown as sound/green/native anywhere in any brygge surface (FS-04). -
C-1b — honesty is a property of every object, not a report (HO-4, FS-01/FS-02). The derived-marking, the loss boundary, and the
Unverifiablestatus live in the IR/proposal and are recoverable from them (brygge inspect), so they cannot be lost, skipped, or separated from the history they describe. -
C-1c — honesty is non-configurable (HO-5, CF-02). No flag suppresses derived-marking, the loss boundary,
Unverifiable, or the fidelity summary. Configuration tunes inference, never honesty. -
C-1d — the two claims are never conflated (VF-4, FS-04). “verified by the target” and “faithfully imported, authorship unverified” are distinguishable by any reader at any time; a preserved source signature is shown as preserved and verifying nothing in the target, never as a target signature.
-
C-1e — derived ≠ stated, in the object (HO-1, IR-2). An inferred rename / reconstructed CVS changeset / inferred SVN branch is marked derived where it appears; a reader tells judgment from fact without re-running the heuristic.
-
C-1f — untrusted text cannot forge brygge’s own output (CL-07; CR-19). Source text (names, messages, paths, ref names, reasons derived from them) could otherwise print a fake
PASSline, a fake key, or terminal control sequences that hide or recolor a verdict.- Human output: every control character and every bidirectional or invisible Unicode format character is shown escaped (
\u{XXXX}), and a literal backslash is doubled, so an escape in the output is never ambiguous with one in the input. - Machine output: untrusted text never appears in a key (items are indexed). Values are percent-encoded outside a small safe set, so a value can never contain
=or a newline and can never forge a line or a key. - One renderer: only the CLI prints. Decoder libraries write nothing to stdout or stderr, so no text can bypass the neutralization.
- Human output: every control character and every bidirectional or invisible Unicode format character is shown escaped (
-
C-1g — an encoder’s output is never presented as brygge’s (since 0.6.0, RFC 017 D-1/D-3). An encoder sits after brygge’s chain (TB-6), so its output could be mistaken for something brygge verified, the T-1 archetype one hop later.
- Verify first, always:
brygge encoderunsverify’s internal checks on the artifact, and on anything butpassit printsverify’s report and exits withverify’s code. The plugin never starts. A plugin is never handed an artifact brygge would reject. - The label: before the plugin runs, brygge prints on stderr that the plugin is external, not part of brygge, and that brygge verified the artifact, not the plugin’s output, with the plugin’s resolved path. brygge’s own refusals all come before that line, so its presence tells a reader whose exit code follows.
- The reserved name:
encode prikkis the built-in encoder’s (Track B1), and is never looked up onPATH. No plugin can stand in for it. - The rules for encoders: the encoder guide (
docs/src/reference/writing-an-encoder.md) requires an encoder to carry or discloseDerivedmarks, to mark every value it supplies or alters, and to report the loss boundary.examples/encode-git, unsupported and never released, does so in every commit (Encoded-supplied:,Encoded-altered:,Brygge-Derived:,Brygge-Artifact:). - brygge supports no third-party encoder. It vouches for the artifact it checked, and for nothing a plugin produces.
- Verify first, always:
T-2 (Tampering / Elevation / DoS) — hostile source repository
A crafted source exploits brygge or its host through TB-1/TB-2: memory-safety bugs in a decoder; path traversal / symlink escape / absolute paths in source-declared file paths; decompression or delta bombs; pathological object counts or sizes; and source-embedded executable content — Git hooks, .gitattributes clean/smudge filters, submodule URLs, SVN hook scripts, CVS .cvsignore/wrappers (A-HOST, A-IMPORT).
-
C-2a — all source bytes are untrusted (TB-1). No decoder path assumes well-formedness; malformed input is a refusal (FA-2/FA-3), never undefined behaviour. Where a format’s reference tool is itself undefined on malformed input, brygge refuses rather than imitating it. For example, RCS edit scripts that
diff -nnever writes are refused. For out-of-order or overlapping commands CVS defines nothing: 1.11 refuses them through unsigned wraparound, and 1.12 returns artifacts of its reverse traversal. A zero-count add is a heap write past its buffer in 1.11, and a silent no-op in 1.12. Commands past the end are refused by both CVS lines, and by brygge.- Strict, never guessed. A malformed field is a typed error, not a default. Examples: an unparseable RCS date or an out-of-range date component; an unknown escape or duplicate key in an hg extra; a malformed phaseroots, bookmark or localtag line; an SVN symlink without its
linktarget. - Refused where carriage cannot be exact. A shape brygge cannot carry byte-exact is a named floor refusal (exit 20), never a lossy conversion. This covers non-UTF-8 paths, and names that the IR holds as text: Git ref names and commit header names, CVS symbol names, and hg extra keys.
- Contained failure. An unexpected panic inside a decoder or a decoder dependency is caught at one boundary in the CLI and becomes a typed failure (exit 1), never an unclassified abort. Release builds keep integer overflow checks, so an arithmetic wrap that review missed becomes that typed failure rather than a false value.
- Strict, never guessed. A malformed field is a typed error, not a default. Examples: an unparseable RCS date or an out-of-range date component; an unknown escape or duplicate key in an hg extra; a malformed phaseroots, bookmark or localtag line; an SVN symlink without its
-
C-2b — brygge never executes source-provided code. Decode reads objects; it does not run hooks, apply clean/smudge filters, fetch submodules, or execute any script the source carries. Filter/hook content is preserved opaquely as data (PR-4) if it is history, never invoked. This is an invariant (INV-2). Running a trusted external tool to read a source (RFC 006 Tier D invokes
svnadmin dump) is distinct from and does not breach this: the tool is operator-environment code (TB-4), not source-provided, andsvnadmin dumpexecutes no repository hook scripts (hooks fire on commit/revprop paths, never on dump). A tool that did run source-embedded code, or a source construct that reaches out (svn:externals), is refused — externals are refused, not resolved (→ the SVN floor).- Encoder plugins (since 0.6.0, RFC 017 D-3) are operator-installed code too (TB-6), never source-provided, and brygge keeps it so. The plugin is found on
PATHonly, and only among its absolute entries: an empty or relative entry is skipped, so the current directory and a source repository are never searched. On Unix, it must be a regular file with an execute bit; on Windows, a regular file namedbrygge-encode-<target>.exe(never a.bator.cmd, which run throughcmd.exe). The target name must match[a-z0-9][a-z0-9-]*, so no path or shell character reaches the lookup. brygge resolves the path itself and spawns it directly, never the bare name (Windows’ own search would look elsewhere first), with no shell, and passes the arguments verbatim. - Transform plugins (since 0.7.0, RFC 018 D-6; TB-7),
brygge-transform-<name>, are found and run by exactly the same code, with the same rules. The two kinds never stand in for each other.
- Encoder plugins (since 0.6.0, RFC 017 D-3) are operator-installed code too (TB-6), never source-provided, and brygge keeps it so. The plugin is found on
-
C-2c — source-declared paths are data, not filesystem targets; brygge reads only the repository it is given. Paths from the source name content inside the IR; brygge never uses a source-declared path as a write destination (→ C-7). On the read side, a source must not be able to make brygge read another location on the host into the IR, which would be a confused deputy (T-6/T-7):
- Git: opened with gix’s isolated options (no global, system or environment configuration). Alternates, a redirected git directory (
gitdir:files,commondir), and a symlinked.git,objects,objects/info,objects/packor pack entry are refused. So are grafts, replace refs and shallow clones, which would substitute history. - CVS: any symlink under the repository root, file or directory, is refused; entries are examined with
lstatand never followed.- The file opened is the file walked. On Unix it must have the same device and inode as the walk’s
lstat. On Windows it is opened without following a link, and refused if it is a link or any reparse point. - A swap between the walk and the open is
Read(“changed while being read”), never a read of another file.
- The file opened is the file walked. On Unix it must have the same device and inode as the walk’s
- Mercurial: the store is read in place; a repository in the middle of a merge is refused.
- SVN: a dumpfile is read as one stream; a live repository is read only through
svnadmin dump. - Per platform (RFC 012; tested in CI on Linux x86_64 and arm64, macOS and Windows):
- Windows: a file symlink, a directory symlink and a directory junction are each refused, under
a CVS root and in Git’s redirected-directory checks.
stdreports a junction as a symlink, because its reparse tag is a name surrogate, and a CI test asserts it. A Windows name that is not valid Unicode is refused asnon-utf8-path. - macOS: APFS and HFS+ cannot hold a file name that is not valid UTF-8, so that refusal cannot arise there. Its escaping stays tested on every platform.
- Windows: a file symlink, a directory symlink and a directory junction are each refused, under
a CVS root and in Git’s redirected-directory checks.
- Git: opened with gix’s isolated options (no global, system or environment configuration). Alternates, a redirected git directory (
-
C-2d — resource bounds, refuse rather than exhaust (→ T-8). Declared ceilings on object size, total count, path length and depth, and decompressed size. A ceiling is checked before the memory it protects is allocated. An outer read limit (a
.take()on a decoder’s stream) bounds only what the decoder returns, not what it allocates internally, so a decompression ceiling is claimed only where the decoder’s own allocation is bounded, too (each site audited in v0.7). Hitting a ceiling is a typed refusal (ResourceLimit, exit 20) naming what exceeded and the ceiling with its unit, never an OOM, a stack overflow or a hang. Each decoder keeps its ceilings in one place, and its README lists them:- Git: blob size, read from the object header before the body is read; commit count; path length; tree depth, enforced by an iterative tree walk (recursion on attacker-chosen depth could abort the process beyond any panic boundary); tag-chain length.
- Mercurial: every decompression and every delta application is bounded. zlib inflates into brygge’s buffer, so the outer limit bounds it. zstd is bounded by
ruzstd0.9.1’s per-block bound plus a window cap at the revision ceiling; before 0.3.1 it was not (see v0.7). Each reconstructed revision must also equal its index’s recorded length. The obsstore and the small metadata files (phaseroots, bookmarks, localtags) have ceilings; the dirstate read is 40 bytes. - SVN: the dumpstream is size-checked before reading and read through a bound. One node’s text (fulltext or reconstructed from a delta) is at most 1 GiB, and everything a delta dump reconstructs is at most the dumpstream ceiling; both are checked before a delta window runs. The
svnadminsubprocess’s stdout is bounded, and its stderr is drained with only a bounded prefix kept, so the child can never deadlock. - CVS: each
,vfile is size-checked before reading and read through a bound; the file count is bounded. - Streaming (bounded memory, not just bounded input): RFC 010’s increments 2 and 4 were deferred by measurement in 0.2.0, since every peak tracks the IR itself.
-
C-2e — memory-safety posture. brygge’s own crates
forbid(unsafe_code). The unsafe/C surface is confined to dependencies (RR-1) and, if a C library is used at all, to a single dedicated FFI crate — or, preferably where available, to a subprocess (RFC 006 Tier D reads SVN viasvnadmin dumprather than linkinglibsvn), which contains any memory-safety fault in that C code in a separate address space where it cannot corrupt brygge’s process or defeatforbid(unsafe_code)(→ C-4b). -
C-2f — source identifiers are verified, not trusted (PR-4, VF-2). brygge preserves a source’s own object ids (a Git SHA, an hg node) as the link back to the source. A crafted repository could present content under an id it does not hash to, and brygge would then publish a false link.
- Git: every object whose content or links reach the IR is re-hashed with the repository’s hash kind and compared with the id it was requested by; a mismatch stops the decode. That covers commits, trees, blobs, and every tag on a tag chain. History is walked from verified commits only: the commit-graph cache, an unverified index of parent ids, is not consulted, and a walk that disagrees with verified commit content is a read error. The SHA-256 object format is refused until the reader supports it.
- Mercurial: every revision brygge reads (changelog, manifest, filelog) is checked against its node with Mercurial’s own revision hash,
sha1(min(p1, p2) ‖ max(p1, p2) ‖ raw text), using a collision-detecting SHA-1 as Mercurial does. A mismatch, or a detected collision, stops the decode. A filelog’s store name, including a hasheddh/name, is computed from the logical path with Mercurial’s own encoding, so a wrong or missing file is a read error, never a silent skip. Revisions whose stored text is not the hashed text (ellipsis, external storage) and unknown revision flags are refused by name. The repository identity is taken from the smallest published root, which is read and therefore verified. - SVN: every checksum a dump states (
Text-content-md5/-sha1,Text-delta-base-*,Text-copy-source-*) is checked on every node, and a mismatch stops the decode. This is consistency, not authenticity: the dump is untrusted and can state any checksum. It catches a corrupt dump, a delta applied to the wrong base, and a fault in brygge’s own delta application.svnrdumpwrites MD5 only, hencemd-5.
-
C-2g — the parsers are tested adversarially, not only by example (RFC 014). Every parser of untrusted bytes (RCS, the SVN dumpstream and svndiff, the hg revlog, its metadata files and its store encoding, the IR artifact reader) and
verify’s checks on a received artifact are fed format-aware mutations of real seeds: boundary values at length, count and size fields, and at every declared ceiling. Each must giveOkwithin its ceiling, or a typed error; never a panic, a hang, or an over-ceiling result. The tests run on stable Rust, in the ordinary suite. A quick depth runs on every push. A deep depth runs under an OS memory cap whenever parser code orCargo.lockchanges, and at each release cut, so an allocation that escapes a ceiling kills the run (proven against the RUSTSEC-2026-0344 decoder). Every finding becomes a permanent regression test.
T-3 (Tampering) — altering the import, or stripping its honesty
An attacker (or accident) modifies the IR between decode and encode, or strips derived-marks / loss-boundary / provenance so the output looks more trustworthy than it is (A-IMPORT).
-
C-3a — inconsistency is detectable (VF-3; CR-02).
brygge verify, which needs no source, runs seven checks, and each can fail:- integrity: the contract version and digest;
- structure: parents exist and precede their children, refs target atoms, ref names are unique per kind, and there is at most one op per path per atom;
- replay: replaying each atom along its first parent is consistent (adds target absent paths; modifies, deletes and replaces target present ones);
- derivations: every derived record carries the parameters its kind requires (for example, a reconstructed CVS changeset needs its window, keys, date rule and confidence rule);
- source-invariants: an atom’s status fits its source kind, so a CVS artifact relabelled
Statedfails even with its ids and digest recomputed; - provenance: it names its decoder, versions and source;
- loss-boundary: the loss boundary is present and well-formed.
The verdict is three-valued:
pass,fail, orincomplete(a requested--against-sourcecould not run). It is never reported aspasswith a non-zero exit. -
C-3b — the artifact is integrity-checkable and versioned (IX-07; RFC 011). The IR carries its contract version and a content digest, so tampering or truncation is detectable rather than silent (this is detectability, not authentication — see RR-4).
-
The version gate runs first: an artifact of an unknown contract is refused before anything else is parsed.
-
The digest covers the logical content (since 0.7.0, contract 0.3.0, RFC 018 D-3): the uncompressed stream the frames give, never a re-encoding, and never the compressed bytes. It is a function of the IR alone, because the store order and the frame packing are fixed by the contract and checked by the reader. A 0.2.0 artifact’s digest covers its stored bytes, as before.
-
The canonical form is strict at the logical level: a non-canonical encoding of the same content is refused, so no two logical streams mean one artifact. Two files that differ only in compression are one artifact, with one digest, by design.
-
Decompression is bounded before it allocates (since 0.7.0, RFC 018 D-1; reviews 099 and 101):
- every frame’s declared size is checked against the packing plan, which the blob table fixes, before its stored bytes are read;
- a DEFLATE frame may not claim more than DEFLATE’s maximum expansion;
- inflation streams through a fixed 64 KiB buffer, stops at the declared size, and refuses a stream that is longer, shorter, or leaves stored bytes unconsumed.
So a small artifact cannot claim a large allocation. An artifact of about 256 KiB that inflates to 256 MiB, 16 times the bound, passes through
verifywithin a 16 MiB peak, measured in a child process; that test fails, never skips, on Linux. The lesson of RUSTSEC-2026-0344 (C-2d) applies here too. -
Evolution is safe by construction: each field carries a critical bit. An unknown critical field is refused, and an unknown non-critical field is skipped and reported, never silently ignored.
-
One pass, and nothing read twice unchecked (since 0.5.0, RFC 015 D-4). The reader streams the file once: it feeds every byte into the digest, checks the canonical order, and hashes each blob as it passes, keeping only the metadata and an index. Nothing is accepted before the digest matches. A blob read later, from the same open file, is re-hashed against its content address; a mismatch is
ArtifactChanged. So a file that changes while brygge reads it can never be parsed as bytes other than those it verified.from_bytesis the same parser over memory. Since 0.7.0, a blob read later re-inflates its frame under the same bounds, and is still re-hashed.
-
-
C-3c — determinism catches divergence (VF-1, C-9). A fresh re-decode of the same source under the same version reproduces the IR; a tampered artifact diverges from the reproduction.
verify --against-sourcereportsnot-checked(verdictincomplete), neverfail, when the source given is a different form from the one recorded (an SVN dumpfile versus a live repository). It compares SVN decodes with the recordedsvnadminversion aligned, noting a version difference rather than failing on it.- Across brygge versions (since 0.7.0, review 106 V-1). The IR records which brygge and decoder made it, and every derivation records its decoder’s version, which its atom’s id covers. Until 0.7.0, the comparison therefore reported every artifact made by an earlier brygge as
does-not-correspond, a false claim of tampering. Now, when the versions differ, the re-decode is re-stamped to the artifact’s versions and rebuilt (Ir::restamped), then compared: an identical history iscorresponds, with a note naming both versions; a different one isnot-checked(verdictincomplete), naming the version to re-run with, because a newer decoder may decode differently and legitimately. With equal versions, the comparison is strict, as before. - The cost, accepted: an attacker who also edits the recorded version turns a
failinto anincomplete. That is never apass, its exit code is non-zero, and the report names the recorded version.restampedis never written by the CLI, so it cannot relabel an artifact.
- Across brygge versions (since 0.7.0, review 106 V-1). The IR records which brygge and decoder made it, and every derivation records its decoder’s version, which its atom’s id covers. Until 0.7.0, the comparison therefore reported every artifact made by an earlier brygge as
-
C-3d — a transform records itself, and brygge checks it (since 0.7.0, contract 0.3.0, RFC 018 D-5/D-6). A transform (an IR → IR program) could otherwise launder history: change an author, remove a file, and present the result as the decoder’s original, the T-3 archetype.
-
The record, in the artifact:
- a chain of records, each naming the transform, its version and parameters, and the digest (C-3b) of the artifact it read, so the chain links back to the decoder’s original;
- a
Transformedstatus on every atom, op and ref a transform changed, naming exactly the changed parts from a closed vocabulary, and keeping the prior status, so an earlierDerivedis never erased; - a
Transformloss for everything removed, naming exactly one thing (atom,op,copyorref).
The reader refuses a malformed chain (C-3a), and a 0.2.0 artifact carrying any of it.
-
The check, at brygge’s boundary (TB-7):
brygge transformverifies the input first, runs the plugin into a temporary file, reads the output as untrusted input, and runstransform::checkagainst the input:- one new record, citing the input’s digest;
- provenance, flags and earlier records unchanged;
- every difference marked, exactly, in both directions;
- every removal recorded;
- nothing added (no atom, no op without an input op).
On any failure it deletes the file, writes nothing, and exits 50. The check is a public function, so anyone holding both artifacts can run it, and
transform::Editbuilds outputs that pass it by construction. -
Back to the source:
verify --against-sourceon a chained artifact re-decodes and compares the result’s digest with the chain’s first record. The verdict isroot-corresponds(CVS:root-reproduces), naming how many steps were not re-run; never plaincorresponds. -
What it cannot do is check a step run outside
brygge transform(RR-transform-trust).
-
T-4 (Supply chain) — the heavy dependency surface
The decoder libraries (~100 crates for gix, or C for libgit2, plus SVN/CVS) are the largest attack and audit surface, and the reason brygge is separate from prikk (A-SUPPLY, PU-5).
- C-4a — isolate the weight behind the decoder boundary. The heavy deps live only in the per-source decoder crates; the IR, the honesty/verify path, and the encoders do not link them. VF-3 (internal verification) must run without any decoder dependency present — the internal analogue of BN-5.
brygge-ir’s closure is a committed allowlist (crates/brygge-ir/allowed-dependencies.txt), checked bytools/check-ir-isolation.shfor every target platform at once (cargo tree --target all, since 0.6.0): before, the check ran for the host only, and missedlibc, whichsha2pulls in throughcpufeatureson aarch64. Since 0.7.0 the closure also holdsminiz_oxideandadler2(RFC 018 D-4, approved by the owner under RFC 009 D-6): pure Rust,forbid(unsafe_code), already in the lock file. They are not pinned with=, so a crate that linksbrygge-irkeeps its own resolution; a golden-bytes test shows when an upgrade changes the file bytes (never the digest, C-3b).examples/encode-gitproves PU-3 against the same allowlist: an encoder onbrygge-iralone. - C-4b — pure-Rust preferred; C isolated by FFI crate or subprocess. Prefer pure Rust (e.g.
gix, keepsforbid(unsafe)maximal) over a C library (e.g.libgit2). If C code is unavoidable for a source, isolate it — in preference order: (1) a pure-Rust reader (no C at all — the ideal); (2) a subprocess that produces a parseable stream brygge reads in pure Rust (RFC 006 SVN Tier D:svnadmin dump→ brygge’s own dumpstream parser) — the C fault surface is a separate process, not brygge’s address space, and vanishes entirely when the operator supplies the dumped stream directly; (3) a single dedicated FFI crate — the one placeunsafe/C is linked into brygge, mirroring prikk’sprikk-ffidiscipline — used only when neither (1) nor (2) is available. The subprocess (2) is stronger isolation than the FFI crate (3) and is preferred wherever the source ecosystem offers a suitable tool. - C-4c — pin and lock. Exact dependency versions; the lockfile is committed; upgrades are deliberate and reviewed. A security fix may raise the MSRV, when the only patched version needs it (0.3.1: 1.85 to 1.87, for
ruzstd0.9.1). The MSRV job in CI proves the new floor. - C-4d — supply-chain gates in CI.
cargo-deny(advisories, licenses, banned/duplicate crates) andcargo-auditrun in CI; a new advisory fails the build. New or upgraded decoder dependencies get explicit architect review (governance). The advisory watch (advisory-watch.yml) runscargo auditagainst the newest advisory database with no code change. It is brygge’s only scheduled job: a new advisory is an external event with no trigger in the repository, so it is polled (GOVERNANCE.md, “Work is triggered, never scheduled”). The isolation ofbrygge-ir(C-4a/C-5) is enforced in CI against a declared allowlist of its dependency closure (tools/check-ir-isolation.sh), not merely observed. - C-4e — minimize. The dependency set is kept as small as the mission allows; a dependency is justified, not defaulted-in.
- C-4f — the release pipeline publishes only what was verified, on the owner’s go-ahead (RFC 012;
release.yml). A compromised pipeline could publish a maliciousbryggeto everycargo installuser, so it is the place brygge holds its only publish credential. The pipeline enforces:- What is released:
- an annotated
X.Y.Ztag, onmain, equal to the workspace version, with its CHANGELOG section; - gated by the same reusable workflow as CI, on the tagged commit;
- built for the four CI-proven platforms before anything is published, unless a dispatch turns the binaries off (as for 0.1.0, whose release has none, and whose gates run on Linux only). Publication is all-or-nothing behind these checks.
- an annotated
- Who authorizes it: the owner’s explicit go-ahead, given before the architect pushes the tag
(
GOVERNANCE.md); the tag push starts the publication. (A per-release approval gate in thereleaseenvironment was used for 0.1.1 and removed for v0 by owner ruling, RFC 012 D-2.) Thereleaseenvironment stays, without a reviewer: it scopes crates.io trusted publishing, and it admits onlymainand release tags. A published version’s tag is never moved or deleted: a governance rule (GOVERNANCE.md), not a GitHub ruleset. It was deliberately not mechanized in v0 (RFC 012 D-2, amended), because crates.io versions cannot change anyway. - What the credential is: crates.io trusted publishing issues a token that lasts minutes, to this
workflow in this environment; no crates.io token is stored anywhere.
- Permissions are least-privilege per job (
contents: readby default;id-token: writeonly where a token is minted;contents: writeonly for the GitHub release). - Every third-party action in
release.ymlis pinned to a commit SHA. - No workflow expression is interpolated into a shell script.
- The release tools refuse a versioned dev-dependency on an unpublished crate, which a publish dry-run
cannot see before the cut (
tools/check-release-dev-deps.sh).
- Permissions are least-privilege per job (
- What was released is checked:
- after publication,
bryggeis installed from crates.io and smoke-tested; - every published crate is compared byte for byte with the tag;
- binaries carry SHA-256 checksums and GitHub build-provenance attestations
(
gh attestation verify).
- after publication,
- The AUR packages (since 0.5.0, RFC 016):
brygge, built from the tag’s source archive, andbrygge-bin, the release’s binary. Theaurjob runs only after the GitHub release succeeds:- it verifies each Linux binary’s attestation before rendering anything;
- it builds both packages in an
archlinux:base-develcontainer pinned by digest, as an unprivileged user.bryggeruns the full test suite (check());brygge-binis checked to install the attested binary byte for byte (makepkg’s stripping is off), and the job fails otherwise; - it clones the AUR repositories anonymously over HTTPS. The SSH key (RR-aur-key) is written to a mode-0600 file only in the push step, and removed whatever the outcome;
- the AUR host key is pinned in
packaging/aur/known_hosts; the host key is never accepted on first use; - an AUR failure after a release is reported as “released; AUR not updated”, never as a green run.
- What is released:
T-5 (Elevation) — brygge output enlarging the target’s audited surface
A design in which consuming a brygge import forces the target to link a brygge dependency would defeat the whole separation: prikk’s deliberately small audited dependency surface would grow through the back door (A-TARGET-TRUST, BN-5).
- C-5 — the boundary is a tested property (CT-05). The IR, the proposal, and internal verification (VF-3) are consumable and checkable with only the target’s own dependency surface — no brygge decoder dependency required downstream. This is verified by a test that consumes brygge output with none of brygge’s decoder deps present.
T-6 (Information disclosure) — leaking source secrets, or importing them unknowingly
Source history may contain committed secrets, private emails, GPG signatures, and internal paths. Threat: brygge exfiltrates them (network/telemetry/logs), or the operator imports secrets without realizing they travel (A-SOURCE-CONTENT).
- C-6a — no network, no telemetry (INV-3). brygge reads sources and writes operator-specified files only (CT-01). There is no phone-home, no analytics, no remote fetch during decode (submodules are refused, not fetched — C-2b).
- C-6b — no content in logs beyond the operator’s chosen surface. Diagnostics name atoms, classes, and counts; they do not dump source content into logs that could outlive the operator’s intent.
- C-6c — carried-verbatim is stated, not silently scrubbed. brygge preserves source content faithfully (VF-2 depends on it), so it must not silently redact — but the fidelity surface states plainly that content is carried verbatim from source, so the operator knows secrets-in-history come along and can act in the source before import. brygge names what it does not do; scrubbing is the operator’s pre/post step (RR-3).
- C-6d — only what the source would publish is imported (CR-05). Some history in a repository was never meant to leave it.
- Git: history comes only from the carried namespaces (
refs/heads/*,refs/tags/*). Commits reachable only from stash, notes, remote-tracking or other refs are not imported, and they are counted. - Mercurial: brygge computes the repository’s published view (what
hg clonewould share). Secret, archived and internal-phase changesets, and hidden (obsolete) ones, are not imported, and they are counted. - A migration therefore cannot carry a changeset the source marked private.
- Git: history comes only from the carried namespaces (
T-7 (Elevation) — confused deputy / errant writes
A source with crafted paths tries to make brygge write outside --out (A-HOST).
- C-7 — write only where told. brygge writes one file, the artifact at
decode --out; source-derived paths are never write targets (C-2c). This mirrors stikk’s “never write inside a repository” discipline, one boundary over. The write is atomic: a temporary file in the same directory, synced, then renamed over the target. An interrupted or failed decode leaves the previous artifact intact, never a truncated one.- The spill file (since 0.5.0, RFC 015 D-3). While it decodes, brygge keeps file content in one temporary file instead of memory: in
--spill-dir, which must already exist, or else the output’s directory. It is created withcreate_newand mode 0600 under a unique.brygge-spill-…name. On Unix its directory entry is removed as soon as it is open; on Windows it is opened delete-on-close. So it is private while it exists, and gone when the process ends, however it ends. Its location never reaches the IR or the provenance, and it never changes the artifact. A write error, a full disk included, is a typed error naming the directory, and no artifact is written.verify --against-sourcespills its re-decode under the same rules. - The transform output (since 0.7.0, RFC 018 D-6).
brygge transformwrites one more file: a temporary file in--out’s directory, created withcreate_newand mode 0600 under a unique.brygge-transform-…name, which the plugin writes. It is not unlinked, because the plugin needs its path. It is deleted on every refusal path (a plugin failure or signal, a failed verify, a failed check), and on success renamed over--out, atomically.--outmay not be the input. An interrupt of brygge itself can leave it behind; it holds only what the plugin wrote.
- The spill file (since 0.5.0, RFC 015 D-3). While it decodes, brygge keeps file content in one temporary file instead of memory: in
T-8 (Denial of service) — resource exhaustion
Enormous repositories, pathological delta chains, deep trees, huge file counts, decompression bombs (A-HOST). (Called out separately from T-2 because it is a normal operating condition for real migrations, not only an attack.)
- C-8 — bounded and honest at the limit. A ceiling hit is a typed refusal with a named reason (FA-3, C-2d), never an OOM that leaves an ambiguous artifact. An interrupted run leaves no artifact, or the previous one intact (C-7); brygge does not write partial artifacts.
- Not built: progress reporting and graceful cancellation (OP-02). Interrupting brygge simply stops it. That is safe because of C-7, but it gives no progress and produces no labelled partial.
- Built in 0.5.0 (RFC 015): content is held on disk while decoding (C-7’s spill file), the artifact is written and read as a stream (C-3b), and memory follows the metadata rather than the content. What remains is RR-total-memory.
T-9 (Tampering) — non-determinism as a trust hole
If brygge is non-deterministic, “faithful” is uncheckable (VF-1 fails) and a tamper can hide in the noise (A-IMPORT).
- C-9 — determinism is a security property. The same inputs yield byte-identical IR and proposal; any non-determinism brygge cannot avoid is named as a stated non-determinism, never left to silently perturb output. Since contract 0.3.0, the digest is reproducible for the same brygge version, source and parameters whatever the codec’s version, and the file bytes are reproducible for the same brygge build (C-3b); parallel compression keeps them byte-identical to a serial write. Since contract 0.2.0, the IR carries no import time, so no stated non-determinism remains in the IR itself. The one input-side dependency is the
svnadminversion for a live SVN decode (RR-svn-svnadmin-version). prikk ruled that an import attestation’screated_atis a fixed sentinel (UD-4), so the proposal adds none either.
4. Security invariants (INV-…) — the non-negotiables
A change that breaks one of these is a security bug, not a preference. Several must be enforced by test.
- INV-1 — No manufactured verification. Imported authorship is
Unverifiableby construction; honesty (derived-marking, loss boundary, status, fidelity summary) is a property of every produced object and is not configurable off. (T-1) - INV-2 — Source input is untrusted, and brygge never executes source-provided code. No hooks, filters, submodule fetches, or scripts are run; all source-driven resource use is bounded. (T-2/T-8)
- INV-3 — No network I/O; writes only to operator-specified outputs. (T-6/T-7)
- INV-4 — The dependency surface is isolated, minimized, pinned, and audited, on every target platform; brygge’s own crates
forbid(unsafe_code); any C code lives only in a dedicated FFI crate or a subprocess (C-4b). (T-4) - INV-5 — brygge output never enlarges the target’s audited surface — consumable and internally verifiable with the target’s own dependencies alone. (T-5)
- INV-6 — Determinism and object-carried, recoverable provenance are integrity controls. (T-3/T-9)
5. Residual risks & assumptions (RR-…, ASSUME-…)
- RR-1 — The heavy decoder dependencies may contain vulnerabilities. This is the accepted cost of the mission (it is why brygge is separate from prikk). Mitigated by isolation (C-4a), pure-Rust preference (C-4b), pinning + supply-chain gates (C-4c/d), and the recommendation that operators run brygge over untrusted source repositories in a sandbox (container / restricted user / no ambient credentials), since TB-1 input reaches those libraries. (v0.4 note:
cargo auditreports RUSTSEC-2026-0306, an informational “unsound” advisory againstfaster-hex 0.10.0, reached only throughgix-hash. It is tracked by the advisory watch and reviewed with every dependency update. 0.7.1 note: nine informational advisories againstheapless0.8.0, linked through the samefaster-hex, are not reachable (see the 0.7.1 re-verification); 0.8.0 note:faster-hex0.10.1 fixes 0306, and it is semver-compatible withgix-hash0.26, sogixstays at 0.87. The nineheaplessadvisories stay, unreachable, on everygixversion released so far, becausegix-hashstill usesfaster-hex0.10; they clear when it moves tofaster-hex2, whereheaplessis optional.) - RR-2 — brygge cannot make a lying source honest. A faithfully-imported falsehood is still a falsehood; VF-2 checks correspondence to the source, not the source’s own truthfulness. Detecting source-level fraud is out of scope.
- RR-3 — Secrets/PII in source history are carried faithfully. Redaction would break fidelity (VF-2) and is the operator’s decision in the source, before or after import; brygge’s duty is to state that content is carried verbatim (C-6c), not to scrub it.
- RR-4 — brygge’s artifact is integrity-detectable (C-3b) but not cryptographically authenticated, and brygge never signs. prikk ruled on 2026-09-13 (RFC 113 OQ-1/OQ-2) that the importer signs the import declaration, and that the importer is prikk’s own import command, run by an adopted maintainer. Authentication therefore happens at prikk’s boundary, over what that maintainer imports, once prikk’s import attestation (UD-1) is built. Until then, anyone who can alter an artifact can also recompute its digest; the defense is
verify --against-source(C-3c) against the source. - RR-gix-sha1 —
gixreads SHA-1 Git objects without collision detection (RFC 004 security review; relates to RUSTSEC-2025-0021, cleared as an advisory by pinning forward). This is inherent to SHA-1 repositories and does not touch brygge’s integrity model: the IR re-hashes everything under SHA-256 (AtomId/BlobId/digest, RFC 003 D-3), and the Git SHA-1 is preserved opaquely as a source identifier (PR-4), trusted for nothing in any target. The residual is source misread under a deliberate SHA-1 collision, mitigated by SHA-256 re-hashing andverify --against-source(RFC 004 D-7). Narrowed in v0.3: since every object is now re-hashed against its id (C-2f), a mismatched object is impossible; only a true SHA-1 collision remains. Trackgix’s SHA-256-object support as it matures (the SHA-256 object format is refused until then). - RR-svn-svnadmin — brygge trusts the operator’s
svnadminbinary and its dump output (RFC 006 Tier D; TB-4). A hostile or compromisedsvnadminon the host could feed a false dumpstream; mitigated by ASSUME-1 (the host is trusted) and by the dumpfile path, which bypasses the subprocess entirely. Separately,svnadminparsing a hostile repository is a semi-trusted-tool surface (a TB-2 variant in subprocess form), isolated by process (C-2e/C-4b) and covered by RR-1’s sandbox recommendation for untrusted sources. - RR-svn-svnadmin-version — decode of a live SVN repository depends on the
svnadminversion (RFC 006 Tier D): two versions could frame the dumpstream differently, so the byte-for-byte result across hosts is guaranteed only for the same tool version. Named as a stated non-determinism (C-9), mitigated by treating the dumpstream as the canonical deterministic input (decoding the same dumpfile is always identical) and recording the source form (live dump vs supplied dumpfile) in provenance soverify --against-source(VF-2) is well-defined. Implemented in 0.1.0: provenance recordssource_form, plussvnadmin_version(neutralized, bounded) for a live decode;verify --against-sourcerefuses to compare across forms (not-checked) and aligns the version before comparing (C-3c). - RR-cvs-reconstruction — a CVS changeset is brygge’s derived judgment, not a source record (RFC 007). A consumer that ignores the
Derivedstatus could over-trust the grouping as if CVS had recorded it. The marking is in every atom; the confidence rule (span-overlap-v1), its inputs and every order split are recorded; the fidelity report leads with it; and the faithfulness statement states the limit before the run. The residual is a consumer discarding honesty brygge attached, which brygge cannot prevent, only make impossible to lose (the CVS-specific sharpening of RR-2). Since 0.3.0 it covers branch history too: a branch’s parent edge is brygge’s judgment (branch_point_rule, andbranch_pointexact, approximate or unconstrained, with approximate flagged), and a branch-point atom’s ops areDerived; no merge parent is ever inferred. - RR-cvs-open-blocking (replaces RR-cvs-read-toctou, closed in v0.5): on Unix the CVS reader’s
openis an ordinary one, and the identity check follows it. So someone who can swap a,vpath for a FIFO while brygge reads could make thatopenblock: a hang, never a read of the wrong file. This needs concurrent write access to the source, a compromise of A-HOST (ASSUME-1). It is not mechanized in v0, because a non-blocking open needs a per-OS constant or a dependency. - RR-release-agent-credentials — the AI agents (architect, implementer) act through the owner’s own git
and GitHub credentials, so GitHub cannot tell them apart from the owner (RFC 012 D-2).
- Nothing mechanical stops an agent from creating, moving or deleting a tag.
- With no approval gate, pushing a release tag is the act that publishes, so an agent that pushed a version tag could start a publication.
- Mitigations:
GOVERNANCE.md(“Cutting a release”) and the agents’ standing instructions: only the architect tags, only after the owner’s go-ahead, and the implementer never tags;verify’s checks narrow what such a tag could publish to a commit onmain, at the workspace version, with a CHANGELOG section and green gates;- two-factor authentication on the owner’s accounts.
- RR-release-dispatch-tools — a dispatched release runs the release tools of the commit it was dispatched
from, not of the tag (needed to release a tag that predates the tools, like 0.1.0).
- Mitigation: the
releaseenvironment admits onlymainand release tags, so those tools are always code committed tomainor to a release tag. It is reviewed by the project’s process, not enforced by a branch rule: RFC 012 D-2 deliberately adds no branch protection, and CI gates such a commit after it is pushed. - The tools’ test-only environment hooks (
BRYGGE_TEST_*) are set by no workflow, andverify-publishedchecks the real crates.io independently.
- Mitigation: the
- Closed in v0.3:
- RR-git-loose-object-symlink (a symlinked loose object could read outside the repository): a loose object now either hashes to its id, so it is the right object wherever it was read from, or the decode stops (C-2f).
- RR-git-object-id-unverified (a preserved Git id could be a false link): every object is verified (C-2f).
- RR-hg-node-unverified (the same gap for Mercurial nodes, found in the 0.1.0 release review): every revision read is verified (C-2f).
- RR-total-memory — no aggregate memory ceiling. C-2d’s ceilings bound each object, never the total. A large legitimate repository can therefore still exhaust the host’s memory, rather than being refused with
ResourceLimit. Narrowed in v0.9 (0.5.0, RFC 015): content no longer sits in memory, so the peak follows the metadata (commits, trees, paths), not the content. For fish-shell (23,496 commits; 4.6 GiB of content),decodefell from about 18.7 GiB to about 410 MiB,verifyandinspectfrom about 9.1 GiB to about 64 MiB, andverify --against-sourcefrom about 14 GiB to about 472 MiB (tools/bench/README.md). What remains:- the metadata still grows with the history, without a total ceiling;
- the cost moved to disk: the spill file holds every unique blob uncompressed. Since 0.7.0 the artifact is compressed, 4.6×–7.5× smaller on the measured repositories, so the spill file is now the larger of the two. A full disk is a typed error (C-7), not a hang;
decodecompresses on up to 8 threads, with at most 64 MiB of raw frames in flight: a constant of about 100 MiB more than 0.6.0, which does not grow with the repository;- a RAM-backed
--spill-dir(tmpfs) moves the cost back into memory. The operator’s sandbox (RR-1) should still bound memory and disk.
- RR-aur-key — the AUR packages are published with a stored SSH key (RFC 016). The AUR offers no short-lived credential like crates.io’s trusted publishing, so the secret
AUR_SSH_PRIVATE_KEYlives in the GitHubreleaseenvironment.- What it could do if stolen: push to every package the owner’s AUR account maintains, not only
bryggeandbrygge-bin, since AUR keys are per account. A PKGBUILD is a shell script thatmakepkgruns on the user’s machine, so a malicious push is code execution for whoever next builds the package without reading it. - Mitigations:
- the key is generated for this use only, and lives only in the secret (
docs/src/development/releasing.md, “AUR”); - the
releaseenvironment admits onlymainand release tags (RR-release-dispatch-tools); - the job writes the key only in its push step, never on a dry run, and removes it whatever the outcome; the host key is pinned;
- every AUR commit is public, under the owner’s identity, and the AUR’s own convention is that users read a PKGBUILD before building it;
- if the key is suspected leaked: remove it from the AUR account first, then replace the secret (
releasing.md).
- the key is generated for this use only, and lives only in the secret (
- It is accepted for v0. If the AUR gains a short-lived credential, the job should move to it.
- What it could do if stolen: push to every package the owner’s AUR account maintains, not only
- Disclosed and closed in v0.8: five CVS RCS-reader defects (never listed as residuals, because they were unknown until C-2g found them), in 0.1.0–0.3.1: an infinite loop on a truncated
symbols/brancheslist; an apply loop spun by a crafted ed-script line number; a pre-allocation sized by an untrusted count; a subtraction panic on a malformed revision number; and a million-step walk on a cyclicnextchain. Each is closed in 0.4.0, with a regression test. - Disclosed and closed in v0.7: the zstd decompression gap (it was never listed as a residual, because it was unknown until RUSTSEC-2026-0344): a crafted zstd revlog chunk could exhaust memory in 0.1.0–0.3.0. It is closed in 0.3.1 (C-2d).
- Closed in v0.6: RR-svn-special-toggle (a property-only change of
svn:specialkept the previous content): the node’s content is recomputed from its base’s SVN text under the new flag, and malformed symlink text is still refused (C-2a). It is checked againstsvn catin all three dump forms. - Closed in v0.5: RR-cvs-read-toctou (a symlink swapped in between the walk and the open would be followed): the opened file must be the walked file (C-2c).
- RR-plugin-trust — an encoder plugin runs with the operator’s privileges, and brygge does not vet it (RFC 017 D-3; TB-6). Whatever program is first on
PATHasbrygge-encode-<target>is the one that runs, as with any command onPATH,gitandcargosubcommands included.- Mitigations:
- the lookup rules (C-2b);
- the label, which prints the resolved path before the plugin runs (C-1g);
brygge encode --list, which shows every plugin found, and marks one hidden by an earlierPATHentry as shadowed;- and verify-first, so a plugin never receives an artifact brygge rejects.
- What brygge’s check does not cover: it verifies the file when it checks it. A plugin that reads the artifact with
brygge-irgets the same checks again,ArtifactChangedincluded; a plugin that parses the bytes itself gets nothing from brygge. The guide says so. - It is the operator’s trust choice, as ASSUME-1 already states for the host.
- Mitigations:
- RR-transform-trust — a transform’s honesty is checked only where brygge runs it (RFC 018 D-6; TB-7).
- A transform plugin runs with the operator’s privileges, as an encoder plugin does (RR-plugin-trust), with the same mitigations.
- Inside
brygge transform, its output cannot lie about its own shape: C-3d checks every difference against the input. Whatcheckcannot judge is whether the transform’s change was wise (a wrong author mapping is a marked, honest wrong mapping). - Outside it, anyone can write a well-formed 0.3.0 artifact with
brygge-ir’s writer, with or without a chain. Such a file is not checked at transform time. The defence is--against-source: an artifact whose content differs from its source’s decode and carries no chain (a forgery that hides its transform) givesdoes-not-correspond; one whose chain’s root is not the source’s decode gives the same. A reader holding a step’s input can runtransform::checkitself. - It is the same class as RR-4: the artifact is integrity-detectable, not authenticated.
- ASSUME-1 — The operator and their host are trusted; the source repository is not. brygge defends A-HOST against the source (TB-1), not against a hostile operator.
- ASSUME-2 — The target enforces its own admission/trust/seal (BN-2). brygge’s honesty is necessary but not sufficient; the target’s policy is the last line, and OQ-1…OQ-3 (owner’s) decide what that policy is for prikk.
6. Controls × threats
| Control ↓ / Threat → | T-1 | T-2 | T-3 | T-4 | T-5 | T-6 | T-7 | T-8 | T-9 |
|---|---|---|---|---|---|---|---|---|---|
| C-1a…e honesty in the object | ● | ● | |||||||
| C-1f output neutralization | ● | ● | |||||||
| C-1g encoder output labelled, verify first | ● | ○ | |||||||
| C-3d transforms recorded and checked | ● | ● | |||||||
| C-2a…e untrusted-input handling | ● | ○ | ● | ● | |||||
| C-2f source identifiers verified | ○ | ● | ● | ||||||
| C-3a…c integrity/verify/determinism | ● | ● | |||||||
| C-4a…e dependency isolation/audit | ○ | ● | ○ | ||||||
| C-4f the release pipeline | ○ | ● | ● | ||||||
| C-5 boundary-not-enlarged (tested) | ○ | ● | |||||||
| C-6a…c no-network / carried-verbatim | ● | ○ | |||||||
| C-6d only what the source would publish | ● | ||||||||
| C-7 write-only-where-told | ○ | ○ | ● | ||||||
| C-8 bounded/cancellable | ○ | ● | |||||||
| C-9 determinism | ○ | ● |
(● primary control, ○ contributing.)
7. Traceability
| Threat-model element | Requirements / design basis |
|---|---|
| T-1 / C-1* / INV-1 | NG-3, HO-1…HO-5, VF-4, FS-01/02/04, CF-02; RFC 113 §2/§3; C-1f: CL-07, CR-19; C-1g and TB-6: RFC 017 D-1/D-3, CL-03 (amended) |
| T-2 / C-2* / INV-2 | TB-1, FA-2/FA-3, PR-4; PU-5 (why the surface exists); C-2c: CR-11; C-2d: RFC 010 D-4, CR-10/CR-17; C-2f: PR-4, VF-2 |
| T-3 / C-3* / INV-6 | VF-1/VF-3, IX-07, HO-4, FS-02, ID-4; C-3a: CR-02, RFC 011 D-10; C-3b: RFC 011, RFC 015 D-4, RFC 018 D-1/D-3; C-3d and TB-7: RFC 018 D-5/D-6, CL-09 |
| T-4 / C-4f | RFC 012 (release automation); RFC 016 (the AUR packages); GOVERNANCE.md “Cutting a release”; docs/src/development/releasing.md |
| T-4 / C-4* / INV-4 | PU-5, BN-5; project dependency-discipline (mirrors prikk’s small, audited dependency posture and prikk-ffi) |
| T-5 / C-5 / INV-5 | BN-5, CT-05 |
| T-6 / C-6* / INV-3 | CT-01, NG-3, PR-3/PR-4; C-6d: CR-05, owner ruling D-4 (2026-09-23) |
| T-7 / C-7 / INV-3 | BD-04, CT-02; CR-13; the spill file: RFC 015 D-3/D-3a |
| T-8 / C-8 | FA-1/FA-3/FA-4/FA-5, OP-02; RFC 015 |
| T-9 / C-9 / INV-6 | VF-1, ID-4, UD-4 |
End of Threat Model v0.11. Per project rules, this document is revisited every release: a release whose changes touch new source parsers, new dependencies, the IR/provenance format, or any untrusted-input path updates this model; other releases re-verify its controls still hold. The controls most likely to need a test from day one: INV-2 (no source code executed; path-safety), INV-4/INV-5 (dependency isolation; output consumable without brygge deps), and INV-1 (honesty is present and non-suppressible in every produced object).