Threat model: what we defend against and what we accept #99

Closed
opened 2026-11-11 22:02:57 +00:00 by Claude · 2 comments
Owner

Part of #87

Question

Against which actors and mistakes does this repository defend, with which cheap measures, and which risks are explicitly accepted? Recorded as this repository's first ADR.

Context

  • Decided already: friends are trusted but fallible; take the low-hanging fruit against malice; write down what is not done.
  • Known weaknesses: workflows and check scripts load from the pull request head, so a pull request can remove its own gate; a same-repository pull request reaches the organisation secrets and runs molecule with root on the runner; nothing checks for pull_request_target or stray secret references; the bot-diff guard keys on a branch name.
  • Candidate defences: protected file patterns on workflows and check scripts, CODEOWNERS, a CI check for pull_request_target and secret references, judge scripts run from the base branch.
  • Candidates to explicitly not do: ephemeral runners, signed commits, a CLA.
  • Anyone who can push a branch can run arbitrary workflows; branch protection does not prevent that.
Part of #87 ## Question Against which actors and mistakes does this repository defend, with which cheap measures, and which risks are explicitly accepted? Recorded as this repository's first ADR. ## Context - Decided already: friends are trusted but fallible; take the low-hanging fruit against malice; write down what is not done. - Known weaknesses: workflows and check scripts load from the pull request head, so a pull request can remove its own gate; a same-repository pull request reaches the organisation secrets and runs molecule with root on the runner; nothing checks for `pull_request_target` or stray secret references; the bot-diff guard keys on a branch name. - Candidate defences: protected file patterns on workflows and check scripts, CODEOWNERS, a CI check for `pull_request_target` and secret references, judge scripts run from the base branch. - Candidates to explicitly not do: ephemeral runners, signed commits, a CLA. - Anyone who can push a branch can run arbitrary workflows; branch protection does not prevent that.
Claude added the
Wayfinder
Grilling
label 2026-11-11 22:02:57 +00:00
Claude added a new dependency 2026-11-11 22:03:13 +00:00
Claude added a new dependency 2026-11-11 22:03:13 +00:00
Claude added a new dependency 2026-11-11 22:03:13 +00:00
Claude added a new dependency 2026-11-11 22:03:13 +00:00
Claude added a new dependency 2026-11-11 22:03:14 +00:00
Defame1297 was assigned by Claude 2026-11-14 21:56:45 +00:00
Author
Owner

Resolution (2026-11-14)

Built on Test what a fork pull request can do on this Gitea and Record current repository settings and branch protection. Recorded as this repository's first ADR, docs/adr/0001-threat-model.md (filed below). The ADR follows the ADR rules from Public design contract replacing the ADR 0004 references: one screen, a residual-risk section, no infrastructure detail.

Actors

Actor Defence
A contributor with write access who makes a mistake Controls
A contributor's agent that overreaches (edits a workflow to turn a check green, weakens a gate, adds a secret reference) Controls
An outsider using a fork The approval click, asked again on every push; the approver reads the workflow diff of every push
A malicious or compromised contributor, or a stolen contributor token Cheap measures only; the rest is accepted
A compromised bot or agent token Cheap measures only (least privilege, below)
A compromised upstream (Python packages, hooks, base images) The existing pins, hashes, digests and release age; the rest is accepted

Assets, in priority order

  1. What consumers install: main and the v* tags.
  2. The registry push credential: every later CI run executes the images it pushes.
  3. Contributors' machines: hooks, dev-setup.sh and hook revisions from a branch run locally when someone checks that branch out.
  4. Control of the organisation: branch and tag protection and the secrets.
  5. The runner: rebuildable and isolated, with no production secret.

Trust boundary

Write access is secret access. Anyone who can push a branch can run their own workflow, read every organisation secret and run as root on the runner, all before any review. Branch protection controls what merges, never what runs. So write access goes only to people trusted with the secrets; everyone else contributes through a fork. Consequence for How friends get code in.

