v0.15 is out: rules that were silently dropped on the shipped engine now run, and scans skip your test and mock files by default. Read more →
MEDIUM AI PREVALENCE: HIGH auth.iac.tf-hardcoded-oauth-secret

A secret-like attribute (client_secret, token, password, api_key, private_key, ...) is assigned a hard-coded string literal in Terraform.

Why AI tools produce this: AI coding tools generate this anti-pattern by default, it appears in a large share of AI-written auth code.

Why this matters

The value ships in the repository and, because Terraform records arguments in state, it also lands in the state file, so it must be treated as leaked and rotated. Read it from a variable (var.*), a secret-manager data source (AWS Secrets Manager, Vault, GCP Secret Manager), or an environment-backed input instead, and keep the value out of both the code and the state where possible.

VULNERABLE
vulnerable.tf
provider "okta" {
  org_name = "example"
  # ruleid: auth.iac.tf-hardcoded-oauth-secret
  api_token = "00aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890abcdef"
  # ruleid: auth.iac.tf-hardcoded-oauth-secret
  client_secret = "s3cr3t-hardcoded-oauth-client-secret-value"
}
SAFE
safe.tf
provider "okta" {
  org_name      = "example"
  api_token     = var.okta_api_token
  client_secret = var.okta_client_secret
}

Suppressing this rule

If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.

// oauthlint-disable-next-line auth.iac.tf-hardcoded-oauth-secret -- <reason>

References

https://cwe.mitre.org/data/definitions/798.html ↗https://developer.hashicorp.com/terraform/language/state/sensitive-data ↗