Skip to content

Security

This document outlines security practices in the template.

Note

See installation/hardening for additional security measures.

Checks

Key security checks include:

Important

These checks run both locally (prek) and in CI/CD.

Tip

Configuration is primarily in pyproject.toml and prek.toml, with a few additional settings in .github/workflows.

GitHub Actions

Important

See GitHub Actions section for details.

Security measures:

  • Minimal permissions for GitHub Actions
  • Software Bill of Materials (SBOMs): Generated, stored, and attested in releases
  • Reusable workflows for key tasks (e.g., release, test) to minimize misconfiguration risks (more info ⧉)
  • Egress monitoring: stepsecurity/harden-runner ⧉
  • Static analysis: actionlint ⧉

Important

Security checks (e.g., scorecard) run weekly.

SLSA

SLSA ⧉ status of the released distributions:

  • Build track: L3 ⧉ (L2 for open-nudge/opentemplate itself, as it relies on its own build). Distributions are built and their provenance attested by reusable workflows running no project code. _release-vsa.yml verifies the provenance and attests the result as a Verification Summary Attestation ⧉ (VSA), bundled with the distributions in the release (see release process).

Security documents

Tip

Review these documents and adapt them to your project.

Following Open Source Security Foundation best practices ⧉:

Important

See the full OpenSSF Scorecard checklist ⧉.

Adjustments

Most security configurations (e.g., check-security, check-workflow) are in pyproject.toml. Additional security workflows are in .github/workflows (prefix: security-, reusable workflows additionally prefixed with _).

Security tab categories

Scanners do not upload results themselves (pull requests run without write permissions). Their SARIF files are uploaded by .github/workflows/_security-upload.yml on main (push and weekly) and during releases, one analysis per tool, categorized as /tool:<tool>/scope:<scope>/language:<language>:

Tool Category
CodeQL /tool:codeql/scope:workflows/language:actions
zizmor /tool:zizmor/scope:workflows/language:actions
Semgrep /tool:semgrep/scope:repository/language:all
uv audit /tool:uv-audit/scope:dependencies/language:python
GuardDog /tool:guarddog/scope:dependencies-<tier>/language:python
GuardDog /tool:guarddog/scope:actions/language:actions
Trivy /tool:trivy/scope:sbom-<name>/language:python
Trivy /tool:trivy/scope:licenses-<name>/language:python
Scorecard /tool:scorecard/scope:repository/language:all

Note

Analyses uploaded under other categories (e.g. by previous template versions) are not replaced. Delete them under Security → Code scanning → Tool status so their alerts get closed.

Analyses are kept per ref and category:

  • main (push and weekly) replaces the previous main analysis, so the Security tab reflects the latest commit, not the latest release
  • releases upload against the tag (separate from main); the SARIF files are also attested and attached to the GitHub release, describing exactly the released commit
  • pull requests upload nothing, findings are listed in the job summary

uv audit

uv audit checks uv.lock (all groups) against the OSV database ⧉ on every commit (prek) and in CI. Fixes arrive as Dependabot security updates, which (unlike version updates) are not delayed by the 7 day cooldown, see SECURITY-DEPENDENCY.md. To ignore specific vulnerabilities, add their IDs (any alias) with a reason to [tool.uv.audit] in pyproject.toml:

  • ignore - not applicable to the project
  • ignore-until-fixed - no fix released yet, reported again once it is

Trivy

Trivy ⧉ scans the Python SBOMs (per tier, Python version and OS) for known vulnerabilities and the licenses of the distributed environments (core and extras) on pull requests (job summary only), weekly (main and the latest release) and before every release (.github/workflows/_sbom.yml) (latter two being uploaded to the security tab). Vulnerabilities are triaged in the Security tab, while licenses outside of the allowed ones fail the job (see legal).

Configuration (allowed licenses) is stored in .trivy.yaml, triaged findings are ignored in .trivyignore.yaml. Both files are required, used by every scan, attested and attached to releases (trivy-config-<commit SHA>.yaml, trivy-ignore-<commit SHA>.yaml), so what the released scans ignore can be audited.

Every run installs the newest Trivy release published at least 7 days ago (the Dependabot-like cooldown), so no manual updates are needed, while compromised releases (like v0.69.4 ⧉, withdrawn after 3 hours) are not used. The version used is recorded in every SARIF (tool.driver.version), attested and released with the scans. The vulnerability database is downloaded on every run.

