Attestation - FOSSA

Attestation

A digitally signed statement or evidence about software artifacts that verifies specific properties, origins, or processes related to the software supply chain, enhancing trust and transparency.

What is Attestation?

In the context of software supply chain security, an attestation is a digitally signed statement that verifies specific properties, origins, or processes related to software artifacts. Attestations serve as cryptographically verifiable evidence that particular claims about software are true, providing a foundation for trust in the software supply chain.

Attestations are created by trusted entities (attestors) who have firsthand knowledge of the claims being made. These statements are then cryptographically signed to ensure their authenticity and integrity, allowing consumers to verify that the software meets specific security or compliance requirements.

Types of Software Supply Chain Attestations

Build Attestations

Statements about how a software artifact was built:

Provenance Attestations

Statements about the origin and history of software:

Policy Attestations

Statements about compliance with security policies:

Testing Attestations

Statements about testing performed:

Attestation Formats and Standards

in-toto Attestations

The in-toto framework provides a format for supply chain security attestations:

{
  "_type": "https://in-toto.io/Statement/v0.1",
  "predicateType": "https://slsa.dev/provenance/v0.2",
  "subject": [
    {
      "name": "example-package",
      "digest": {"sha256": "abcdef123456..."}
    }
  ],
  "predicate": {
    "builder": {"id": "https://github.com/actions/runner"},
    "buildType": "https://github.com/actions/runner/build",
    "invocation": {
      "configSource": {
        "uri": "git+https://github.com/example/repo@refs/heads/main",
        "digest": {"sha1": "abc123..."},
        "entryPoint": ".github/workflows/build.yml"
      }
    },
    "buildConfig": {
      "commands": ["npm ci", "npm run build"]
    },
    "materials": [
      {
        "uri": "git+https://github.com/example/repo@refs/heads/main",
        "digest": {"sha1": "abc123..."}
      }
    ]
  }
}

SLSA Provenance

The Supply-chain Levels for Software Artifacts (SLSA) framework defines provenance attestation formats:

{
  "_type": "https://in-toto.io/Statement/v0.1",
  "predicateType": "https://slsa.dev/provenance/v0.2",
  "subject": [
    {
      "name": "example-artifact.tar.gz",
      "digest": {"sha256": "abcdef123456..."}
    }
  ],
  "predicate": {
    "builder": {"id": "https://github.com/Attestations/builder@v1"},
    "buildType": "https://github.com/Attestations/builder/cloudbuild@v1",
    "invocation": {
      "configSource": {
        "uri": "git+https://github.com/example/repo@refs/heads/main",
        "digest": {"sha1": "abc123..."},
        "entryPoint": "cloudbuild.yaml"
      }
    },
    "materials": [
      {
        "uri": "git+https://github.com/example/repo@refs/heads/main",
        "digest": {"sha1": "abc123..."}
      }
    ]
  }
}

SBOM Attestations

Software Bill of Materials (SBOM) can be wrapped as attestations to verify component inventories:

{
  "_type": "https://in-toto.io/Statement/v0.1",
  "predicateType": "https://spdx.dev/Document/v2.3",
  "subject": [
    {
      "name": "example-package",
      "digest": {"sha256": "abcdef123456..."}
    }
  ],
  "predicate": {
    "SPDXID": "SPDXRef-DOCUMENT",
    "name": "example-sbom",
    "packages": [
      {
        "name": "example-package",
        "SPDXID": "SPDXRef-Package-1",
        "versionInfo": "1.0.0",
        "downloadLocation": "https://example.com/packages/example-1.0.0.tgz",
        "filesAnalyzed": true,
        "licenseConcluded": "MIT",
        "licenseDeclared": "MIT"
      }
    ],
    "relationships": [
      {
        "spdxElementId": "SPDXRef-DOCUMENT",
        "relatedSpdxElement": "SPDXRef-Package-1",
        "relationshipType": "DESCRIBES"
      }
    ]
  }
}

Sigstore Cosign Attestation

Cosign from the Sigstore project supports creating and verifying attestations:

{
  "payload": {
    "body": {
      "_type": "https://in-toto.io/Statement/v0.1",
      "predicateType": "https://slsa.dev/provenance/v0.2",
      "subject": [{"name": "example", "digest": {"sha256": "abcdef123456..."}}],
      "predicate": {"builder": {"id": "https://github.com/actions/runner"}}
    }
  },
  "signatures": [
    {
      "keyid": "SHA256:abcdef123456...",
      "sig": "base64encodedSignature=="
    }
  ]
}

Creating and Managing Attestations

Attestation Generation

Attestations are typically generated as part of automated build and release processes:

# Example using Sigstore Cosign to create an attestation
cosign attest --key cosign.key \
  --type slsaprovenance \
  --predicate provenance.json \
  registry.example.com/myapp:1.0.0

Attestation Storage and Distribution

Attestations can be stored and distributed through various methods:

Attestation Verification

Consumers verify attestations to establish trust in software:

# Example using Sigstore Cosign to verify an attestation
cosign verify-attestation \
  --key cosign.pub \
  --type slsaprovenance \
  registry.example.com/myapp:1.0.0

Attestation in CI/CD Pipelines

GitHub Actions Example

Generating attestations in GitHub Actions:

name: Build and Attest

on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      id-token: write  # Required for keyless signing
      packages: write  # Required for pushing to GHCR

steps:
      - uses: actions/checkout@v3

- name: Build application
        run: |
          npm ci
          npm run build

- name: Generate provenance
        uses: slsa-framework/slsa-github-generator@v1
        with:
          artifact-path: ./dist/app.js
          output-path: ./provenance.json

- name: Install Cosign
        uses: sigstore/cosign-installer@main

- name: Sign and attest artifact
        run: |
          cosign sign-blob --key env://COSIGN_PRIVATE_KEY ./dist/app.js > app.sig
          cosign attest --key env://COSIGN_PRIVATE_KEY --predicate ./provenance.json ./dist/app.js
        env:
          COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}

GitLab CI Example

Generating attestations in GitLab CI:

stages:
  - build
  - attest

build:
  stage: build
  script:
    - npm ci
    - npm run build
  artifacts:
    paths:
      - dist/

attest:
  stage: attest
  script:
    - apt-get update && apt-get install -y jq curl
    - curl -sLO https://github.com/slsa-framework/slsa-verifier/releases/download/v1.0.0/slsa-verifier-linux-amd64
    - chmod +x slsa-verifier-linux-amd64
    - |
      cat <<EOF > provenance.json
      {
        "_type": "https://in-toto.io/Statement/v0.1",
        "predicateType": "https://slsa.dev/provenance/v0.2",
        "subject": [
          {
            "name": "app.js",
            "digest": {"sha256": "$(sha256sum dist/app.js | cut -d ' ' -f 1)"}
          }
        ],
        "predicate": {
          "builder": {"id": "https://gitlab.com/project/pipeline"},
          "buildType": "https://gitlab.com/project/pipeline/job",
          "invocation": {
            "configSource": {
              "uri": "git+https://gitlab.com/project@$CI_COMMIT_SHA",
              "digest": {"sha1": "$CI_COMMIT_SHA"}
            }
          },
          "materials": [
            {
              "uri": "git+https://gitlab.com/project@$CI_COMMIT_SHA",
              "digest": {"sha1": "$CI_COMMIT_SHA"}
            }
          ]
        }
      }
      EOF
    - curl -sLO https://github.com/sigstore/cosign/releases/download/v1.13.1/cosign-linux-amd64
    - chmod +x cosign-linux-amd64
    - ./cosign-linux-amd64 attest --key $COSIGN_PRIVATE_KEY --predicate provenance.json dist/app.js
  dependencies:
    - build

Consuming and Verifying Attestations

Verification in Deployment Pipelines

Attestations can be verified before deploying software:

name: Deploy with Attestation Verification

on:
  workflow_dispatch:

jobs:
  verify-and-deploy:
    runs-on: ubuntu-latest

steps:
      - name: Install Cosign
        uses: sigstore/cosign-installer@main

- name: Verify attestation
        run: |
          cosign verify-attestation \
            --key cosign.pub \
            --type slsaprovenance \
            registry.example.com/myapp:1.0.0

- name: Deploy if verified
        if: ${{ success() }}
        run: |
          # Deploy the verified artifact
          kubectl apply -f deployment.yaml

Policy Enforcement with Open Policy Agent

Enforcing attestation policies using OPA:

package attestation

# Allow deployment only if a valid SLSA provenance attestation exists
allow_deployment {
  input.attestations[_].predicateType == "https://slsa.dev/provenance/v0.2"
  verify_builder_identity
}

# Verify the builder is from a trusted source
verify_builder_identity {
  input.attestations[_].predicate.builder.id == "https://github.com/actions/runner"
}

Container Security with Kubernetes Admission Controllers

Enforcing attestation verification during container deployment:

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
  name: verify-image-attestations
spec:
  failurePolicy: Fail
  matchConstraints:
    resourceRules:
    - apiGroups: [""]
      apiVersions: ["v1"]
      operations: ["CREATE", "UPDATE"]
      resources: ["pods"]
  validations:
    - expression: "has(object.spec.containers[0].image) && object.spec.containers[0].image.contains('verify-attestation')"

Benefits of Attestation in Software Supply Chain

Enhanced Trust and Verification

Attestations enable:

Regulatory Compliance

Attestations support compliance with:

Security Risk Reduction

Attestations help mitigate:

Challenges and Limitations

Complexity of Implementation

Implementing attestations can be challenging due to:

Ecosystem Maturity

The attestation ecosystem is still developing:

Verification Challenges

Verification systems may face:

Future of Attestations

Emerging Trends

The field of software attestations is evolving rapidly:

Industry Adoption

Increasing adoption across sectors:

Research and Development

Ongoing areas of innovation: