View a markdown version of this page

Security in Credential Broker - AWS Identity and Access Management

Security in Credential Broker

Note

This is prerelease documentation for a service in preview release. It is subject to change.

This section provides security information specific to Credential Broker. It complements the information in Security in IAM and AWS STS, which covers security topics applicable to IAM as a whole.

Data encryption falls into two categories: encryption at rest and encryption in transit.

Encryption at rest

Credential Broker encrypts all customer data at rest, even if you don't configure any encryption settings.

Credential Broker stores two kinds of data:

How Credential Broker encrypts data at rest

Data

Where Credential Broker stores it

How it is encrypted

Tokens it obtains (access tokens and, for flows that act for a user, refresh tokens)

Credential Broker

With an AWS owned key by default, or with a customer managed key that you configure on the credential provider pool or on a credential provider

Client secrets and API keys that you give a credential provider

AWS Secrets Manager, in a secret that Credential Broker creates (named credentialbroker!credentialProviderId) or a secret that you own. See How Credential Broker stores your secrets.

With the AWS KMS key that the secret uses

You can choose one of the following key types for tokens:

AWS owned key

Credential Broker encrypts tokens with an AWS owned AWS KMS key. AWS owned keys are not visible in your account. You can't view, manage, or audit them in AWS KMS. This is the default.

Customer managed key

Credential Broker encrypts tokens with a AWS KMS key that you create and own. You manage the key policy, rotation, and scheduled deletion.

Things to know about encryption with customer managed keys

Keep the following in mind when you use a customer managed key with Credential Broker:

  • You can set a customer managed key on a credential provider pool. Every credential provider in the pool uses that key, unless a provider sets its own customer managed key.

  • The encryption context contains two keys: aws:credentialbroker:credentialproviderpool-arn, set to the credential provider pool ARN, and aws:credentialbroker:credentialprovider-arn, set to the credential provider ARN. Both keys are present on every operation, including for a provider that uses the pool's key. A key policy can condition on either key.

  • In a key policy condition, add the aws-crypto-ec: prefix to these keys, for example kms:EncryptionContext:aws-crypto-ec:aws:credentialbroker:credentialproviderpool-arn. The prefix is required because Credential Broker encrypts through the AWS Database Encryption SDK. A condition without the prefix never matches.

  • A pool key and a provider key must be two different AWS KMS keys. Each key's CreateGrant condition is scoped to a different encryption context key, so one key can't serve both.

  • Credential Broker validates that the key is symmetric, has ENCRYPT_DECRYPT key usage, is enabled, is a customer managed key, and is in the same Region as the credential provider pool.

  • You can switch from the AWS owned key to a customer managed key, from one customer managed key to another, or from a customer managed key back to the AWS owned key. Tokens keep serving during the switch.

  • Credential Broker accepts the full AWS KMS key ARN or alias.

  • If you disable the key, schedule it for deletion, or remove Credential Broker's access to it, Credential Broker can't decrypt cached tokens. Workloads then can't retrieve tokens from the affected providers, and users must consent again in flows that act for a user.

  • The principal that creates or updates the pool or provider needs the AWS KMS permissions listed in Control access to AWS IAM Credential Broker.

Configure a customer managed key

You can configure a customer managed key on a credential provider pool, or on an individual credential provider that overrides the pool key.

Console
To set a customer managed key on a credential provider pool
  1. Open the IAM console, and then choose Credential Broker in the navigation pane.

  2. On the Pool settings tab, choose Edit.

  3. Under Encryption, choose Customize encryption.

  4. Choose Choose a different AWS KMS key.

  5. Do one of the following:

    • Choose an AWS KMS key from the list.

    • Enter a key ARN.

    • Choose Create an AWS KMS key. This opens the AWS KMS console. After you create the key, return and choose it.

  6. Choose Save changes.

To set a customer managed key on a credential provider
  1. On the Credential providers tab, choose the provider.

  2. Choose Edit.

  3. Expand Additional settings, and then under Encryption choose Customize encryption.

  4. Choose Choose a different AWS KMS key.

  5. Do one of the following:

    • Choose an AWS KMS key from the list.

    • Enter a key ARN.

    • Choose Create an AWS KMS key. This opens the AWS KMS console. After you create the key, return and choose it.

  6. Choose Save changes.

AWS CLI

To set a customer managed key on a credential provider pool, run the following command.

aws credential-broker update-credential-provider-pool \ --pool-id pool-1234567890abcdef \ --kms-key-arn arn:aws:kms:us-east-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab

Key policy

Credential Broker calls AWS KMS as the IAM identity that calls Credential Broker, by using a forward access session, not as a Credential Broker service principal. Your key policy must therefore allow that IAM role. A key policy that allows only credentialbroker.amazonaws.com grants nothing. The role's identity-based policy must also allow the same AWS KMS actions.

Credential Broker needs the following permissions on your key.

AWS KMS permissions that Credential Broker needs
Action Used for

