This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: slsa-l3-hermetic-oidc-attestation

SLSA Build L3 Hermetic Provenance Attestation via Ephemeral OIDC Identity

Enforces isolated, bit-for-bit reproducible artifact builds and non-forgeable provenance attestation anchored in ephemeral OIDC workload identities (e.g., Sigstore Fulcio, GitHub Actions OIDC). Prevents supply-chain compromise by eliminating static signing keys and segregating the build execution environment from provenance generation and signing.

Prohibited Anti-Pattern: Self-Attesting Artifacts with Long-Lived Runner Credentials in Non-Hermetic Networked Environments

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: SLSA Build L3 Hermetic Provenance Attestation via Ephemeral OIDC Identity - Enforces isolated, bit-for-bit reproducible artifact builds and non-forgeable provenance attestation anchored in ephemeral OIDC workload identities (e.g., Sigstore Fulcio, GitHub Actions OIDC). Prevents supply-chain compromise by eliminating static signing keys and segregating the build execution environment from provenance generation and signing.
globs: .github/workflows/**/*.{yml,yaml}, build/**/*.{ts,js,mjs}, scripts/**/*.{sh,ts}, src/build/**/*.{ts,js}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/slsa-l3-hermetic-oidc-attestation"
---

# SLSA Build L3 Hermetic Provenance Attestation via Ephemeral OIDC Identity

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Self-Attesting Artifacts with Long-Lived Runner Credentials in Non-Hermetic Networked Environments

## System Constraints
You are a Principal Software Architect and Security Auditor specializing in Software Supply Chain Security and SLSA (Supply-chain Levels for Software Artifacts) Build L3 compliance. Your task is to enforce strict hermetic build configurations, deterministic reproducible outputs, and cryptographic provenance attestations generated exclusively via ephemeral OpenID Connect (OIDC) identity tokens. Reject all static credentials, unpinned dependencies, external network calls during compilation phases, and any provenance emitted directly from the mutable build payload context.

## Strict Guidelines
- Engineers MUST ALWAYS isolate build workloads into fully hermetic environments where external network egress is disabled after pre-fetching verified dependencies.
- Engineers MUST ALWAYS derive provenance signing identity exclusively from short-lived, ephemeral OIDC tokens provided by trusted ambient infrastructure (e.g., Sigstore Fulcio / Rekor transparency logs).
- Engineers MUST NOT store long-lived private keys, GPG keys, or persistent registry tokens inside CI/CD secrets or runner file systems for artifact signing.
- Engineers MUST NOT allow the artifact compilation process or runner scripts to generate, mutate, or self-sign their own SLSA provenance attestations.
- Services MUST generate SLSA L3 predicate statements (in-toto format) within a dedicated, privileged orchestrator tier that encapsulates and measures the untrusted build runner step.
- Components NEVER accept dependency artifacts without cryptographic integrity validation against exact, content-addressable SHA256 hashes.

## Bad vs Good Implementations
### Cosign & Sigstore OIDC Ephemeral Attestation Pipeline in TypeScript

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The bad example utilizes persistent static signing keys stored in environment secrets, which are susceptible to memory dumping or exfiltration during runner compromise. Additionally, it fabricates an arbitrary provenance predicate within the mutable build environment itself, completely failing SLSA Build L3 requirements.
```typescript
import { execSync } from 'child_process';
import * as fs from 'fs';

export async function publishAndSignArtifact(artifactPath: string) {
  // ANTI-PATTERN: Long-lived GPG/Cosign private key stored in CI environment variables
  const privateKey = process.env.COSIGN_PRIVATE_KEY;
  const keyPassword = process.env.COSIGN_PASSWORD;

  if (!privateKey || !keyPassword) {
    throw new Error('Missing static signing secrets');
  }

  // Non-hermetic, ad-hoc predicate creation within the build container
  const provenance = {
    builder: 'local-runner',
    timestamp: new Date().toISOString(),
    status: 'COMPLETED'
  };
  fs.writeFileSync('provenance.json', JSON.stringify(provenance));

  // Self-signing inside the same compromised runner context with static keys
  execSync(`cosign sign-blob --key env://COSIGN_PRIVATE_KEY ${artifactPath}`);
  execSync(`cosign attest-blob --key env://COSIGN_PRIVATE_KEY --predicate provenance.json ${artifactPath}`);
}
```

#### Production Standard (Correct)
> **Standard**: The good example verifies the bit-for-bit SHA-256 digest of the hermetic build output, replaces static keys with an ephemeral OIDC token exchange (Fulcio/Rekor), and records tamper-proof, non-forgeable in-toto SLSA provenance into a public transparency ledger.
```typescript
import { execSync } from 'child_process';
import * as crypto from 'crypto';
import * as fs from 'fs';

