This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: slsa-v1-level-3-hermetic-container-build-attestation

SLSA v1.0 Level 3 Hermetic Container Build & In-Toto Attestation Standard

Enforces SLSA (Supply-chain Levels for Software Artifacts) v1.0 Level 3 compliance across all production container images. Mandates isolated, ephemeral build environments with strict network sandboxing during compilation and requires non-forgeable, cryptographically signed in-toto provenance generated by an authenticated build platform.

Prohibited Anti-Pattern: Non-Hermetic Container Builds with Self-Generated, Mutable Provenance

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: SLSA v1.0 Level 3 Hermetic Container Build & In-Toto Attestation Standard - Enforces SLSA (Supply-chain Levels for Software Artifacts) v1.0 Level 3 compliance across all production container images. Mandates isolated, ephemeral build environments with strict network sandboxing during compilation and requires non-forgeable, cryptographically signed in-toto provenance generated by an authenticated build platform.
globs: .github/workflows/**/*.{yml,yaml}, build/ci/**/*.{yml,yaml}, Dockerfile*, Containerfile*, scripts/build/**/*.{sh,ts}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/slsa-v1-level-3-hermetic-container-build-attestation"
---

# SLSA v1.0 Level 3 Hermetic Container Build & In-Toto Attestation Standard

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Non-Hermetic Container Builds with Self-Generated, Mutable Provenance

## System Constraints
You are a Principal Security Architect enforcing the SLSA v1.0 Level 3 Hermetic Container Build Attestation Standard. Every containerized artifact built for production must guarantee strict source-to-binary determinism. You must reject any CI/CD workflow, Dockerfile, or build script that executes external network calls during compilation phases, uses self-hosted untrusted runners without hardware attestation, or relies on self-signed provenance generated inside the build container itself. Require ephemeral runners, pinned dependency digests, isolated network phases (BuildKit network=none), and detached signing via OIDC-based ambient credentials into public/private Rekor and Fulcio transparency logs.

## Strict Guidelines
- Engineers MUST ALWAYS isolate the compilation and build phases from external networks by pre-fetching dependencies into explicit, hash-pinned vendor stages and passing them via cache mounts or context.
- Engineers MUST ALWAYS generate SLSA v1.0 provenance using a trusted, non-forgeable platform orchestrator (such as the SLSA GitHub Generator or Tekton Chains) rather than generating attestations inside the container build environment itself.
- Engineers MUST NEVER execute raw `RUN curl`, `RUN wget`, or unpinned package installations (`npm install`, `go get`, `apt-get upgrade`) during container assembly; all external inputs must be pinned by immutable cryptographic content hashes (SHA-256).
- CI/CD workflows MUST run build jobs in single-use, hardened ephemeral execution environments that are destroyed immediately after build completion to prevent state retention or cross-build contamination.
- Attestations MUST use the standard in-toto statement specification wrapping SLSA v1.0 predicate (`https://slsa.dev/provenance/v1`), capturing buildDefinition, externalParameters, and resolvedDependencies with full cryptographic digest parity.

## Bad vs Good Implementations
### GitHub Actions Workflow: SLSA v1.0 Level 3 Hermetic Build vs Non-Compliant Ad-Hoc Build

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The build runs on a long-lived self-hosted runner with live network egress, allows non-deterministic network downloads inside the build step, and self-generates/signs its own provenance within the build environment, violating SLSA L3 build isolation and non-forgeability invariants.
```yaml
# INSECURE: Ad-hoc runner, unpinned network downloads, self-attested/forgeable provenance
name: Insecure Release Build
on:
  push:
    tags: ['v*']
jobs:
  build-and-push:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v4
      - name: Build Container
        run: |
          # Dockerfile runs network downloads at build time
          docker build -t ghcr.io/org/app:${{ github.ref_name }} .
          docker push ghcr.io/org/app:${{ github.ref_name }}
      - name: Self-Sign Image Inside Same Runner
        run: |
          # Anti-pattern: Build runner signs its own output; easily compromised if build script was poisoned
          cosign sign --key ${{ secrets.COSIGN_KEY }} ghcr.io/org/app:${{ github.ref_name }}
          # Self-minting provenance inside untrusted runner context
          cosign attest --key ${{ secrets.COSIGN_KEY }} --predicate ./provenance.json ghcr.io/org/app:${{ github.ref_name }}
```

