This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: cosign-keyless-oidc-admission-verification

Cosign Keyless OIDC Container Verification Admission Gate

Enforces cryptographic supply-chain integrity at the Kubernetes admission boundary by verifying container signatures using short-lived Fulcio certificates tied to OIDC workload identity and Rekor transparency logs. Requires immutable sha256 image digests and strictly asserts OIDC issuer and subject SANs while rejecting static long-lived keys and unsigned digests.

Prohibited Anti-Pattern: Admitting Unsigned, Mutable Container Tags or Omitting OIDC Workload Subject and Issuer Identity Verification

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cosign Keyless OIDC Container Verification Admission Gate - Enforces cryptographic supply-chain integrity at the Kubernetes admission boundary by verifying container signatures using short-lived Fulcio certificates tied to OIDC workload identity and Rekor transparency logs. Requires immutable sha256 image digests and strictly asserts OIDC issuer and subject SANs while rejecting static long-lived keys and unsigned digests.
globs: src/admission/**/*.ts, src/security/**/*.ts, k8s/**/*.yaml, policies/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cosign-keyless-oidc-admission-verification"
---

# Cosign Keyless OIDC Container Verification Admission Gate

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Admitting Unsigned, Mutable Container Tags or Omitting OIDC Workload Subject and Issuer Identity Verification

## System Constraints
You are a Principal Security Architect enforcing container provenance and keyless admission gates using Sigstore Cosign. You mandate that container images deployed to Kubernetes are verified against Fulcio short-lived OIDC certificates, backed by Rekor transparency log proofs, anchored to exact OIDC issuer URLs and repository subject SAN identities, and addressed exclusively via immutable SHA-256 digests.

