Many teams still use saved keys

Datadog's 2026 State of Cloud Security report looked at how GitHub Actions signs in to the cloud. "Keyless" means it uses a short-lived OIDC sign-in, not a saved key.

Cloud Keyless only Both Saved keys only
AWS 54% 22% 24%
Azure 5% 52% 43%
Google Cloud 22% 13% 65%

Look at the Both column. If you add OIDC but leave the old key in place, someone can still steal and use that key. In the Azure group, 52% use both methods.

Datadog mostly collected this data from its customers in September 2026. It may not represent every organisation.

How OIDC works

  1. GitHub creates a short-lived, signed token for a job.
  2. The job sends the token to your cloud provider.
  3. The cloud provider checks details such as the repository and environment.
  4. If they match your rules, it gives the job temporary access.

You do not need to save a cloud key in GitHub. However, code in a trusted job can still use that access or steal the temporary credentials. This is why the trust rules and permissions matter.

Do not trust every branch

This AWS rule lets any branch, tag, pull request or environment in the repository use the role, as long as the job can get an OIDC token:

Exampletext
repo:example-org/payments:*

Limiting it to the main branch is better, but may still not be enough. In the wfx-loot attacks, the attacker used stolen tokens to add code to repositories and could ask for OIDC tokens there. If an attacker can push to main, a rule that trusts main will trust their workflow too.

For production, use a protected GitHub environment:

  1. Create an environment called production.
  2. Add required reviewers, if your GitHub plan supports them.
  3. Choose which branches can use it.
  4. Limit who can change its settings or skip its rules.
  5. Limit the cloud role to this environment.

An environment without protection rules does not need approval. Someone who can change the workflow could use its name in their job.

AWS example

This Terraform policy only trusts one environment in one repository:

Examplehcl
data "aws_iam_policy_document" "github_deploy" {
  statement {
    effect  = "Allow"
    actions = ["sts:AssumeRoleWithWebIdentity"]

    principals {
      type        = "Federated"
      identifiers = [aws_iam_openid_connect_provider.github.arn]
    }

    condition {
      test     = "StringEquals"
      variable = "token.actions.githubusercontent.com:aud"
      values   = ["sts.amazonaws.com"]
    }

    condition {
      test     = "StringEquals"
      variable = "token.actions.githubusercontent.com:sub"
      values   = ["repo:example-org/payments:environment:production"]
    }
  }
}

Use this as the role's assume_role_policy. You also need to create the OIDC provider used in the example. The sub value can be different if your organisation has changed its format. Check GitHub's documentation and the value your repository uses before you change a live role.

This policy decides who can use the role. A separate policy decides what it can do. Give the role only the permissions it needs to deploy the app. It should not normally be able to create users, access keys or admin roles.

In the workflow, give OIDC access only to the job that needs it:

Exampleyaml
permissions: {}

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: production
    permissions:
      contents: read
      id-token: write
    steps:
      # Pin each action to a full commit SHA that you have reviewed.
      - uses: actions/checkout@<FULL_COMMIT_SHA>
      - uses: aws-actions/configure-aws-credentials@<FULL_COMMIT_SHA>
        with:
          role-to-assume: arn:aws:iam::123456789012:role/payments-deploy
          aws-region: eu-west-1
      - run: ./deploy.sh

Replace the sample values before you use this workflow. id-token: write lets the job ask for an OIDC token. It does not give any cloud access by itself. Your cloud policy controls that access.

Azure and Google Cloud

Azure: add a federated credential to the app or managed identity, and limit its subject to the GitHub environment. Once it works, delete old client secrets and certificates that were only used for deployment. Check for credentials you do not recognise too.

Google Cloud: set a condition on the identity provider, and limit which GitHub identities can use the service account. Do not allow every identity in the pool. Then delete service account keys that you no longer need.

Remove the old keys

Do this for one workflow at a time:

  1. Find every place that uses the old key. It may be used outside GitHub too.
  2. Set up OIDC and test a normal deployment.
  3. Test that another branch or environment cannot use the role.
  4. Turn off the old key, but do not delete it yet. Watch for errors.
  5. When you are sure nothing needs it, delete it from the cloud and GitHub.
  6. Set up an alert if someone creates a new long-lived key for this deployment account.

If you think a key was stolen, do not wait. Turn it off straight away and follow your incident response process.

To check when an AWS key was last used:

Examplebash
aws iam get-access-key-last-used --access-key-id "$ACCESS_KEY_ID"

Use this with CloudTrail. It only shows the last recorded use, not everywhere the key is used.

What scanners can and cannot find

IaC scanning can find some trust rules and permissions that are too broad. It can only check the files you scan, so it may miss a role made by hand. Secrets scanning can find a key in your code or Git history, but not one stored in GitHub's encrypted secrets. CSPM can check some live cloud permissions. Check the GitHub environment rules yourself, because the cloud settings do not show if an approval is required.

Check your infrastructure and CI/CD files

AquilaX IaC scanning checks Terraform, cloud templates and CI/CD files for risky settings. Included in Premium and Ultimate.

See IaC scanning →