feat: CI role that creates IAM roles without privilege escalation#32
Merged
Conversation
…ge escalation
Extend the GitHub OIDC CI role so it can run `terraform apply` that CREATES IAM
roles, while making self-escalation impossible. Built on the
terraform-aws-modules/iam modules (iam-policy), consistent with the role itself.
Mechanism (full rationale inline in iam-ci.tf):
- Permissions boundary `tf-managed-boundary` caps every CI-created role:
effective perms = intersection(attached policies, boundary). "Admin minus a
hardened deny-list" — no IAM users, no boundary tampering, no org/account
actions, can't edit itself.
- CI grant `tf-managed-ci` (replaces the old AmazonS3ReadOnlyAccess): tight S3
state R/W + IAM role/policy management scoped to a repo path
/tf-managed/<org>/<repo>/, allowed only when the request stamps our boundary.
iam:PassRole is path-scoped; a global backstop Deny refuses any role whose
boundary isn't ours. DeleteRolePermissionsBoundary is deliberately NOT granted.
- The CI role carries no boundary itself (it must set boundaries on children,
which the boundary forbids); it is constrained by its own tight policy.
Verified with `aws iam simulate-principal-policy`: CreateRole in-path with our
boundary = allowed; without boundary = explicitDeny; out-of-path = implicitDeny;
DeleteRolePermissionsBoundary = denied; rewriting the boundary = explicitDeny;
state PutObject = allowed.
Repo-wide contract (documented in CLAUDE.md + README): every aws_iam_role the CI
applies must set permissions_boundary + path; CI feeds the path via
TF_VAR_role_path=/tf-managed/${{ github.repository }}/.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The CI grant was tightened to bucket-scoped S3 access (no s3:ListAllMyBuckets), so `aws s3 ls` with no arg now AccessDenies. Target the state bucket directly (s3:ListBucket), which the grant allows — a more meaningful smoke test anyway. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
nbrieussel
marked this pull request as ready for review
June 13, 2026 14:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Follow-up to #31. The CI OIDC role could only do
aws s3 ls(AmazonS3ReadOnlyAccess). Goal: let it runterraform applythat creates IAM roles, while making self-escalation impossible — using theterraform-aws-modules/iammodules, as discussed.Mechanism (rationale inline in
iam-ci.tf)tf-managed-boundarycaps every CI-created role: effective perms =intersection(attached policies, boundary). "Admin minus a hardened deny-list" (no IAM users, no boundary tampering, no org/account, can't edit itself).tf-managed-ci(replacesAmazonS3ReadOnlyAccess): tight S3 state R/W + IAM role/policy management scoped to/tf-managed/<org>/<repo>/, allowed only when the request stamps our boundary.iam:PassRolepath-scoped. Global backstop Deny on any role whose boundary isn't ours.DeleteRolePermissionsBoundarydeliberately not granted (that would be an escalation).Closes the 3 escalation vectors
iam:PassRolea powerful role → PassRole path-scoped to bounded roles only.DeleteRolePermissionsBoundarynot granted.Verification (
aws iam simulate-principal-policy)allowedexplicitDenyimplicitDenyDeleteRolePermissionsBoundary(escalation)implicitDenyexplicitDenyPutObjecton state bucketallowedRepo-wide contract (⚠️ behaviour change)
Every
aws_iam_rolethe CI applies must setpermissions_boundary(=permissions_boundary_arnoutput) andpath(=managed_pathoutput), or the apply is rejected. CI feeds the path viaTF_VAR_role_path=/tf-managed/${{ github.repository }}/. Documented inCLAUDE.md+aws-github-oidc/README.md.State
Already
terraform apply'd to account503577850357(applied locally with admin SSO, as this root always is).vars.AWS_GITHUB_ACTIONS_ROLE_ARNunchanged (same role).Follow-ups (not in this PR)
terraform apply(withTF_VAR_role_path).🤖 Generated with Claude Code