πŸ”’ Security

SLSA

Supply-chain Levels for Software Artifacts, a supply chain security framework

πŸ“– Detailed Explanation

SLSA (Supply-chain Levels for Software Artifacts, pronounced "salsa") is a software supply chain security framework led by Google. It defines a standard for verifying where software came from, who built it, and whether it has been tampered with.

SLSA presents a four-level (L1-L4) maturity model. L1 is documenting the build process, L2 is using a hosted build service, L3 is isolating the build environment and generating provenance, and L4 is a fully reproducible build. Most organizations aim for L3.

The core concept is "Provenance." The build system signs and attaches an attestation stating, "This artifact was built from this source code, by this builder, at this point in time." Consumers verify it to confirm that the origin is trustworthy.

There are tools that automatically generate SLSA provenance in GitHub Actions and GitLab CI. With slsa-github-generator and slsa-verifier, you can implement L3-level supply chain security.

πŸ’» Code Example

# GitHub Actionsμ—μ„œ SLSA L3 Provenance 생성
# .github/workflows/slsa-build.yml
name: SLSA Build

on:
  release:
    types: [published]

jobs:
  build:
    outputs:
      hashes: \${{ steps.hash.outputs.hashes }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build
        run: make build
      - name: Generate hash
        id: hash
        run: |
          HASHES=\$(sha256sum dist/* | base64 -w0)
          echo "hashes=\$HASHES" >> \$GITHUB_OUTPUT
      - uses: actions/upload-artifact@v4
        with:
          name: dist
          path: dist/

  provenance:
    needs: [build]
    permissions:
      actions: read
      id-token: write
      contents: write
    uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
    with:
      base64-subjects: "\${{ needs.build.outputs.hashes }}"
      upload-assets: true

# SLSA Provenance 검증
slsa-verifier verify-artifact myapp-v1.0.tar.gz \
  --provenance-path myapp-v1.0.tar.gz.intoto.jsonl \
  --source-uri github.com/myorg/myapp \
  --source-tag v1.0

# Provenance λ‚΄μš© 확인
cat myapp-v1.0.tar.gz.intoto.jsonl | jq '.payload | @base64d | fromjson'
# {
#   "buildType": "https://github.com/slsa-framework/slsa-github-generator/...",
#   "builder": {"id": "https://github.com/slsa-framework/slsa-github-generator/..."},
#   "invocation": {"configSource": {"uri": "git+https://github.com/myorg/myapp@refs/tags/v1.0"}},
#   "materials": [{"uri": "git+https://github.com/myorg/myapp", "digest": {"sha1": "abc123"}}]
# }

πŸ—£οΈ How It's Said in Practice

Security: "To prevent supply chain attacks like SolarWinds, you need SLSA L3. You have to generate build provenance and verify it before deployment."

DevOps: "Is it hard to add to our existing pipeline?"

Security: "With slsa-github-generator, you can achieve L3 by adding just one reusable workflow."

Interviewer: "Please explain the requirements of SLSA Level 3."

Candidate: "L3 requires building in an isolated environment on a hosted build service, and the build system must generate tamper-proof provenance. The provenance includes the source code origin, builder identity, and build parameters, all signed."

Take a mock interview on this topic β†’ WIA SOOM AI Interview Β· Start for free

Reviewer: "The --source-uri in slsa-verifier is wrong. Please correct it to the exact repository path."

Author: "Understood. I'll change it to github.com/myorg/myapp."

⚠️ Cautions

πŸ“š Learn More