Agent Wranglers

APS-74Required

Keep secrets out of builds from strangers

Never give deploy keys or other secrets to builds that run code from outside contributors. Give each build job only the access it needs.

How to do it

Run pull requests from forks without secrets. Never check out or run a fork's code in a job that has secrets, such as a GitHub pull_request_target job. Keep deploy keys in protected environments that only the main branch can use. Prefer short-lived cloud tokens through OIDC over stored keys. Pin build actions to a full commit hash, as Lock every CI action and its dependencies to a reviewed commit says. Give the build token read-only access unless a job needs more.

Examples

YAML example

permissions:
  contents: read
jobs:
  deploy:
    if: github.ref == 'refs/heads/main'
    environment: production

How to check

Open a test pull request from a fork that prints the environment. No secret appears in the log. A search of the workflows finds no pull_request_target job that checks out the pull request's code, and every action is pinned to a 40-character hash.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/application-security/supply-chain/ci-secrets">Agent Wranglers application security playbook</a>. In code you write, add a comment next to it with the same link.