Skip to content

LearnCloud

CI pipeline secrets and OIDC trust review

Brief

A deploy pipeline is a standing way into the cloud account, and the review asks who besides the pipeline can use it: anyone who can push a branch, open a pull request, or edit a workflow. The answers are in four places, the stored secrets, the cloud trust policy, the workflow triggers and the runners.

Track
Cloud
Stage
Access
Reviewed
On this page
  1. Check first
  2. Which cloud credentials are stored as CI secrets?
  3. What does the cloud trust from the CI identity provider?
  4. Which workflows run untrusted code with secrets or a write token?
  5. Which runners do these pipelines land on?
  6. The defender sees
  7. Done when
  8. Not covered
  9. Tools
  10. Related research
  11. Where this page fits
  12. Reviewed

All commands

Situation
Read access to the source organization the scope letter names (a GitHub organization or a GitLab group) and a read-only review role in each cloud account the pipelines deploy to. Every command here is a read: secret and variable listings print names and flags, never values, and no workflow is run, edited or triggered. Where the review finds a path, the proof is the trust condition itself; we do not open a pull request to test it unless the client asks for that in writing on a repository created for the test.
Goal
A table per pipeline: the credentials it holds, the cloud roles it can assume and the exact condition that limits them, the triggers that run untrusted code, and the runners it lands on.
Outputs
Representative examples on placeholder hosts, trimmed to the lines that matter. Not captured from a public fixture yet.

Check first

  • Which repositories deploy, and to which cloud accounts, subscriptions or projects.
  • Whether pipelines authenticate with stored keys or with OIDC federation, and which roles they assume.
  • Which events start a workflow, especially anything a person outside the organization can cause.
  • Who can register runners, and whether self-hosted runners are shared between repositories.
  • Where the source platform's audit log goes, so the client can match each read.

Steps

Which cloud credentials are stored as CI secrets?

gh secret list --org example-org
gh secret list --repo example-org/payments-api
curl -s -H "PRIVATE-TOKEN: $GITLAB_REVIEW_TOKEN" "https://gitlab.example.com/api/v4/projects/412/variables" \
  | jq -r '.[] | [.key, .protected, .masked, .environment_scope] | @tsv'

Expected output

$ gh secret list --repo example-org/payments-api
NAME                   UPDATED
AWS_ACCESS_KEY_ID      about 2 years ago   # <- a long-lived cloud key, older than anyone's memory of it
AWS_SECRET_ACCESS_KEY  about 2 years ago
$ curl ... /projects/412/variables | jq ...
AZURE_CLIENT_SECRET	false	true	*   # <- not protected: every branch's pipeline can read it
DEPLOY_ENV	false	false	*

GitHub never returns secret values through its API, so the listing is names and dates. GitLab's variables endpoint does return values, which is why the jq filter keeps only the key and its flags. An unprotected GitLab variable is available to pipelines on every branch, so anyone who can push a branch can read it from a job.

Negative result. No cloud keys or client secrets stored at all, because every deploy uses OIDC, and any remaining variable is protected and scoped to an environment.

Fix. Replace stored cloud keys with OIDC federation, then deactivate and delete the old key. Where a secret must stay, protect it, scope it to the deploy environment, and require a reviewer on that environment.

What does the cloud trust from the CI identity provider?

aws iam list-open-id-connect-providers --query 'OpenIDConnectProviderList[].Arn' --output text
aws iam get-role --role-name github-deploy --query 'Role.AssumeRolePolicyDocument.Statement[].Condition'
az ad app federated-credential list --id <app-id> --query '[].{name:name,subject:subject}' -o table

Expected output

$ aws iam get-role --role-name github-deploy --query ...
[
    {
        "StringLike": {
            "token.actions.githubusercontent.com:sub": "repo:example-org/*"   # <- any repository, any branch, any pull request in the org
        }
    }
]
$ az ad app federated-credential list --id <app-id> --query ... -o table
Name         Subject
-----------  ---------------------------------------------------------
prod-deploy  repo:example-org/payments-api:environment:production

The subject claim names the repository and what triggered the run: a branch, a tag, an environment or a pull request. A wildcard after the organization means every repository in it, including one any member can create, can assume the role. A condition with no sub at all is worse: on a shared issuer like GitHub's, the audience check alone can let other organizations' workflows in. Google Cloud keeps the same rule in the provider's attributeCondition. The AWS escalation page shows how to read what the role itself can then do.

Negative result. Every trust names one repository and one environment or protected branch, with an aud condition of sts.amazonaws.com on AWS.

Fix. Use StringEquals on the full subject, repo:<org>/<repo>:environment:<name>, and protect that environment with required reviewers. Split roles so pull request runs get a read-only role or none.

Which workflows run untrusted code with secrets or a write token?

grep -rnE 'pull_request_target|workflow_run|pull_request\.head|id-token: write|contents: write' .github/workflows/
grep -rhoE 'uses: [^ ]+@[^ ]+' .github/workflows/ | sort -u
gh api /orgs/example-org/actions/permissions/workflow

Expected output

.github/workflows/preview.yml:3:  pull_request_target:   # <- runs with secrets on code from a fork when combined with a head checkout
.github/workflows/preview.yml:18:        ref: ${{ github.event.pull_request.head.sha }}
uses: actions/checkout@v4
uses: example-vendor/scan-action@v2   # <- a movable tag; the vendor's next push runs in this pipeline
{"default_workflow_permissions":"write","can_approve_pull_request_reviews":false}

pull_request_target runs in the base repository's context with its secrets, so checking out the fork's code inside it hands that code the secrets. A third-party action pinned to a tag runs whatever the tag points at next week, which is how one scanner compromise spread. A default token with write permission turns every workflow into one that can push code.

Negative result. No pull_request_target workflow checks out the head, every third-party action is pinned to a full commit SHA, and the default token is read-only.

Fix. Use pull_request for untrusted code, pin actions by SHA with an update bot, set default_workflow_permissions to read, and grant id-token: write only in the deploy job.

Which runners do these pipelines land on?

gh api /orgs/example-org/actions/runner-groups \
  --jq '.runner_groups[] | [.name, .visibility, .allows_public_repositories] | @tsv'

Expected output

Default	all	true   # <- every repository, public ones included, can run on the self-hosted runners
deploy	selected	false

A self-hosted runner shared with every repository lets any of them leave something behind for the next job, including the deploy job, unless each runner is used once and destroyed. On GitLab the same question is whether shared or group runners pick up untagged jobs from any project.

Negative result. Deploy runners sit in a group limited to the deploy repositories, public repositories are refused, and runners are ephemeral.

Fix. Give deploy jobs their own runner group, refuse public repositories, and use ephemeral runners that are rebuilt after every job.

The defender sees

The cloud reads land in CloudTrail and the Azure activity log under the review role: ListOpenIDConnectProviders and GetRole, and Graph reads of the application. The secret and runner listings are API reads on GitHub or GitLab under the review token; those platforms log changes in the audit log rather than reads, so this part of the review is close to invisible, which is worth saying in the report. What the client should already watch is the use of the trust: each AssumeRoleWithWebIdentity event in CloudTrail carries the token's subject, so a deploy role assumed from a repository or branch that is not the deploy one is a high-value alert, and the cloud first hour covers whether CloudTrail is there to catch it.

Done when

Every long-lived cloud key in CI is named by variable and repository, every OIDC trust is recorded with its subject condition, every workflow with a risky trigger or write token is listed, and runner groups are mapped to the repositories that can use them.

Not covered

Build tool and dependency compromise, container image review, and secrets committed to the repository history; the outputs shown are representative examples on a placeholder organization and account, not captured runs.