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. |
How it works
Section titled “How it works”- The pull request controls the files scanned. It does not control how they are scanned.
- Each trusted workflow has two jobs:
scanreads the pull request’s files. It can only read the repository. It never runs the pull request’s code.reportsends 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.
Set it up
Section titled “Set it up”-
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 itsstarter/trusted-workflows/folder. - Make a new, separate repository, for example
acme/arbiter-trusted. - Copy
secret-scan.yml,dependency-check.yml,terraform-validate.ymlandtrusted-repo-ci.ymlto.github/workflows/in it. - Copy the
gitleaks/andterraform/folders,caller.ymland theci/folder (the tests) to the top of it. trusted-repo-ci.ymlruns the tests on every change. Make its check required in step 2.- In all three workflows, in the
reportjob, set the two values markedSET-ME:ARBITER_URL: your Arbiter’s address, for examplehttps://arbiter.acme.com. It must behttps.ARBITER_AUDIENCE: the same value as Arbiter’sARBITER_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-repoexception insecret-scan.yml, or replace it with your own (see “Exact-value exceptions”).
- These files come with the starter files in your Arbiter release image. Write them out with
-
Protect it. Protect it like the policy repository: required reviews, the
trusted workflow testscheck required, and no bypass. Set its Actions access so the pilot repositories can call its workflows. Whoever can merge to it controls the scan. -
Pin its commit in policy. Name each trusted workflow and its full commit sha in the
required_checksof 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-validatewithacme/arbiter-trusted/.github/workflows/terraform-validate.ymlthe same way, in the entry for your Terraform paths (for exampleinfrastructure/**).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-levelalways_required_checkslist instead, as the starter policy does.The starter policy,
starter/policies/acme/payments-api/policy.yaml, names all three trusted workflows withacme/arbiter-trustedand a placeholder commit (markedSET-ME): the secret scan underalways_required_checks, the dependency check in thepackage.jsonentry, which every dependency rule reuses, and the Terraform check in theinfrastructure/**entry. Replace the repository and the commit in all three. -
Call it from each pilot repository. Copy
caller.ymlto.github/workflows/arbiter-trusted-scans.ymlon the repository’s default branch. Change onlyacme/arbiter-trustedand the three commit shas. -
Set
ARBITER_OIDC_AUDIENCEon Arbiter, to the same value asARBITER_AUDIENCE. -
Run the route check (below).
Rules for the caller
Section titled “Rules for the caller”- Use the caller exactly as given. Never add steps, jobs,
with:orsecrets:to it. - Never add
secrets: inherit. The trusted workflows read no secret, butsecrets: inheritwould 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’s pull_request_target policy
Section titled “GitHub’s pull_request_target policy”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.
Changing the pinned commit
Section titled “Changing the pinned commit”Change things in this order:
- Merge the change in the trusted repository.
- Update the commit sha in each pilot repository’s caller.
- Update
trusted_workflow_shain 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.
Network
Section titled “Network”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.
Route check
Section titled “Route check”Post a token that is not valid. Expect 401 from Arbiter, not an error from a proxy:
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/1401means the route reaches Arbiter.403,404,405or502means a proxy is in the way. Fix the proxy.503meansARBITER_OIDC_AUDIENCEis 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.
What fails the scan, and what to do
Section titled “What fails the scan, and what to do”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.tomlandosv-scanner.tomlin 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. Thegitleaks:allowcomment 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.
Dependency coverage
Section titled “Dependency coverage”- 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 eachgo.sum, thego.modbeside it is scanned instead. Ago.sumwith nogo.modbeside it fails the check. - Other manifest types are not scanned by name. A second, whole-tree OSV-Scanner run (with
.gitignorenot 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.
-
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 readRuleIDandMatchfrom the JSON report. -
In
secret-scan.yml, step “Build the gitleaks config”, add a line under your repository’s name:Terminal window case "$GITHUB_REPOSITORY" inacme/payments-api)add_exception 'generic-api-key' 'client_secret = "<the fake value>"';;esacUse the repository name exactly as GitHub shows it. Values with a
'cannot be written here. -
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.
Stated limits
Section titled “Stated limits”- 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
successhas 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 check
Section titled “Terraform check”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
.tfand.tf.jsonfile 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=falsethenterraform validateinside 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,.terraformrcandterraform.rcpaths are removed from the copy. A.tffile under.terraform/orterraform.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”:
case "$GITHUB_REPOSITORY" in acme/payments-api) module_only_dir 'modules/vpc' ;;esacA 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
successhas 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.
Changing versions (Terraform)
Section titled “Changing versions (Terraform)”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.
- The image. Take the new tag’s multi-platform digest with
docker buildx imagetools inspect hashicorp/terraform:<version>(theDigest:line). Puthashicorp/terraform@sha256:<digest>inIMAGEin the steps “Install the pinned Terraform and providers” and “Validate every Terraform folder”, interraform/pins.txt’simageline, and inINSTALL_RUNandVALIDATE_RUN, the self-test’s copies of those two steps. - A provider. Take the
linux_amd64zip’s sha256 from HashiCorp’shttps://releases.hashicorp.com/terraform-provider-<type>/<version>/terraform-provider-<type>_<version>_SHA256SUMS. Change the provider line in the install step, inINSTALL_RUNand interraform/pins.txt’sproviderline, and theincludelist in the CLI config (in the step and inINSTALL_RUN) for a new provider. - Run the CI. Then follow “Changing the pinned commit”.
Changing gitleaks or OSV-Scanner versions
Section titled “Changing gitleaks or OSV-Scanner versions”- Take the new version’s checksums from its official GitHub release, and the binary’s sha256 for linux x64.
- For gitleaks, copy
config/gitleaks.tomlfrom the new tag togitleaks/gitleaks.toml. Review the rule changes. Updategitleaks/rules-manifest.txt(IDs, count,ids-sha256). - Update the pins in the workflow: the download URL,
GITLEAKS_SHA256orOSV_SCANNER_SHA256, and for gitleaksDEFAULT_CONFIG_SHA256,RULE_COUNT,RULE_IDS_SHA256and the config URL’s commit. - 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
gitonly; - the
reportjob, against a local stub; - the
scanjob’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
scansteps, against fixture repositories, with the pinned image and provider. This test also needs Docker andunzip, whichubuntu-latesthas.
Built from Arbiter 0.1.3 at commit 05d1dcb.