Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions terraform/modules/github-oidc-role/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
# subs (`repo:owner/repo:*`) are a well-known GHA OIDC footgun: a forked
# PR push, a tag from a malicious actor, or an environment trick can
# mint a token whose `sub` matches the wildcard but should NOT be
# allowed to assume the role. The module's `subject_claims` validator
# also rejects empty lists. If you genuinely want StringLike, fork this
# module rather than weakening it -- forcing the fork makes the
# decision visible in code review.
# allowed to assume the role. The module's `subject_claims` validators
# reject empty lists and any sub containing `*` or `?`. If you
# genuinely want StringLike, fork this module rather than weakening
# it -- forcing the fork makes the decision visible in code review.
#
# - StringEquals on `aud`. AWS STS requires `sts.amazonaws.com`; the
# `audience` variable exists for non-AWS audience reuse (Cognito,
Expand Down
5 changes: 5 additions & 0 deletions terraform/modules/github-oidc-role/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ variable "subject_claims" {
condition = length(var.subject_claims) > 0
error_message = "subject_claims must list at least one explicit sub; wildcard / empty allowlists are not supported."
}

validation {
condition = alltrue([for sub in var.subject_claims : !can(regex("[*?]", sub))])
error_message = "subject_claims must be exact sub strings; wildcard characters (* or ?) are not supported. The trust uses StringEquals, where they would be dead weight at best."
}
}

variable "permissions_policy_json" {
Expand Down