registry(auth): require authentication for image pulls (F11) #43

Merged
sirius merged 1 commit from fix/registry-anon-pull into master 2026-11-27 05:15:39 +00:00
Owner

Summary

Audit finding F11: /v2/token minted a token for anonymous clients (UserID: -1, Scope: "") and that token returned 200 on every package — including images of private repos (siriusdevops-site, phs-site, sirius-growth-*, sgs-leadgen), because Forgejo 16 grants the anonymous ghost user perm.AccessModeRead in services/context/package.go::determineAccessMode. "Make the repo private" was therefore not a mitigation.

Changes

  • apps/base/forgejo/deployment.yaml — FORGEJO__service__REQUIRE_SIGNIN_VIEW=true. This is the documented switch in routers/api/packages/container (Authenticate): anonymous callers get UNAUTHORIZED instead of a ghost token, and determineAccessMode returns AccessModeNone. Side effect (deliberate): the Forgejo web UI/REST API becomes login-only for anonymous visitors, including public repos. CI pushes are unaffected (REGISTRY_TOKEN, write:package).
  • 18 workload manifests (osint ×8, piedmont ×2, sirius-growth ×6, siriusdevops ×2) — imagePullSecrets: [{name: forgejo-pull}].
  • docs/registry-pull-auth.md — why the node carries no global credential, the out-of-band Secret recipe, the add-a-namespace recipe, and the verification commands.

The forgejo-pull Secret (kubernetes.io/dockerconfigjson, user registry-reader, read:package) exists out of band in all four namespaces — secrets never live in this repo. A recreated namespace needs the Secret re-applied before its pods reschedule.

Verification (live, after merge)

  • anonymous /v2/token → 401 {"errors":[{"code":"UNAUTHORIZED",...}]}; anonymous manifest HEAD → 401
  • authenticated two-stage flow → 200; dockerconfigjson pull proven from each namespace
  • all 18 pods Running, no ErrImagePull/ImagePullBackOff
  • config_path = "" and no hosts.toml on any node (no node-level credential)

Refs: finding F11 of 2026-11-27-cluster-netsec-audit.md.

## Summary Audit finding **F11**: `/v2/token` minted a token for anonymous clients (`UserID: -1, Scope: ""`) and that token returned `200` on every package — including images of **private** repos (`siriusdevops-site`, `phs-site`, `sirius-growth-*`, `sgs-leadgen`), because Forgejo 16 grants the anonymous ghost user `perm.AccessModeRead` in `services/context/package.go::determineAccessMode`. "Make the repo private" was therefore not a mitigation. ### Changes * `apps/base/forgejo/deployment.yaml` — `FORGEJO__service__REQUIRE_SIGNIN_VIEW=true`. This is the documented switch in `routers/api/packages/container` (`Authenticate`): anonymous callers get `UNAUTHORIZED` instead of a ghost token, and `determineAccessMode` returns `AccessModeNone`. Side effect (deliberate): the Forgejo web UI/REST API becomes login-only for anonymous visitors, including public repos. CI pushes are unaffected (`REGISTRY_TOKEN`, `write:package`). * 18 workload manifests (osint ×8, piedmont ×2, sirius-growth ×6, siriusdevops ×2) — `imagePullSecrets: [{name: forgejo-pull}]`. * `docs/registry-pull-auth.md` — why the node carries no global credential, the out-of-band Secret recipe, the add-a-namespace recipe, and the verification commands. The `forgejo-pull` Secret (`kubernetes.io/dockerconfigjson`, user `registry-reader`, `read:package`) exists **out of band** in all four namespaces — secrets never live in this repo. A recreated namespace needs the Secret re-applied before its pods reschedule. ### Verification (live, after merge) * anonymous `/v2/token` → `401 {"errors":[{"code":"UNAUTHORIZED",...}]}`; anonymous manifest `HEAD` → `401` * authenticated two-stage flow → `200`; `dockerconfigjson` pull proven from each namespace * all 18 pods `Running`, no `ErrImagePull`/`ImagePullBackOff` * `config_path = ""` and no `hosts.toml` on any node (no node-level credential) Refs: finding F11 of `2026-11-27-cluster-netsec-audit.md`.
Forgejo 16 mints an anonymous ("ghost user") registry token on /v2/token and
grants it Read on every package regardless of repo visibility, so all 18 app
images were world-downloadable — including images of private repos
(siriusdevops-site, phs-site, sirius-growth-*, sgs-leadgen).

* FORGEJO__service__REQUIRE_SIGNIN_VIEW=true: /v2/token answers UNAUTHORIZED
  to anonymous clients, anonymous manifests get 401. This is the documented
  switch in routers/api/packages/container (Authenticate) and
  services/context/package.go (determineAccessMode). Side effect: the Forgejo
  web UI/API becomes login-only for anonymous visitors.
* imagePullSecrets: [forgejo-pull] on all 18 workloads that pull from the
  registry (osint, piedmont, sirius-growth, siriusdevops). The
  kubernetes.io/dockerconfigjson Secret is per-namespace and out of band
  (never in git); docs/registry-pull-auth.md documents why, how to recreate
  it, and the verification commands. No containerd-level credential.
sirius merged commit 99cc3313f2 into master 2026-11-27 05:15:39 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/homek8s!43
No description provided.