## Strict Guidelines
- Engineers MUST ALWAYS resolve container references to immutable digests (image@sha256:...) before verification and admission.
- Engineers MUST NOT admit container images using mutable tags alone (e.g., :latest, :v1.0.0) without cryptographic digest pinning.
- Verification logic MUST validate the Sigstore bundle containing the Fulcio ephemeral X.509 certificate and the Rekor transparency log entry inclusion proof.
- Admission gates MUST strictly enforce exact matches or regex constraints on both the Fulcio certificate OIDC Issuer (e.g., https://token.actions.githubusercontent.com) and Subject Alternative Name (SAN).
- Services MUST reject deployments when verification times out or when transparency log proofs cannot be validated; fail-open behavior is strictly prohibited.
- Components NEVER accept long-lived asymmetric keys (RSA/ECDSA public keys) when keyless workload identity policies are mandated for the cluster.

## Bad vs Good Implementations
### Keyless OIDC Verification in Kubernetes Admission Webhook Handler

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The handler admits containers using mutable tags, omits cryptographic verification of the Cosign signature bundle, fails to check Rekor transparency log proofs, and fails open without checking Fulcio OIDC issuer or subject identity.
```typescript
import { Request, Response } from 'express';

interface AdmissionRequestBody {
  request: {
    uid: string;
    object: {
      spec: { containers: Array<{ image: string; name: string }> };
    };
  };
}

export async function validateAdmission(req: Request, res: Response): Promise<void> {
  const { uid, object } = (req.body as AdmissionRequestBody).request;

  for (const container of object.spec.containers) {
    // ANTI-PATTERN: Allows mutable tags, skips Rekor validation, and admits without
    // asserting Fulcio OIDC certificate issuer and subject SAN.
    if (!container.image.includes('sha256')) {
      console.warn(`Warning: image ${container.image} is not pinned, allowing anyway`);
    }
  }

  // Fail-open response without cryptographically verifying Sigstore bundle
  res.json({
    apiVersion: 'admission.k8s.io/v1',
    kind: 'AdmissionReview',
    response: { uid, allowed: true }
  });
}
```

#### Production Standard (Correct)
> **Standard**: Enforces immutable sha256 image references, verifies the keyless Sigstore bundle containing Fulcio short-lived certificates and Rekor log proofs, constrains the OIDC issuer and workflow subject SAN regex, and explicitly fails closed with HTTP 403 upon any verification failure.
```typescript
import { Request, Response } from 'express';
import * as sigstore from '@sigstore/verify';

interface AdmissionRequestBody {
  request: {
    uid: string;
    object: {
      spec: { containers: Array<{ image: string; name: string }> };
    };
  };
}

const TRUSTED_ISSUER = 'https://token.actions.githubusercontent.com';
const TRUSTED_SAN_REGEX = /^https:\/\/github\.com\/org-name\/[a-zA-Z0-9_-]+\/.github\/workflows\/.*\.yml@refs\/heads\/main$/;
const DIGEST_REGEX = /^[a-z0-9.\-_/]+@sha256:[a-f0-9]{64}$/;

export async function validateAdmission(req: Request, res: Response): Promise<void> {
  const { uid, object } = (req.body as AdmissionRequestBody).request;

  try {
    for (const container of object.spec.containers) {
      if (!DIGEST_REGEX.test(container.image)) {
        throw new Error(`Rejected: Container '${container.name}' must specify an immutable sha256 digest.`);
      }

      const bundle = await fetchSigstoreBundleForDigest(container.image);
      if (!bundle) {
        throw new Error(`Rejected: Signature bundle missing for image ${container.image}`);
      }

      // Verify keyless signature against Fulcio root and Rekor log
      const verificationResult = await sigstore.verify(bundle, {
        keyless: {
          issuer: TRUSTED_ISSUER,
          subjectAltName: TRUSTED_SAN_REGEX
        }
      });

      if (!verificationResult) {
        throw new Error(`Rejected: Signature verification failed for ${container.image}`);
      }
    }

    res.json({
      apiVersion: 'admission.k8s.io/v1',
      kind: 'AdmissionReview',
      response: { uid, allowed: true }
    });
  } catch (error) {
    const message = error instanceof Error ? error.message : 'Unknown admission error';
    res.json({
      apiVersion: 'admission.k8s.io/v1',
      kind: 'AdmissionReview',
      response: {
        uid,
        allowed: false,
        status: { code: 403, message }
      }
    });
  }
}

async function fetchSigstoreBundleForDigest(_image: string): Promise<sigstore.Bundle | null> {
  // Implementation fetching Cosign signature layer and bundle from OCI registry
  return null;
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Cosign Keyless OIDC Container Verification Admission Gate

Cosign Keyless OIDC Container Verification Admission Gate defines an industrial-grade behavioral standard for security engineering. Enforces cryptographic supply-chain integrity at the Kubernetes admission boundary by verifying container signatures using short-lived Fulcio certificates tied to OIDC workload identity and Rekor transparency logs. Requires immutable sha256 image digests and strictly asserts OIDC issuer and subject SANs while rejecting static long-lived keys and unsigned digests. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Admitting Unsigned, Mutable Container Tags or Omitting OIDC Workload Subject and Issuer Identity Verification Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftAdmitting Unsigned, Mutable Container Tags or Omitting OIDC Workload Subject and Issuer Identity VerificationCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS resolve container references to immutable digests (image@sha256

Engineers MUST ALWAYS resolve container references to immutable digests (image@sha256:...) before verification and admission.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST NOT admit container images using mutable tags alone (e.g.,

Engineers MUST NOT admit container images using mutable tags alone (e.g., :latest, :v1.0.0) without cryptographic digest pinning.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Verification logic MUST validate the Sigstore bundle containing the Fulcio ephemeral X.509 certificate and the Rekor transparency log entry inclusion proof.

Verification logic MUST validate the Sigstore bundle containing the Fulcio ephemeral X.509 certificate and the Rekor transparency log entry inclusion proof.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Admission gates MUST strictly enforce exact matches or regex constraints on both the Fulcio certificate OIDC Issuer (e.g., https

Admission gates MUST strictly enforce exact matches or regex constraints on both the Fulcio certificate OIDC Issuer (e.g., https://token.actions.githubusercontent.com) and Subject Alternative Name (SAN).

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Services MUST reject deployments when verification times out or when transparency log proofs cannot be validated

Services MUST reject deployments when verification times out or when transparency log proofs cannot be validated; fail-open behavior is strictly prohibited.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
6

Components NEVER accept long-lived asymmetric keys (RSA/ECDSA public keys) when keyless workload identity policies are mandated for the cluster.

Components NEVER accept long-lived asymmetric keys (RSA/ECDSA public keys) when keyless workload identity policies are mandated for the cluster.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Cosign Keyless OIDC Container Verification Admission Gate critical for AI coding assistants?

Enforces cryptographic supply-chain integrity at the Kubernetes admission boundary by verifying container signatures using short-lived Fulcio certificates tied to OIDC workload identity and Rekor transparency logs. Requires immutable sha256 image digests and strictly asserts OIDC issuer and subject SANs while rejecting static long-lived keys and unsigned digests. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Admitting Unsigned, Mutable Container Tags or Omitting OIDC Workload Subject and Issuer Identity Verification) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

Cosign