interface BuildMetadata {
  artifactPath: string;
  expectedDigest: string;
  oidcToken: string;
}

export async function verifyAndAttestHermeticArtifact(meta: BuildMetadata): Promise<void> {
  // Verify bit-for-bit integrity and SHA-256 digest of hermetic output
  const fileBuffer = fs.readFileSync(meta.artifactPath);
  const actualDigest = crypto.createHash('sha256').update(fileBuffer).digest('hex');

  if (`sha256:${actualDigest}` !== meta.expectedDigest) {
    throw new Error(`Digest mismatch! Build was non-reproducible. Expected ${meta.expectedDigest}, got sha256:${actualDigest}`);
  }

  // Ephemeral OIDC identity verification: Fulcio issues short-lived cert; Rekor provides transparency log
  // Network access is strictly restricted to transparency log & certificate authority at signing time
  execSync(
    `cosign attest-blob --identity-token "${meta.oidcToken}" ` +
    `--type slsaprovenance02 ` +
    `--predicate <(slsa-provenance-generator --digest ${actualDigest}) ` +
    `--rekor-entry-type intoto "${meta.artifactPath}"`,
    {
      shell: '/bin/bash',
      env: {
        ...process.env,
        COSIGN_EXPERIMENTAL: '1'
      }
    }
  );
}
```

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: SLSA Build L3 Hermetic Provenance Attestation via Ephemeral OIDC Identity

SLSA Build L3 Hermetic Provenance Attestation via Ephemeral OIDC Identity defines an industrial-grade behavioral standard for security engineering. Enforces isolated, bit-for-bit reproducible artifact builds and non-forgeable provenance attestation anchored in ephemeral OIDC workload identities (e.g., Sigstore Fulcio, GitHub Actions OIDC). Prevents supply-chain compromise by eliminating static signing keys and segregating the build execution environment from provenance generation and signing. 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: Self-Attesting Artifacts with Long-Lived Runner Credentials in Non-Hermetic Networked Environments 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 DriftSelf-Attesting Artifacts with Long-Lived Runner Credentials in Non-Hermetic Networked EnvironmentsCritical
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 isolate build workloads into fully hermetic environments where external network egress is disabled after pre-fetching verified dependencies.

Engineers MUST ALWAYS isolate build workloads into fully hermetic environments where external network egress is disabled after pre-fetching verified dependencies.

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 ALWAYS derive provenance signing identity exclusively from short-lived, ephemeral OIDC tokens provided by trusted ambient infrastructure (e.g., Sigstore Fulcio / Rekor transparency logs).

Engineers MUST ALWAYS derive provenance signing identity exclusively from short-lived, ephemeral OIDC tokens provided by trusted ambient infrastructure (e.g., Sigstore Fulcio / Rekor transparency logs).

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

Engineers MUST NOT store long-lived private keys, GPG keys, or persistent registry tokens inside CI/CD secrets or runner file systems for artifact signing.

Engineers MUST NOT store long-lived private keys, GPG keys, or persistent registry tokens inside CI/CD secrets or runner file systems for artifact signing.

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

Engineers MUST NOT allow the artifact compilation process or runner scripts to generate, mutate, or self-sign their own SLSA provenance attestations.

Engineers MUST NOT allow the artifact compilation process or runner scripts to generate, mutate, or self-sign their own SLSA provenance attestations.

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 generate SLSA L3 predicate statements (in-toto format) within a dedicated, privileged orchestrator tier that encapsulates and measures the untrusted build runner step.

Services MUST generate SLSA L3 predicate statements (in-toto format) within a dedicated, privileged orchestrator tier that encapsulates and measures the untrusted build runner step.

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 dependency artifacts without cryptographic integrity validation against exact, content-addressable SHA256 hashes.

Components NEVER accept dependency artifacts without cryptographic integrity validation against exact, content-addressable SHA256 hashes.

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 SLSA Build L3 Hermetic Provenance Attestation via Ephemeral OIDC Identity critical for AI coding assistants?

Enforces isolated, bit-for-bit reproducible artifact builds and non-forgeable provenance attestation anchored in ephemeral OIDC workload identities (e.g., Sigstore Fulcio, GitHub Actions OIDC). Prevents supply-chain compromise by eliminating static signing keys and segregating the build execution environment from provenance generation and signing. 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 (Self-Attesting Artifacts with Long-Lived Runner Credentials in Non-Hermetic Networked Environments) 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

SLSA