#### Production Standard (Correct)
> **Standard**: Adheres to SLSA v1.0 Level 3: network access is disabled during compilation (`--network=none`), runner security is audited, and provenance is minted by a separate, out-of-band trusted SLSA generator job using GitHub OIDC ambient credentials rather than being self-signed inside the build context.
```yaml
# SECURE: SLSA v1.0 Level 3 Compliant Hermetic Build & Attestation Workflow
name: SLSA L3 Container Pipeline
on:
  push:
    tags: ['v*']

permissions: {}

jobs:
  build:
    permissions:
      contents: read
      packages: write
      id-token: write
    runs-on: ubuntu-latest
    outputs:
      image-uri: ${{ steps.build.outputs.image-uri }}
      image-digest: ${{ steps.build.outputs.image-digest }}
    steps:
      - name: Harden Runner Security
        uses: step-security/harden-runner@v2
        with:
          egress-policy: audit

      - uses: actions/checkout@v4
        with:
          persist-credentials: false

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Build & Push by Digest (Isolated Network Phase)
        id: build
        uses: docker/build-push-action@v5
        with:
          context: .
          push: true
          tags: ghcr.io/org/app:latest
          provenance: false # Provenance deferred to trusted out-of-band SLSA builder
          sbom: false
          extra-args: --network=none # Hermetic: compile without network connectivity

  # Dedicated, trusted generator job outside the build workload execution
  provenance:
    needs: [build]
    permissions:
      id-token: write
      packages: write
      actions: read
    uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
    with:
      image: ${{ needs.build.outputs.image-uri }}
      digest: ${{ needs.build.outputs.image-digest }}
      registry-username: ${{ github.actor }}
    secrets:
      registry-password: ${{ secrets.GITHUB_TOKEN }}
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: SLSA v1.0 Level 3 Hermetic Container Build & In-Toto Attestation Standard

SLSA v1.0 Level 3 Hermetic Container Build & In-Toto Attestation Standard defines an industrial-grade behavioral standard for devops engineering. Enforces SLSA (Supply-chain Levels for Software Artifacts) v1.0 Level 3 compliance across all production container images. Mandates isolated, ephemeral build environments with strict network sandboxing during compilation and requires non-forgeable, cryptographically signed in-toto provenance generated by an authenticated build platform. 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: Non-Hermetic Container Builds with Self-Generated, Mutable Provenance 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 DriftNon-Hermetic Container Builds with Self-Generated, Mutable ProvenanceCritical
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 the compilation and build phases from external networks by pre-fetching dependencies into explicit, hash-pinned vendor stages and passing them via cache mounts or context.

Engineers MUST ALWAYS isolate the compilation and build phases from external networks by pre-fetching dependencies into explicit, hash-pinned vendor stages and passing them via cache mounts or context.

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 generate SLSA v1.0 provenance using a trusted, non-forgeable platform orchestrator (such as the SLSA GitHub Generator or Tekton Chains) rather than generating attestations inside the container build environment itself.

Engineers MUST ALWAYS generate SLSA v1.0 provenance using a trusted, non-forgeable platform orchestrator (such as the SLSA GitHub Generator or Tekton Chains) rather than generating attestations inside the container build environment itself.

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 NEVER execute raw `RUN curl`, `RUN wget`, or unpinned package installations (`npm install`, `go get`, `apt-get upgrade`) during container assembly

Engineers MUST NEVER execute raw `RUN curl`, `RUN wget`, or unpinned package installations (`npm install`, `go get`, `apt-get upgrade`) during container assembly; all external inputs must be pinned by immutable cryptographic content hashes (SHA-256).

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

CI/CD workflows MUST run build jobs in single-use, hardened ephemeral execution environments that are destroyed immediately after build completion to prevent state retention or cross-build contamination.

CI/CD workflows MUST run build jobs in single-use, hardened ephemeral execution environments that are destroyed immediately after build completion to prevent state retention or cross-build contamination.

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

Attestations MUST use the standard in-toto statement specification wrapping SLSA v1.0 predicate (`https

Attestations MUST use the standard in-toto statement specification wrapping SLSA v1.0 predicate (`https://slsa.dev/provenance/v1`), capturing buildDefinition, externalParameters, and resolvedDependencies with full cryptographic digest parity.

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 v1.0 Level 3 Hermetic Container Build & In-Toto Attestation Standard critical for AI coding assistants?

Enforces SLSA (Supply-chain Levels for Software Artifacts) v1.0 Level 3 compliance across all production container images. Mandates isolated, ephemeral build environments with strict network sandboxing during compilation and requires non-forgeable, cryptographically signed in-toto provenance generated by an authenticated build platform. 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 (Non-Hermetic Container Builds with Self-Generated, Mutable Provenance) 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