Note

GitHub Actions are not scanned by Trivy (it does not match them), their known vulnerabilities are reported by zizmor.

GuardDog

GuardDog ⧉ looks for malicious code (heuristics such as obfuscation, exfiltration or typosquatting) in Python dependencies and in the source of third-party actions used by .github/workflows steps (.github/workflows/*security-guarddog*.yml). Unlike uv audit, Trivy or zizmor, it does not rely on known advisories. GuardDog is installed (hash-locked) from the template's dev-security group.

Python dependencies are scanned per tier (as SBOMs are):

Tier Dependencies Scanned on
core --no-default-groups releases
extras --no-default-groups --all-extras pull requests, main, release

Note

Heuristics produce false positives, therefore findings do not fail the check. Review them in the Security tab (dismissed alerts stay dismissed). On pull requests findings are listed only in the job summary.

Important

Development dependencies are not scanned. GuardDog downloads every package anew (roughly 1.5 seconds per package), the template's own development dependencies (over 250 packages) take around 8 minutes.

Excluded rules (--exclude-rules in the reusable workflow):

  • capability-* (Python dependencies only): describe normal behavior (reading files, spawning processes, network access), around 90% of findings for Python packages. Actions are scanned with all rules, their capabilities (e.g. downloads, spawned processes) are few and worth triaging in the Security tab
  • repository_integrity_mismatch: fully clones the GitHub repository of every package (for 68 dependencies it took 10 minutes instead of 2, a single repository took over 5 minutes), finding no issues in practice

Warning

Maintainers' e-mail domains are checked with WHOIS (unclaimed or re-registered domains indicate account takeover risk). harden-runner ⧉ allows only the WHOIS servers of currently used top-level domains. If the job warns about coverage and its log shows Error trying to connect to socket, add the missing registry (see its IANA entry) to the reusable workflow.

Known limitations (the job warns when something was not scanned):

  • GuardDog exits successfully even if a package could not be downloaded
  • actions referenced by a path inside a repository (e.g. github/codeql-action/init) and docker:// images are not scanned, neither are actions used by composite actions in .github/actions
  • each action is scanned once per workflow using it, identical results are deduplicated and alerts point to the first such workflow

CodeQL

CodeQL ⧉ only analyzes GitHub Actions workflows (.github/workflows/*security-codeql*.yml). Pull requests fail on any finding, while results are uploaded to the Security tab on main (push and weekly) and attached to releases.

Important

Dismissing an alert in the Security tab does not affect the check, the findings have to be fixed.

Warning

GitHub's CodeQL default setup rejects uploads of the advanced setup. harden.yml disables it (best effort), otherwise go to Settings → Advanced Security → CodeQL analysis → ⋯ and choose Disable CodeQL (or Switch to advanced). If an organization security configuration enforces default setup, an organization owner has to change it.

Note

Advanced setup needs no switch, the first upload enables code scanning for public repositories. Private repositories need GitHub Code Security, see Without GitHub Code Security.

zizmor

zizmor ⧉ audits GitHub Actions workflows (check-github in pyproject.toml) on pull requests, on main (push and weekly) and during releases.

Important

Outside of pull requests zizmor is installed from open-nudge/opentemplate (dev-security group) and ignores zizmor configuration files (--no-config), so the attested results cannot be altered by the project. Use inline # zizmor: ignore[<audit>] comments instead.

Without GitHub Code Security

Private repositories need GitHub Code Security ⧉ (formerly part of GitHub Advanced Security) for the Security tab. Without it set the NO_GITHUB_CODE_SECURITY configuration variable (repository or organization) to any value, e.g. true, which:

  • skips CodeQL (the required check passes as skipped), as its license ⧉ does not allow analyzing private code without GitHub Code Security
  • skips uploads to the Security tab, findings are listed in the job summary of each scanner instead (checks still fail on findings)

Note

SARIFs are still produced and attached to releases. Their attestation depends only on NO_GITHUB_ENTERPRISE_CLOUD (see release process).

Caution

This escape hatch is ignored for public and internal repositories!

Conform

siderolabs/conform ⧉ enforces DCO sign-off and GPG signatures. Modify .conform.yml to adjust checks.

Additional resources