Targets and measures

  • Least privilege for tokens: each bot or agent token can do only its own job, and none is an organisation owner. Settings are left to the repository-settings recommendation.
  • Layers against a pull request that removes its own gate:
    • CODEOWNERS with "block on CODEOWNERS review". It covers .gitea/**, scripts/**, renovate.json, .pre-commit-config.yaml, requirements*, galaxy.yml and docs/adr/**, all assigned to the maintainer. Ordinary role changes stay self-mergeable.
    • Dismiss stale approvals, already on.
    • Judge scripts run from main's copy, as bot-diff and molecule selection already do. Rule: every new judge script does the same.
    • zizmor, below.
  • Rule held by review: only image.yml and renovate.yml may reference secrets. CODEOWNERS puts every workflow change in front of the maintainer; there is no custom grep.
  • zizmor (1.32.0, MIT), tested offline on the five workflows. It parses all five when the files are passed explicitly. Default level: no findings. It flags pull_request_target and ${{ }} in run:. Adopted as a pre-commit hook, with files: overridden to .gitea/workflows and the revision pinned by SHA. Condition: it must fit the ci image under the 100 MB layer limit. If the hook's own environment does not fit, zizmor goes into requirements-dev as a language: system hook.
  • Rule for contributors: review an unmerged branch's hook and script changes before running them locally.

Accepted risks

  • The shared runner. One long-lived host runs molecule as root, approved fork runs and the image build that holds the push credential. Anything that gets root can tamper with a later image build. Runner labels are not a boundary, because any workflow can name any label. The planned fix is ephemeral runners (a clean host per privileged job). Trigger: before the first fork approval for someone outside the friends tier, or before write access goes to anyone without secret-level trust. Provisioning the runner is outside this repository.
  • The bot-diff check keys on the branch name. A contributor who names a branch renovate/… only gets stricter checks. The real risk is the bot's token, covered by least privilege.
  • A malicious contributor with write access can read the secrets. Accepted by giving write access only to trusted people.

Not done

  • Signed commits: a signature proves which key signed, not who wrote the change. Tag protection already guards releases.
  • CLA or DCO: GPL-3.0-or-later and REUSE already settle licensing, and the contributors are friends.
  • Signing release artifacts: consumers install from a protected tag.

Not verified

  • How Gitea's protected file patterns interact with an empty push allowlist. They were not adopted.
  • Whether the zizmor pre-commit hook itself runs with the files: override. It was only run directly.
  • Whether the maintainer can approve a pull request opened by the agent account. Expected yes, because it is a different account.
## Resolution (2026-11-14) Built on [Test what a fork pull request can do on this Gitea](https://git.rkdr.net/Mortis/Kamino/issues/89) and [Record current repository settings and branch protection](https://git.rkdr.net/Mortis/Kamino/issues/90). Recorded as this repository's first ADR, `docs/adr/0001-threat-model.md` (filed below). The ADR follows the ADR rules from [Public design contract replacing the ADR 0004 references](https://git.rkdr.net/Mortis/Kamino/issues/92): one screen, a residual-risk section, no infrastructure detail. ### Actors | Actor | Defence | |---|---| | A contributor with write access who makes a mistake | Controls | | A contributor's agent that overreaches (edits a workflow to turn a check green, weakens a gate, adds a secret reference) | Controls | | An outsider using a fork | The approval click, asked again on every push; the approver reads the workflow diff of every push | | A malicious or compromised contributor, or a stolen contributor token | Cheap measures only; the rest is accepted | | A compromised bot or agent token | Cheap measures only (least privilege, below) | | A compromised upstream (Python packages, hooks, base images) | The existing pins, hashes, digests and release age; the rest is accepted | ### Assets, in priority order 1. What consumers install: `main` and the `v*` tags. 2. The registry push credential: every later CI run executes the images it pushes. 3. Contributors' machines: hooks, `dev-setup.sh` and hook revisions from a branch run locally when someone checks that branch out. 4. Control of the organisation: branch and tag protection and the secrets. 5. The runner: rebuildable and isolated, with no production secret. ### Trust boundary **Write access is secret access.** Anyone who can push a branch can run their own workflow, read every organisation secret and run as root on the runner, all before any review. Branch protection controls what merges, never what runs. So write access goes only to people trusted with the secrets; everyone else contributes through a fork. Consequence for [How friends get code in](https://git.rkdr.net/Mortis/Kamino/issues/100). ### Targets and measures - **Least privilege for tokens:** each bot or agent token can do only its own job, and none is an organisation owner. Settings are left to the repository-settings recommendation. - **Layers against a pull request that removes its own gate:** - **CODEOWNERS** with "block on CODEOWNERS review". It covers `.gitea/**`, `scripts/**`, `renovate.json`, `.pre-commit-config.yaml`, `requirements*`, `galaxy.yml` and `docs/adr/**`, all assigned to the maintainer. Ordinary role changes stay self-mergeable. - **Dismiss stale approvals**, already on. - **Judge scripts run from `main`'s copy**, as bot-diff and molecule selection already do. Rule: every new judge script does the same. - **zizmor**, below. - **Rule held by review:** only `image.yml` and `renovate.yml` may reference secrets. CODEOWNERS puts every workflow change in front of the maintainer; there is no custom grep. - **zizmor** (1.32.0, MIT), tested offline on the five workflows. It parses all five when the files are passed explicitly. Default level: no findings. It flags `pull_request_target` and `${{ }}` in `run:`. Adopted as a pre-commit hook, with `files:` overridden to `.gitea/workflows` and the revision pinned by SHA. Condition: it must fit the `ci` image under the 100 MB layer limit. If the hook's own environment does not fit, zizmor goes into `requirements-dev` as a `language: system` hook. - **Rule for contributors:** review an unmerged branch's hook and script changes before running them locally. ### Accepted risks - **The shared runner.** One long-lived host runs molecule as root, approved fork runs and the image build that holds the push credential. Anything that gets root can tamper with a later image build. Runner labels are not a boundary, because any workflow can name any label. The planned fix is **ephemeral runners** (a clean host per privileged job). Trigger: before the first fork approval for someone outside the friends tier, or before write access goes to anyone without secret-level trust. Provisioning the runner is outside this repository. - **The bot-diff check keys on the branch name.** A contributor who names a branch `renovate/…` only gets stricter checks. The real risk is the bot's token, covered by least privilege. - **A malicious contributor with write access** can read the secrets. Accepted by giving write access only to trusted people. ### Not done - **Signed commits:** a signature proves which key signed, not who wrote the change. Tag protection already guards releases. - **CLA or DCO:** GPL-3.0-or-later and REUSE already settle licensing, and the contributors are friends. - **Signing release artifacts:** consumers install from a protected tag. ### Not verified - How Gitea's protected file patterns interact with an empty push allowlist. They were not adopted. - Whether the zizmor pre-commit hook itself runs with the `files:` override. It was only run directly. - Whether the maintainer can approve a pull request opened by the agent account. Expected yes, because it is a different account.
Author
Owner

Review of the map (2026-11-17).

Partly superseded by How friends get code in and The friend boundary once the approval facts are known: an outsider's fork pull request is closed by a human, never approved. A friend's pushes are approved until the friend's first merged pull request, and the approver reads the whole diff.

Partly superseded by Enforcement map for each prose-only rule: the secrets rule is "each secret is referenced by exactly one workflow".

Partly superseded by Code-owner approval against Renovate automerge, and where secrets live: CODEOWNERS is a root file that owns itself, it owns more gate inputs, and the three pin files are not owned.

Added by Agent credentials and what unattended agents can do: prompt injection as an actor and an accepted risk. Added by Release path: fragment check, failed publish and tarball integrity: the tag message carries the tarball's sha256; still no artifact signing. The current text is the scope of docs(adr): record the threat model as ADR 0001.

Review of the map (2026-11-17). Partly superseded by [How friends get code in](https://git.rkdr.net/Mortis/Kamino/issues/100) and [The friend boundary once the approval facts are known](https://git.rkdr.net/Mortis/Kamino/issues/205): an outsider's fork pull request is closed by a human, never approved. A friend's pushes are approved until the friend's first merged pull request, and the approver reads the whole diff. Partly superseded by [Enforcement map for each prose-only rule](https://git.rkdr.net/Mortis/Kamino/issues/102): the secrets rule is "each secret is referenced by exactly one workflow". Partly superseded by [Code-owner approval against Renovate automerge, and where secrets live](https://git.rkdr.net/Mortis/Kamino/issues/210): CODEOWNERS is a root file that owns itself, it owns more gate inputs, and the three pin files are not owned. Added by [Agent credentials and what unattended agents can do](https://git.rkdr.net/Mortis/Kamino/issues/209): prompt injection as an actor and an accepted risk. Added by [Release path: fragment check, failed publish and tarball integrity](https://git.rkdr.net/Mortis/Kamino/issues/211): the tag message carries the tarball's sha256; still no artifact signing. The current text is the scope of [docs(adr): record the threat model as ADR 0001](https://git.rkdr.net/Mortis/Kamino/issues/143).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: Mortis/Kamino#99