kms:Decrypt

Decrypting the key that protects a provider's credentials, on every credential retrieval

kms:Encrypt, kms:GenerateDataKeyWithoutPlaintext

Creating that key when you create a credential provider

kms:ReEncryptFrom, kms:ReEncryptTo

Re-encrypting when you change the key

kms:CreateGrant

The grant that Credential Broker uses for key rotation

kms:DescribeKey

Validating the key before Credential Broker creates or updates your resource

If you leave out kms:ReEncryptFrom, kms:ReEncryptTo, or kms:CreateGrant, the key works at first. Requests fail later, when you change the key or create the next credential provider.

The following example key policy is for a key that you set on a credential provider pool. Replace the role ARN with the role that calls Credential Broker, the Region in kms:ViaService, and the pool ARN.

{ "Version": "2012-10-17", "Id": "credentialbroker-cmk-pool", "Statement": [ { "Sid": "AllowCredentialBrokerCrypto", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:role/MyWorkloadRole" }, "Action": [ "kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKeyWithoutPlaintext", "kms:ReEncryptFrom", "kms:ReEncryptTo" ], "Resource": "*", "Condition": { "StringEquals": { "kms:ViaService": "credentialbroker.us-east-1.amazonaws.com", "kms:EncryptionContext:aws-crypto-ec:aws:credentialbroker:credentialproviderpool-arn": "arn:aws:credentialbroker:us-east-1:111122223333:credentialproviderpool/c6a26997945e4a0b" } } }, { "Sid": "AllowCredentialBrokerCreateGrant", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:role/MyWorkloadRole" }, "Action": "kms:CreateGrant", "Resource": "*", "Condition": { "StringEquals": { "kms:ViaService": "credentialbroker.us-east-1.amazonaws.com", "kms:EncryptionContext:aws-crypto-ec:aws:credentialbroker:credentialproviderpool-arn": "arn:aws:credentialbroker:us-east-1:111122223333:credentialproviderpool/c6a26997945e4a0b" }, "ForAllValues:StringEquals": { "kms:GrantOperations": [ "GenerateDataKeyWithoutPlaintext", "ReEncryptFrom", "ReEncryptTo" ] } } }, { "Sid": "AllowCredentialBrokerDescribeKey", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:role/MyWorkloadRole" }, "Action": "kms:DescribeKey", "Resource": "*", "Condition": { "StringEquals": { "kms:ViaService": "credentialbroker.us-east-1.amazonaws.com" } } }, { "Sid": "Block FAS requests without kms:ViaService", "Effect": "Deny", "Principal": "*", "Action": "kms:*", "Resource": "*", "Condition": { "Null": { "kms:ViaService": "true" }, "Bool": { "aws:ViaAWSService": "true" } } }, { "Sid": "Block crypto without pool arn EC", "Effect": "Deny", "Principal": "*", "Action": [ "kms:Encrypt", "kms:Decrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*" ], "Resource": "*", "Condition": { "Null": { "kms:EncryptionContext:aws-crypto-ec:aws:credentialbroker:credentialproviderpool-arn": "true" } } }, { "Sid": "Block crypto without provider arn EC", "Effect": "Deny", "Principal": "*", "Action": [ "kms:Encrypt", "kms:Decrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*" ], "Resource": "*", "Condition": { "Null": { "kms:EncryptionContext:aws-crypto-ec:aws:credentialbroker:credentialprovider-arn": "true" } } }, { "Sid": "Block CreateGrant without pool arn EC constraint", "Effect": "Deny", "Principal": "*", "Action": "kms:CreateGrant", "Resource": "*", "Condition": { "Null": { "kms:EncryptionContext:aws-crypto-ec:aws:credentialbroker:credentialproviderpool-arn": "true" } } }, { "Sid": "Block cross-account access without same account SourceAccount", "Effect": "Deny", "Principal": "*", "Action": "kms:*", "Resource": "*", "Condition": { "StringNotEquals": { "aws:PrincipalAccount": "${aws:ResourceAccount}", "aws:SourceAccount": "${aws:ResourceAccount}" }, "ArnNotLike": { "aws:SourceArn": "arn:*:*:*:${aws:ResourceAccount}:*" } } }, { "Sid": "Block cross-account access to CMK when not from an external SP", "Effect": "Deny", "Principal": "*", "Action": "kms:*", "Resource": "*", "Condition": { "StringNotEquals": { "aws:PrincipalAccount": "${aws:ResourceAccount}" }, "Bool": { "aws:PrincipalIsAWSService": "false" } } } ] }

The policy must also allow at least one principal to administer the key, for example with kms:PutKeyPolicy. AWS KMS doesn't let you save a key policy that leaves no principal able to administer the key, and the statements in this example don't grant any administrative actions.

For a key that you set as a provider-level override, use a separate key with the same policy, with one change: in the AllowCredentialBrokerCreateGrant statement and the Block CreateGrant without pool arn EC constraint statement, use kms:EncryptionContext:aws-crypto-ec:aws:credentialbroker:credentialprovider-arn and the credential provider ARN instead of the pool ARN.

How Credential Broker stores your secrets

Each credential provider uses a long-term secret, either an OAuth client secret or an API key. Credential Broker keeps that secret in AWS Secrets Manager in your own AWS account. For OAuth credential providers, Credential Broker doesn't return the secret; your agent receives only the short-lived access token that the client secret is used to obtain.

You choose who owns the secret. The choice works the same way for OAuth credential providers and API key credential providers.

Credential Broker creates the secret (managed secret)

You supply the secret value (clientSecret or apiKey). Credential Broker creates the secret in your account and manages its lifecycle. The secret is named credentialbroker!credentialProviderId. If an OAuth credential provider uses a separate requester client for token exchange, Credential Broker creates a second secret with the suffix /oboRequester. When you delete the credential provider, Credential Broker deletes its secrets. If the deletion fails, the credential provider stays in the DELETING state so that you can retry.

Because every managed secret starts with credentialbroker!, you can scope a policy to all of them with the resource arn:aws:secretsmanager:region:account-id:secret:credentialbroker!*.

You bring your own secret

You create the secret and supply a reference to it (clientSecretReference or apiKeySecretReference): the secret ID and the JSON key that holds the value. When you create the credential provider, Credential Broker checks that it can read the secret with your credentials, then stores only the secret ARN and the JSON key. It doesn't copy the value and doesn't delete the secret when you delete the credential provider. You control the secret's encryption, rotation, and tags. When you rotate the secret, the credential provider uses the new value without any change to the credential provider.

Specify either the secret value or a reference, not both. If you specify both or neither, the request fails with a ValidationException and the reason FIELD_COMBINATION_INVALID. You can't reference a secret that Credential Broker already manages; that request fails with the reason INVALID_SECRET_REFERENCE.

Permissions for secrets

Credential Broker calls Secrets Manager on your behalf by using a forward access session. Secrets Manager therefore authorizes the IAM identity that called Credential Broker, not Credential Broker itself. Two identities need permissions:

  • Your agent needs secretsmanager:GetSecretValue and secretsmanager:DescribeSecret on the secret. Credential Broker reads the secret as your agent whenever it can't serve a request from its cache. Without this permission, creating the credential provider succeeds but the first token or API key request that needs the secret fails.

  • The administrator who creates, updates, or deletes credential providers needs secretsmanager:CreateSecret, secretsmanager:PutSecretValue, and secretsmanager:DeleteSecret on managed secrets, in addition to GetSecretValue and DescribeSecret. If you bring your own secret, the administrator needs only the read permissions.

Grant these permissions only when the request comes through Credential Broker, by adding the aws:CalledVia condition key. A plain GetSecretValue grant would let your agent read the long-term client secret or API key directly with its own SDK call, which bypasses Credential Broker. With the condition, a direct call from your agent's code is denied.

aws:CalledVia is a global condition key that lists the AWS services that made a request on behalf of an IAM principal. The principal is still your role, but the condition matches only when credentialbroker.amazonaws.com made the call. This matters because the grant doesn't add a new principal; it limits your role's access to the path through Credential Broker. Because the key can have several values, use ForAnyValue:StringEquals.

The following policy statement lets your agent read a secret that you own, only through Credential Broker.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "ReadTheSecretOnlyThroughCredentialBroker", "Effect": "Allow", "Action": [ "secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret" ], "Resource": "arn:aws:secretsmanager:us-east-1:111122223333:secret:my-oauth-client-AbCdEf", "Condition": { "ForAnyValue:StringEquals": { "aws:CalledVia": ["credentialbroker.amazonaws.com"] } } } ] }

The following policy statement lets an administrator manage the secrets that Credential Broker creates, only through Credential Broker.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "ManageServiceLinkedSecretsOnlyThroughCredentialBroker", "Effect": "Allow", "Action": [ "secretsmanager:CreateSecret", "secretsmanager:PutSecretValue", "secretsmanager:DeleteSecret", "secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret" ], "Resource": "arn:aws:secretsmanager:us-east-1:111122223333:secret:credentialbroker!*", "Condition": { "ForAnyValue:StringEquals": { "aws:CalledVia": ["credentialbroker.amazonaws.com"] } } } ] }

If your agent's role needs Secrets Manager access for other reasons, use a separate role to call Credential Broker, so that no unconditioned path to the secret exists on that role.

If you encrypt a secret that you own with a customer managed AWS KMS key, the calling identity also needs kms:Decrypt on that key. Add the same aws:CalledVia condition to that statement so that your agent can't decrypt the secret outside Credential Broker.

A public OAuth client, which has no client secret, doesn't read a secret and doesn't need these permissions.

Encryption in transit

Credential Broker accepts only TLS connections. It uses TLS when it calls the external authorization servers and identity providers that issue tokens, and when it returns tokens to your workload.