Skip to content

feat(k8s): an admission policy pins the Jobs the roadmap Service may create #2696

Description

@dan-petty

Problem or Motivation

The Role roadmap-service-jobs lets the Service create Jobs in namespace devops (#2667). Kubernetes cannot limit create to a name, so the Role can create any Job that Pod Security restricted admits. Such a Job can use any image, any ServiceAccount of the namespace, envFrom of Secret devops-cli, and any volume that restricted admits. The Service pod already holds Secret devops-cli, so the Role gives it no new secret today. That holds only while namespace devops holds only Secret devops-cli. If a second Secret is added there, a compromise of the Service reaches it through a Job.

Proposed Solution & Architectural Design

Add a ValidatingAdmissionPolicy (Kubernetes 1.30 and later, built in, no extra component) with a binding for namespace devops, applied to CREATE of jobs by the user system:serviceaccount:devops:roadmap-service. A CEL expression requires that the Job:

  • has exactly one container, with the image ghcr.io/dan-petty/devops-cli/runner (by prefix and digest or tag as the CronJob has it);
  • has serviceAccountName: devops-cli;
  • has envFrom equal to Secret devops-cli only;
  • uses only the volumes that the CronJob devops-cli-runner template names (tmp, home, config);
  • sets automountServiceAccountToken: false.

A test renders the policy and checks it against the CronJob template, so that a change to the template that the policy refuses fails in CI.

Target Subsystem

k8s/devops/ (a new admissionpolicy.yaml and its binding), k8s/README.md, tests/test_k8s_runner.py.

Existing Tool Considered

ValidatingAdmissionPolicy (built in). Kyverno and OPA Gatekeeper cover the same need but add a component to the cluster, so they are not chosen.

Activity

  1. added
    source/agent
    type/security
    status/new
    value/medium
    effort/medium
    on Oct 29, 2026
  2. dan-petty commented on Oct 29, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/security. The change adds an admission policy to limit the blast radius of a compromised Service account.
    • Priority: P2-Medium. It mitigates a future risk that appears only if a second Secret is added to the namespace.
    • Value: Medium. It prevents a compromised Service from reaching new Secrets via an arbitrary Job, but no active exploit exists.
    • Effort: Medium. It needs a CEL expression, a binding, and a CI test that renders the policy against the CronJob template.
    • Related: feat(k8s): the implement job runs as a cluster Job on a runner image with uv, the dev dependencies and the pinned tools, submitted by the Service #2667, which asks for a different change. Both concern the Job the Service creates in namespace devops, but #2667 defines the Job while the candidate constrains what Jobs the Service may create.
  3. added
    priority/p2-medium
    on Oct 29, 2026
  4. added
    type/feature
    scope/k8s
    status/in-progress
    status/in-review
    and removed
    type/security
    status/new
    status/in-progress
    on Oct 30, 2026
  5. removed
    status/in-review
    on Oct 30, 2026
  6. added a commit that references this issue on Oct 30, 2026
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

    effort/mediumpriority/p2-mediumscope/k8ssource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions