Skip to content

fix(k8s): the in-cluster image registry requires authentication behind a perimeter before nodes mirror it, or leaves with its mirrors #1630

Closed

Description

@dan-petty

Friction

The in-cluster image registry accepts unauthenticated pushes and deletes over plain HTTP on a fixed NodePort on every node, runs as root with no securityContext, and its namespace has no NetworkPolicy and no test noticing. Nothing has pulled from it since squid was removed in #734 (v0.2.24), yet the homelab repository still plans to point every node's containerd at it (dan-petty/homelab#7, configure_registries.yaml, apply pending the power move). Unauthenticated writes land on a local-path volume that does not enforce its 50Gi request, so they could fill a 's disk and trigger DiskPressure evictions; once the mirrors are applied, anyone on the LAN or in any pod can also plant an image the nodes will run. The registry should either be protected before the mirrors go live, or leave together with them.

Evidence

Live, read-only, 2026-10-17:

  • Deployment registry/registry runs registry:2.8.3 with empty pod and container securityContext; env only REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY, REGISTRY_HTTP_ADDR=0.0.0.0:5000 and REGISTRY_STORAGE_DELETE_ENABLED=true; no REGISTRY_AUTH*.
  • Service registry/registry is NodePort with a fixed nodePort; kubectl get networkpolicy -n registry returns nothing. Application base (path k8s, 3dd7fa6) is Synced and owns the Namespace, PVC, Service and Deployment.
  • No consumer today: the six registry references in the nodes' image caches are all squid; no workload references a registry-hosted image; Loki shows zero non-probe HTTP requests to the registry in 29 days, and no containerd mirror routes through it yet.
  • Namespace registry is labelled baseline by design (k8s/namespaces.yaml:55-60); a restricted dry run fails, which breaks no declared level.

Repo:

Remedy

The owner decides first, and records the decision in k8s/README.md and on dan-petty/homelab#7:

  • Keep (until Gitea's registry, feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081, replaces it). Tests first: add registry to TARGET_NAMESPACES and a test that the Deployment reads REGISTRY_AUTH=htpasswd from a Secret and sets a non-root securityContext with allowPrivilegeEscalation: false, capabilities dropped and RuntimeDefault seccomp (the namespace stays baseline). Then: an htpasswd Secret pushed from the keyring by push-secrets (a new row in the Cluster Secrets table), REGISTRY_STORAGE_DELETE_ENABLED off unless garbage collection needs it, a registry-perimeter NetworkPolicy admitting 5000 only from the node network and the pods that push, and a k8s/registry/networkpolicy.yaml entry in its kustomization. homelab#7 then adds the matching configs.<mirror>.auth to registries.yaml.
  • Remove (the zero-zombie-code default if nothing will push to it). Drop registry from k8s/kustomization.yaml:7, delete k8s/registry/ and the Namespace at k8s/namespaces.yaml:52-62, the assertion at tests/test_k8s.py:1224-1232 and the mentions at k8s/README.md:601 and k8s_stack_deployment.md:14,89; leave tests/test_security_kubelinter.py:52-53 (a recorded report). Argo CD base prunes the Deployment and Service; PVC registry-data and the Namespace stay under their Prune=false,Delete=false annotations until a person deletes the namespace. dan-petty/homelab#7 then deletes configure_registries.yaml instead of generalising it, and Metrics for the rest of the platform #551 drops the registry.

Priority: P2. Severity medium-to-low today; it becomes an image-injection path for every node once homelab#7's mirrors are applied.

Proposed design

Problem statement

The in-cluster image registry is insecure and unauthenticated, running as root with no securityContext, and accepts unauthenticated pushes and deletes over plain HTTP on a fixed NodePort. It has no NetworkPolicy and is not tested, posing a risk of disk fill-up and unauthorized image injection if mirrors are applied to nodes.

Acceptance criteria

  • Criterion 1: The registry deployment includes authentication via htpasswd and a non-root securityContext with restricted capabilities
    Verification: Verify that the registry Deployment in k8s/registry/deployment.yaml sets REGISTRY_AUTH=htpasswd, uses a non-root user, has allowPrivilegeEscalation: false, dropped capabilities, and RuntimeDefault seccomp.
  • Criterion 2: A NetworkPolicy is applied to restrict access to the registry's NodePort
    Verification: Confirm that k8s/registry/networkpolicy.yaml exists and defines a policy admitting traffic only from the node network and pods authorized to push images.
  • Criterion 3: The registry namespace has proper test coverage for its security settings
    Verification: Ensure tests/test_k8s_network_policies.py includes 'registry' in TARGET_NAMESPACES and that there is a test verifying the Deployment's securityContext and auth configuration.
  • Criterion 4: The registry is either kept with security measures or removed if no longer needed
    Verification: Check k8s/kustomization.yaml for the registry entry and confirm that either it remains with updated security configurations or has been removed along with associated files.

Key questions

  • Should the registry be kept with security measures or removed?: The owner decides first, and records the decision in k8s/README.md and on dan-petty/homelab#7. (proposed)

Open questions

  • What are the current security settings of the registry deployment? (missing verified source)
  • What is the current network policy for the registry namespace? (missing verified source)
  • Are there any existing tests that cover the registry's security? (missing verified source)

Fit

Needs splitting into 3 items:

  1. Create a new task to add authentication and securityContext to the registry deployment
  2. Create a new task to implement a NetworkPolicy for the registry namespace
  3. Update tests to cover the new registry security settings

Suspected block

dan-petty/homelab#7

Dependencies

None.

Activity

  1. added
    source/agent
    type/security
    on Oct 18, 2026
  2. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Type: type/security. The candidate describes a security vulnerability in the in-cluster image registry.
    • Priority: P1-High. The registry accepts unauthenticated pushes and deletes over plain HTTP, running as root with no securityContext, and could fill a node's disk and trigger DiskPressure evictions.
    • Value: High. The registry is exposed to the LAN or any pod and allows unauthenticated writes that could fill disks and trigger evictions.
    • Effort: Medium. The fix requires adding authentication, securityContext, NetworkPolicy, and updating tests and documentation.
  3. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Proposal needs splitting into 3 items at 25e2cda (see proposed design in issue body).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    source/agenttype/security

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions