Skip to content

Trusted scans

These files make Arbiter’s secret scan (gitleaks), dependency check (dependency-check) and Terraform check (terraform-validate) count only when they come from a check the pull request cannot change.

The Terraform check runs terraform validate with Terraform 1.17.2 and the hashicorp/aws provider 6.73.0 only. A pull request’s required_providers must accept hashicorp/aws 6.73.0, or the check fails. See “Terraform check”.

File What it is
secret-scan.yml The trusted secret scan (gitleaks 8.30.1). Check name gitleaks.
dependency-check.yml The trusted dependency check (OSV-Scanner 2.7.0). Check name dependency-check.
terraform-validate.yml The trusted Terraform check (Terraform 1.17.2, hashicorp/aws 6.73.0). Check name terraform-validate.
terraform/pins.txt The reviewed pins for the Terraform check: the image digest and each provider’s version, URL and sha256.
gitleaks/gitleaks.toml A copy of gitleaks 8.30.1’s default rules. The workflow downloads the same file and checks its sha256.
gitleaks/rules-manifest.txt The reviewed list of rule IDs the built config must have.
caller.yml The small file each pilot repository runs.
trusted-repo-ci.yml The trusted repository’s own CI: runs the tests below on every change.
ci/ The tests, which trusted-repo-ci.yml runs.
  • The pull request controls the files scanned. It does not control how they are scanned.
  • Each trusted workflow has two jobs:
    • scan reads the pull request’s files. It can only read the repository. It never runs the pull request’s code.
    • report sends the result to Arbiter. It holds the identity token. It never touches the pull request’s files.
  • Arbiter checks GitHub’s identity token. It knows which workflow file, at which commit, sent the result.
  • If the scan does not run or does not pass, Arbiter has no valid result. A missing result denies.
  1. Create the trusted repository from these starters.

    • These files come with the starter files in your Arbiter release image. Write them out with docker run --rm <image> starter > arbiter-starter.tar (no -t), and unpack the tar. This guide and the files it names are in its starter/trusted-workflows/ folder.
    • Make a new, separate repository, for example acme/arbiter-trusted.
    • Copy secret-scan.yml, dependency-check.yml, terraform-validate.yml and trusted-repo-ci.yml to .github/workflows/ in it.
    • Copy the gitleaks/ and terraform/ folders, caller.yml and the ci/ folder (the tests) to the top of it.
    • trusted-repo-ci.yml runs the tests on every change. Make its check required in step 2.
    • In all three workflows, in the report job, set the two values marked SET-ME:
      • ARBITER_URL: your Arbiter’s address, for example https://arbiter.acme.com. It must be https.
      • ARBITER_AUDIENCE: the same value as Arbiter’s ARBITER_OIDC_AUDIENCE (the audience: the token’s intended recipient). Use letters, digits and -._~:/ only.
    • Keep them as literals. Never read them from vars, inputs or the event. The self-test fails if you do.
    • Delete the example-org/example-repo exception in secret-scan.yml, or replace it with your own (see “Exact-value exceptions”).
  2. Protect it. Protect it like the policy repository: required reviews, the trusted workflow tests check required, and no bypass. Set its Actions access so the pilot repositories can call its workflows. Whoever can merge to it controls the scan.

  3. Pin its commit in policy. Name each trusted workflow and its full commit sha in the required_checks of the evidence requirement for the paths it protects:

    evidence_requirements:
    - path_pattern: "payments/**"
    required_approvals: { team: "acme/payments-reviewers", min_approvals: 1 }
    required_checks:
    - name: "gitleaks"
    trusted_workflow: "acme/arbiter-trusted/.github/workflows/secret-scan.yml"
    trusted_workflow_sha: "<40-hex commit>"

    For Terraform, name terraform-validate with acme/arbiter-trusted/.github/workflows/terraform-validate.yml the same way, in the entry for your Terraform paths (for example infrastructure/**).

    The path must also be under protected_paths. To require the scan on every pull request, whatever it changes, put the same entry (name, trusted_workflow, trusted_workflow_sha) under a top-level always_required_checks list instead, as the starter policy does.

    The starter policy, starter/policies/acme/payments-api/policy.yaml, names all three trusted workflows with acme/arbiter-trusted and a placeholder commit (marked SET-ME): the secret scan under always_required_checks, the dependency check in the package.json entry, which every dependency rule reuses, and the Terraform check in the infrastructure/** entry. Replace the repository and the commit in all three.

  4. Call it from each pilot repository. Copy caller.yml to .github/workflows/arbiter-trusted-scans.yml on the repository’s default branch. Change only acme/arbiter-trusted and the three commit shas.

  5. Set ARBITER_OIDC_AUDIENCE on Arbiter, to the same value as ARBITER_AUDIENCE.

  6. Run the route check (below).

  • Use the caller exactly as given. Never add steps, jobs, with: or secrets: to it.
  • Never add secrets: inherit. The trusted workflows read no secret, but secrets: inherit would hand them your repository’s secrets anyway.
  • The caller runs on pull_request_target. This is the one allowed use of it. GitHub runs it from the default branch’s copy of the file, so a pull request cannot change it. It runs for forks and Dependabot alike.
  • It runs with your repository’s rights. It is safe only because the scan never runs the pull request’s code, reads no secret, and keeps the token job away from the pull request’s files. Adding steps can break that.
  • A title or body edit runs nothing, so a stored result stands. A change of target branch runs a fresh scan.
  • The caller lives under .github/, which your policy protects. Changing it needs the named team’s approval.

GitHub can block pull_request_target in some public repositories (see GitHub’s changelog). Check the Actions event policy of each pilot repository. Where needed, allow this caller. If the caller is blocked, no trusted result arrives, and every pull request is denied.

Change things in this order:

  1. Merge the change in the trusted repository.
  2. Update the commit sha in each pilot repository’s caller.
  3. Update trusted_workflow_sha in policy.

Between steps 2 and 3, Arbiter answers 401, because the policy still names the old commit. The check is missing, so pull requests are denied until the policy change merges. This window fails closed. Keep it short.

Arbiter’s proxy must forward POST /api/trusted-check-results/* from any source. GitHub’s runners call it, and their addresses are many and change. If you only allow GitHub’s webhook addresses, or keep Arbiter off the internet, trusted entries cannot work, and every trusted entry denies.

Post a token that is not valid. Expect 401 from Arbiter, not an error from a proxy:

Terminal window
INVALID_TOKEN='not-a-valid-token'
curl -sS -o /dev/null -w '%{http_code}\n' -X POST \
-H "Authorization: Bearer $INVALID_TOKEN" -H 'Content-Type: application/json' \
--data '{"check":"gitleaks","head_sha":"0000000000000000000000000000000000000000","conclusion":"success"}' \
https://arbiter.example.com/api/trusted-check-results/acme/payments-api/1
  • 401 means the route reaches Arbiter.
  • 403, 404, 405 or 502 means a proxy is in the way. Fix the proxy.
  • 503 means ARBITER_OIDC_AUDIENCE is not set on Arbiter.

Also confirm each pilot repository’s caller file is the published one, unchanged except for the owner, repository and shas. The trusted repository’s self-test does not see the caller.

The scan fails, so the check denies, when the pull request’s tree has any of these. A file the pull request adds and deletes again is held to the rows for files over 5 MB, LFS pointers and archives:

The tree has What to do
A submodule Not supported. Keep the code in the repository, or out of the pilot repository.
A symlink that points outside the repository Replace it with a file, or point it inside the repository.
A Git LFS pointer Not supported. Keep large files out of the pilot repository.
A file over 5 MB (5,000,000 bytes), lockfiles included Split it, or keep it out of the repository.
An archive inside an archive inside an archive (deeper than 2) Unpack one level, or remove it.
An archive that cannot be read (damaged or encrypted) Remove it.
A 7z, RAR, Zstandard, LZ4, lzip, .Z, CAB, ar/.deb, RPM, LZO or Snappy archive, or a file named like an archive (.7z, .rar, .zst, .iso, .dmg, …) that is not zip, tar, gzip, bzip2 or xz Not supported. Use zip or tar (optionally gzip, bzip2 or xz), or remove it.
A symlink whose stored content is not a path (over 4,096 bytes, or holding a NUL byte) Replace it with a file.
A directory or symlink named .gitattributes, .gitleaksignore, .gitleaks.toml or osv-scanner.toml Rename it.

Other notes:

  • Every .gitattributes, .gitleaksignore, .gitleaks.toml and osv-scanner.toml in the pull request is moved out before the scan, and scanned as plain text. Your repository’s own scanner settings and ignore files have no effect. The gitleaks:allow comment has no effect.
  • Gitleaks uses its default rules with every allowlist removed. Files under vendor/, node_modules/, lockfiles and other paths the default rules skip are scanned. Expect findings there that a default gitleaks run would not show.
  • Binary files are also scanned as their printable text (strings -a -n 8). Readable archives (zip, tar, gzip, bzip2, xz) are unpacked to depth 2 and their files scanned.
  • OSV-Scanner reads these lockfile names, wherever they are in the tree: package-lock.json, yarn.lock, pnpm-lock.yaml, requirements.txt, poetry.lock, Pipfile.lock, go.sum, Cargo.lock, Gemfile.lock, composer.lock, pom.xml, gradle.lockfile.
  • Each one is scanned by name. If any cannot be read, the check fails.
  • OSV-Scanner 2.7.0 has no reader for go.sum. For each go.sum, the go.mod beside it is scanned instead. A go.sum with no go.mod beside it fails the check.
  • Other manifest types are not scanned by name. A second, whole-tree OSV-Scanner run (with .gitignore not honoured) may pick up others, but coverage is only claimed for the names above.
  • OSV-Scanner finds known vulnerabilities only. It does not catch a new malicious package or a typosquat.
  • Dependabot is GitHub’s service, not Arbiter’s. GitHub can delay its alerts and its fix pull requests, sometimes by hours. Arbiter does not wait for them: when your policy requires the trusted dependency scan, a pull request that changes a dependency file it lists needs a passing scan of its latest commit.

Exact-value exceptions (secret-scan false positives)

Section titled “Exact-value exceptions (secret-scan false positives)”

The only exception is one exact fake value, for one repository. Never a path, a glob or a fingerprint.

  1. Find the rule ID and the whole match text gitleaks 8.30.1 reports for the fake, key name and quotes included. Run gitleaks 8.30.1 with this repository’s built config on the file, without --redact, and read RuleID and Match from the JSON report.

  2. In secret-scan.yml, step “Build the gitleaks config”, add a line under your repository’s name:

    Terminal window
    case "$GITHUB_REPOSITORY" in
    acme/payments-api)
    add_exception 'generic-api-key' 'client_secret = "<the fake value>"'
    ;;
    esac

    Use the repository name exactly as GitHub shows it. Values with a ' cannot be written here.

  3. Run the trusted repository’s CI, then follow “Changing the pinned commit”. A change is a reviewed change and a policy pin bump.

A real secret beside the fake, or a longer match that contains it, still fails. A real secret equal to an allowed fake value would pass.

  • Whoever can merge to the trusted repository controls the scan. The pin covers the workflow file and what it pins (actions by commit, binaries and the default rules by sha256).
  • A scanner can miss what it does not detect. The dependency check finds known vulnerabilities only.
  • A stored success has no age limit. A dependency that becomes known-vulnerable later still passes until the pull request’s head changes.
  • A flaw in a scanner’s parser, reading the pull request’s bytes, could forge the scan’s result. The pinned versions are the mitigation.
  • The limits above (submodules, outside symlinks, LFS, files over 5 MB, deep or unsupported archives) fail the scan.
  • Binary files are scanned through their printable text, which can miss a secret stored compressed or encoded (for example as UTF-16).
  • A file the pull request adds and deletes again is held to the limits for size, LFS pointers and archives: one over 5 MB or an LFS pointer fails the scan, and an archive is unpacked and its members scanned. A symlink’s stored content is read too, at the head and in history.
  • A secret that exists only in a merge commit’s conflict resolution, and is deleted later, may not appear in the history scan. The tree scan covers the head only.
  • A real secret equal to an allowed fake value passes.
  • Results are ordered by run number. Two runs on one head that scan in the opposite order can let an older failure be ignored. The window is small.
  • Dependabot pull requests are covered like any other: their runs get an identity token and their results count. A run that could not reach Arbiter counts only once it is re-run.
  • If your proxy does not forward the route, trusted entries cannot work.

terraform-validate.yml proves that every Terraform folder in the pull request’s commit is valid Terraform for the pinned providers. It does not judge values, and it does not show what would change in the cloud. Safety stays with your other checks and approvals.

How it works:

  • It reads the commit’s files from git’s objects, blob by blob, into a fresh copy. .gitattributes (export-ignore, filters, eol) cannot hide or change a file.
  • Every .tf and .tf.json file in the commit’s whole tree must be in the copy, byte for byte. Its folder is validated. A folder . is the repository root.
  • Each folder runs terraform init -backend=false then terraform validate inside a sealed container: no network access, no Linux capabilities, none of the runner’s environment, and at most 300 seconds per run. Providers install only from the pinned mirror.
  • Planted .terraform, terraform.d, .terraform.lock.hcl, .terraformrc and terraform.rc paths are removed from the copy. A .tf file under .terraform/ or terraform.d/ fails the check: rename the folder.

What fails the check:

The pull request has What to do
A folder that is not valid Terraform Fix it. One invalid folder anywhere fails every pull request on the repository.
required_providers that exclude hashicorp/aws 6.73.0, or any other provider Accept 6.73.0, or add the provider to the pins (below).
A remote module (registry, git, URL) Not supported. Use a local module (source = "./...").
More than 50 Terraform folders Divide the repository, or ask for a higher cap in the trusted repository.
A .tf file under a folder named .terraform or terraform.d Rename the folder.
A folder that runs too long (300 seconds per run, 25 minutes in all) Simplify it.

Module-only folders. A folder that holds only a module, and is not valid alone (for example it needs variables), can be listed in MODULE_ONLY_DIRS, per repository, in the step “Take the Terraform inventory”:

Terminal window
case "$GITHUB_REPOSITORY" in
acme/payments-api)
module_only_dir 'modules/vpc'
;;
esac

A listed folder is not validated alone. It must instead be called by a validated folder: each Dir in that folder’s modules.json, resolved against that folder and normalised, must be the listed path exactly. A listed folder that no validated folder calls, or that holds no .tf file, fails the check. Use the repository folder path exactly.

Time: under linux/amd64 emulation on an arm64 Mac (Terraform 1.17.2), init then validate took about 57 seconds for a folder that uses hashicorp/aws (most of it hashing and loading the provider) and about 2 seconds for a folder with no provider. Native ubuntu-latest runners are faster, but no native figure is recorded yet; take your own measure from the check’s log (the validate step’s time divided by its folders). At the emulated rate, about 26 folders that use hashicorp/aws use up the step’s 25 minutes, so the limit of 50 folders may not be reachable with provider folders: the check then fails with “validated k of m folders”.

Stated limits.

  • The check proves validity for the pinned providers. It does not judge values or show what would change in the cloud.
  • It validates every Terraform folder in the whole tree, not only infrastructure/**. One invalid folder anywhere fails every pull request on the repository.
  • Whoever can merge to the trusted repository controls the check, its pins and MODULE_ONLY_DIRS.
  • Terraform core and the providers read the pull request’s configuration. A flaw in either could affect the result. The pinned digest and hashes, and the sealed container, are the mitigation.
  • Remote modules, unlisted providers, a provider version the pull request’s constraints exclude, and more than 50 folders fail the check.
  • A stored success has no age limit, as with the other trusted checks.
  • Folder names are compared as Linux compares them: two names that differ only in case are two folders.

Change the workflow, terraform/pins.txt and the self-test’s copies of the install and validate steps together, in one reviewed commit. The self-test (in the ci/ folder) holds three steps word for word: INSTALL_RUN, COPY_RUN and VALIDATE_RUN; any edit to one of those steps changes its copy too.

  1. The image. Take the new tag’s multi-platform digest with docker buildx imagetools inspect hashicorp/terraform:<version> (the Digest: line). Put hashicorp/terraform@sha256:<digest> in IMAGE in the steps “Install the pinned Terraform and providers” and “Validate every Terraform folder”, in terraform/pins.txt’s image line, and in INSTALL_RUN and VALIDATE_RUN, the self-test’s copies of those two steps.
  2. A provider. Take the linux_amd64 zip’s sha256 from HashiCorp’s https://releases.hashicorp.com/terraform-provider-<type>/<version>/terraform-provider-<type>_<version>_SHA256SUMS. Change the provider line in the install step, in INSTALL_RUN and in terraform/pins.txt’s provider line, and the include list in the CLI config (in the step and in INSTALL_RUN) for a new provider.
  3. Run the CI. Then follow “Changing the pinned commit”.
  1. Take the new version’s checksums from its official GitHub release, and the binary’s sha256 for linux x64.
  2. For gitleaks, copy config/gitleaks.toml from the new tag to gitleaks/gitleaks.toml. Review the rule changes. Update gitleaks/rules-manifest.txt (IDs, count, ids-sha256).
  3. Update the pins in the workflow: the download URL, GITLEAKS_SHA256 or OSV_SCANNER_SHA256, and for gitleaks DEFAULT_CONFIG_SHA256, RULE_COUNT, RULE_IDS_SHA256 and the config URL’s commit.
  4. Run the CI. Then follow “Changing the pinned commit”.

Copy the ci/ folder (step 1). trusted-repo-ci.yml runs its tests on every change to the trusted repository. They need Python 3.11 or later with its standard library; the scan job’s test also needs Linux, git, bash, curl, jq, strings and network access. trusted-repo-ci.yml runs on ubuntu-latest, which has them. They check:

  • the workflows’ rules, with a deliberate break of each rule to prove the rule fires;
  • the caller’s if;
  • the history scan, against small fixture repositories, with the system git only;
  • the report job, against a local stub;
  • the scan job’s own steps, against fixture repositories, with the pinned binaries. With every exact-value exception deleted, the exception test is skipped;
  • the Terraform check’s scan steps, against fixture repositories, with the pinned image and provider. This test also needs Docker and unzip, which ubuntu-latest has.

Built from Arbiter 0.1.3 at commit 05d1dcb.