Skip to content

Vault no longer respects AWS_ROLE_ARN or AWS_WEB_IDENTITY_TOKEN_FILE for AWS KMS #21478

@dqsully

Description

@dqsully

Describe the bug
AWS KMS seals no longer respect the AWS_ROLE_ARN or AWS_WEB_IDENTITY_TOKEN_FILE environment variables, which are required for assuming IAM roles via Kubernetes ServiceAccount tokens. Instead, Vault attempts to use the EC2 instance's IAM role (if available) to access the KMS key instead of using the Kubernetes ServiceAccount.

To Reproduce
Steps to reproduce the behavior:

  1. Create an AWS EKS cluster
  2. Connect the EKS cluster as an OIDC provider for AWS IAM
  3. Create an AWS KMS key
  4. Create an AWS IAM role with an assume-role policy authorizing that OIDC provider, and an inline policy authorizing that IAM role for actions on the KMS key you created
  5. Deploy Vault with an "awskms" seal, setting only kms_key_id, and adding a ServiceAccount annotation eks.amazonaws.com/role-arn: <IAM role ARN>

Expected behavior
Vault should assume the IAM role configured in the Kubernetes ServiceAccount annotation and referenced by AWS_ROLE_ARN (injected by EKS because of the annotation), using the Kubernetes ServiceAccount token file referenced by AWS_WEB_IDENTITY_TOKEN_FILE (also injected by EKS) for authentication with AWS.

Environment:

  • Vault Server Version: 1.14.0
  • Server Operating System/Architecture: running on EKS 1.24, deployed using Vault's official Helm chart v0.25.0

Vault server configuration file(s):

ui = true
listener "tcp" {
  tls_disable = 1
  address = "[::]:8200"
  cluster_address = "[::]:8201"
  x_forwarded_for_authorized_addrs = ["####", "####"]
  x_forwarded_for_reject_not_present = false
}
storage "consul" {
  path = "vault"
  address = "HOST_IP:8500"
}

service_registration "kubernetes" {}

seal "awskms" {
  region     = "us-east-1"
  kms_key_id = "######"
}

Additional context
There is an easy workaround for this bug, which is to set role_arn and web_identity_token_file in the seal settings like so:

seal "awskms" {
  region     = "us-east-1"
  kms_key_id = "######"

  # Fixes for Vault 1.14+
  role_arn = "arn:aws:iam::<account ID>:role/<role name>"
  web_identity_token_file = "/var/run/secrets/eks.amazonaws.com/serviceaccount/token"
}

Also, as far as I could trace it, the issue seems to come from this list of approved(?) environment variables for the AWS KMS wrapper?: 254d8f8#diff-8669cb5f3518deb7d1841c405e7e8b222348751cf85f81e6077a1184e9ed767dR15-R23

Hopefully the fix is as easy as adding AWS_WEB_IDENTITY_TOKEN_FILE and AWS_ROLE_ARN to that list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions