CI/CD Supply-Chain Security
Control identity, artifacts, secrets, and promotion policy along the path code already travels. A scanner report is not a security program.
When a long-lived AWS access key leaks, impact follows effective permissions—not admin by default. Identify the principal, contain the key, investigate CloudTrail limits, and replace standing credentials with roles and OIDC.
Muted looping landscape animation in eight stages — Committed, Flagged, Used, IAM decides, Logged, Detected, Revoked, Prevented — for an illustrative IAM user ci-uploader in account 111122223333 with masked access key AKIA**************** and source IP 203.0.113.45. Shows that blast radius follows effective permissions, sts GetCallerIdentity is not a permissions test, CloudTrail management versus data events, GuardDuty detection is not guaranteed, and deactivation stops new calls without undoing earlier actions.
Long-lived IAM user access keys (AKIA…) are still found in public Git history, CI logs, and paste sites. Automated scanners and opportunistic actors often discover public keys quickly. The useful engineering question is not “did someone get a key?” but what that principal can still do—its effective permissions—and how fast you can stop new use while investigating what already happened.
This guide walks an illustrative scenario: IAM user ci-uploader in account 111122223333, access key ID masked as AKIA****************, source IP 203.0.113.45 (documentation range). Outputs and findings are educational examples, not a Cloud9 Solutions customer incident and not attack instructions.
Related prevention context already lives in CI/CD Supply-Chain Security and Building Reliable CI/CD Pipelines with GitHub Actions. This article focuses on exposure response and blast-radius reasoning.
A typical path:
.env, Terraform state fragments, or a hard-coded AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY.AKIA prefix.Confirm which IAM principal owns the key and whether it has been used:
# Illustrative — run with an approved responder identity, not the leaked key.
aws iam get-access-key-last-used \
--access-key-id AKIA****************
aws iam generate-credential-report
aws iam get-credential-report \
--query 'Content' --output text | base64 --decode > credential-report.csvUseful signals:
userIdentity.accessKeyId — management events attributed to that key (region-scoped Event history limits apply; see below).sts get-caller-identity — only when run by responders in a safe, deliberate context to map account/user ARN. It is not a permissions test (next section).AWS may attach a managed quarantine policy such as AWSCompromisedKeyQuarantineV2 (and related quarantine policy versions) and open a support case when it detects exposed credentials. Mention that path when you see the policy attached; do not invent case details. Always follow current AWS guidance for compromised credentials (temporary credential denial patterns, access key rotation).
Identity-based policies on the user or its groups are only one input. Effective access also depends on:
| Control | Role in evaluation |
|---|---|
| Identity-based policies | What the principal’s IAM policies allow/deny |
| Resource-based policies | What the resource itself allows (S3 bucket policy, KMS key policy, etc.) |
| SCPs | Organization ceilings on what member accounts can allow (SCPs) |
| RCPs | Organization resource-control filters when used (RCPs) |
| Permission boundaries | Maximum permissions an identity can ever receive (boundaries) |
| Session policies | Extra filter on temporary credentials |
| Explicit Deny | Always wins over Allow |
| Implicit Deny | Default when nothing allows the request |
In the illustrative ci-uploader scenario, effective access is only s3:ListBucket on app-uploads and s3:GetObject on app-uploads/*. Calls such as iam:CreateUser or ec2:RunInstances are denied. Impact tracks that wedge—not “full admin because a key leaked.”
Tools that help reason about Allow/Deny before or during response:
A principal (here an IAM user access key) calls an AWS API. Evaluation asks whether that request is allowed for that action, resource, and context.
Identity policies, resource policies, SCPs, RCPs, permission boundaries, and session policies can all carry Deny. One explicit Deny ends evaluation with DENY.
If the account is in AWS Organizations, Service Control Policies (SCPs) and Resource Control Policies (RCPs) can prevent an Allow even when the account’s own policies would permit the action.
If a permission boundary or session policy is present, the request must also be allowed by that filter. Missing Allow there is a Deny for this request.
In the common same-account case, an Allow from identity-based policy or resource-based policy can authorize the request after earlier filters pass. Cross-account access has additional trust and resource-policy requirements.
If nothing explicitly allows the request after Deny and filter checks, the result is Deny. Effective permissions are the intersection of what is allowed—not “admin because a key exists.”
Focus: Any explicit Deny?. Identity policies, resource policies, SCPs, RCPs, permission boundaries, and session policies can all carry Deny. One explicit Deny ends evaluation with DENY.
Illustrative decision order aligned with AWS IAM policy evaluation logic. Explicit Deny always wins; Organizations SCPs/RCPs and permission boundaries/session policies can filter Allows; otherwise identity or resource Allow may authorize; default is implicit Deny. Cross-account requests add trust-policy and resource-policy nuance.
Cross-account access adds trust-policy and resource-policy requirements beyond this same-account sketch. See the official policy evaluation logic.
sts:GetCallerIdentity is not a meaningful permissions testGetCallerIdentity returns the account and principal for the credentials in use. It does not require IAM permissions. It can succeed even when every meaningful API is denied—including when an explicit Deny is present for other actions. An explicit Deny cannot “block” GetCallerIdentity the way it blocks s3:GetObject.
Treat a successful GetCallerIdentity as evidence that the key material is valid and active, not that the principal is powerful.
Illustrative management-event lookups (responder identity):
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=AccessKeyId,AttributeValue=AKIA**************** \
--max-results 50GuardDuty only helps if enabled. Finding families such as UnauthorizedAccess:IAMUser, CredentialAccess, Stealth:IAMUser, or PenTest:IAMUser (see the active finding types list) may fire on unusual API use—detection is not guaranteed. Also review IAM Access Analyzer, AWS Config, Security Hub, billing / Cost Anomaly Detection, and AWS Health / abuse notifications when available.
AWS’s practical order for exposed IAM user keys:
Inactive) so new signed requests fail.aws iam update-access-key \
--user-name ci-uploader \
--access-key-id AKIA**************** \
--status Inactiveaws:TokenIssueTime (issue time before containment).Illustrative deny-for-old-sessions sketch (educational; tailor and review before use):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenySessionsIssuedBeforeContainment",
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"DateLessThan": {
"aws:TokenIssueTime": "2026-11-18T10:15:00Z"
}
}
}
]
}After containment, enumerate what the principal could do and what did happen:
Data access (if logged)
GetObject, ListBucket, …) when data-event logging existssecretsmanager:GetSecretValue, ssm:GetParameter / GetParametersByPathResource creation
ec2:RunInstances in every Region, Lambda functions, other compute or data storesPersistence and privilege expansion
iam:CreateUser, CreateAccessKey, CreateLoginProfileAttachUserPolicy, PutUserPolicy, PutRolePolicy, UpdateAssumeRolePolicyDeactivation does not remove users, keys, instances, or policies already created. Find and remove them deliberately, then verify with CloudTrail and inventory across Regions.
AKIA in secrets (configure OIDC with AWS):# Educational fragment. Pin actions by digest in high-risk repos.
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::111122223333:role/github-deploy
aws-region: eu-central-1Illustrative trust-policy conditions for the role (scope tightly):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
},
"StringLike": {
"token.actions.githubusercontent.com:sub": "repo:example-org/example-repo:ref:refs/heads/main"
}
}
}
]
}AWSCompromisedKeyQuarantineV2 managed policyNeed help hardening AWS identity, delivery pipelines, or incident readiness? Explore Cloud9 Solutions.
Control identity, artifacts, secrets, and promotion policy along the path code already travels. A scanner report is not a security program.
Isolate blast radius with accounts, identities, state, and promotion of the same artifact—not a shared admin role with three VPC names.
Build once, use short-lived identities, protect release gates, and verify the artifact you actually deploy.