Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: vault_jwt_auth_backend leaks oidc_client_secret #2206

Open
R0flcopt3r opened this issue Mar 22, 2024 · 1 comment
Open

[Bug]: vault_jwt_auth_backend leaks oidc_client_secret #2206

R0flcopt3r opened this issue Mar 22, 2024 · 1 comment
Labels

Comments

@R0flcopt3r
Copy link

Terraform Core Version

1.7.3

Terraform Vault Provider Version

3.25.0

Vault Server Version

1.15.5

Affected Resource(s)

  • vault_jwt_auth_backend

Expected Behavior

Secrets should not be visible in Terraform state

Actual Behavior

Secrets are visible in state.

Relevant Error/Panic Output Snippet

{
  "mode": "managed",
  "type": "vault_jwt_auth_backend",
  "name": "azure_ad",
  "provider": "provider[\"registry.terraform.io/hashicorp/vault\"]",
  "instances": [
        {
          "schema_version": 1,
          "attributes": {
            "oidc_client_id": "[REDACTED]",
            "oidc_client_secret": "[REDACTED]", # <------- Leaked secret 
            "oidc_discovery_ca_pem": "",
            "oidc_discovery_url": "[REDACTED]",
....
  ]
}

Terraform Configuration Files


resource "vault_jwt_auth_backend" "auth" {
  description = "auth backend"
  path = "oidc"
  oidc_client_id = var.oidc_client_id
  oidc_client_secret = var.oidc_client_secret
  oidc_discovery_url= local.oidc_discovery_url
  default_role = local.oidc_default_role
}

resource "vault_jwt_auth_backend_role" "auth" {
  backend = vault_jwt_auth_backend.auth.path
  role_name = local.oidc_default_role
  user_claim = "email"
  groups_claim = "groups"
  token_policies = ["default"]
  verbose_oidc_logging = true
  oidc_scopes = local.oidc_scopes
  allowed_redirect_uris = local.allowed_redirect_uris
}

resource "vault_identity_group" "group" {
  name = "vault"
  type = "external"
  policies = ["default"]
  metadata = {
    version = "2"
  }
}

resource "vault_identity_group_alias" "group" {
  name = "vault"
  mount_accessor = vault_jwt_auth_backend.auth.accessor
  canonical_id = vault_identity_group.group.id
}

Steps to Reproduce

  1. terraform apply given config with valid variables
  2. inspect terraform state for leaked secrets

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No

@R0flcopt3r R0flcopt3r added the bug label Mar 22, 2024
@fairclothjm
Copy link
Contributor

Hello @R0flcopt3r this is documented behavior as per https://registry.terraform.io/providers/hashicorp/vault/latest/docs

Interacting with Vault from Terraform causes any secrets that you read and write to be persisted in both Terraform's state file and in any generated plan files. For any Terraform module that reads or writes Vault secrets, these files should be treated as sensitive and protected accordingly.

More discussion here: hashicorp/terraform#516

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants