

# Encryption at rest for AWS Assurance

**Important**  
AWS Assurance encrypts all of your data at rest by default, at no additional cost to you. You don’t need to take any action to turn on encryption at rest.

Encryption at rest protects your data from unauthorized access to the underlying storage. AWS Assurance encrypts the following content at rest: evidence, chat messages, assessment details, annotations, tasks, control descriptions, comments, and framework content.

## Options for encryption at rest
<a name="_options_for_encryption_at_rest"></a>

AWS Assurance provides these options for encryption at rest.

 ** AWS owned key (default)** – By default, AWS Assurance encrypts your data with an AWS owned key. AWS Assurance owns and manages this key. You can’t view, manage, or use the key, and you can’t audit its use. You don’t need to take any action or change any settings to protect your data with this key. There is no additional cost to use an AWS owned key.

 **Customer managed key** – You can also set up a customer managed key for an environment. A customer managed key is a AWS Key Management Service (AWS KMS) key that you create, own, and manage in your own AWS account. You have full control over this key. For example, you can define its key policy, turn on automatic key rotation, and audit its use. Use a customer managed key when you must control the keys that protect your data. You can also use it to audit key usage. AWS KMS charges apply for customer managed keys.

For more information about AWS KMS keys, see [Key Management Service concepts](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html) in the *AWS Key Management Service Developer Guide*.

## How AWS Assurance uses customer managed keys
<a name="_how_aws_assurance_uses_customer_managed_keys"></a>

When you set up a customer managed key, AWS Assurance protects your content with client-side envelope encryption. AWS Assurance encrypts your data with the AWS Encryption SDK and a AWS KMS hierarchical keyring before it writes the data to storage.

AWS Assurance creates one branch key for each environment. This branch key encrypts all of the content in the environment, including evidence, chat messages, assessment details, annotations, tasks, control descriptions, comments, and framework content. AWS Assurance stores the branch key, encrypted under your customer managed key, in storage that the service manages. To encrypt or decrypt your content, AWS Assurance first calls AWS KMS to unwrap the branch key, and then uses the branch key to protect your data.

AWS Assurance calls AWS KMS using the credentials of the caller. As a result, your key policy must grant the required permissions to the AWS Identity and Access Management (IAM) roles or users that call AWS Assurance. These callers include the environment’s own roles, which AWS Assurance uses on your behalf. For the list, see [Principals that need access to the key](#encryption-rest-principals). AWS Assurance doesn’t cache authorization to your key across requests, so changes to your key policy, including revoking access, take effect immediately.

AWS Assurance uses the following AWS KMS actions with your customer managed key.


| Action | When AWS Assurance calls it | 
| --- | --- | 
|  `kms:DescribeKey`  | Validates the key when you set it on an environment through `CreateEnvironment` or `UpdateEnvironment`. | 
|  `kms:GenerateDataKeyWithoutPlaintext`  | Provisions the branch key the first time AWS Assurance encrypts content in the environment. | 
|  `kms:ReEncryptFrom` and `kms:ReEncryptTo`  | Provisions the branch key. The AWS KMS hierarchical keyring calls `ReEncrypt`, which needs both permissions. | 
|  `kms:Encrypt`  | Wraps content. The AWS KMS hierarchical keyring issues this call. | 
|  `kms:Decrypt`  | Unwraps the branch key for every encrypt and decrypt operation. | 

**Note**  
AWS Assurance supports only symmetric encryption AWS KMS keys. You can’t use an asymmetric AWS KMS key or an HMAC key to encrypt your data. AWS Assurance rejects these key types.

## Configuring a customer managed key
<a name="_configuring_a_customer_managed_key"></a>

To use a customer managed key, first create a AWS KMS key that meets the requirements. Next, grant the required permissions in the key policy. Then set the key on an environment.

### Key requirements
<a name="_key_requirements"></a>

Your customer managed key must meet the following requirements:
+ The key must be a symmetric encryption AWS KMS key (`SYMMETRIC_DEFAULT`). AWS Assurance doesn’t support asymmetric keys or HMAC keys.
+ The key usage must be `ENCRYPT_DECRYPT`.
+ The key must be in the same AWS Region as the environment.
+ The key must be enabled.
+ You must specify the key by its key ARN. AWS Assurance doesn’t accept a key ID, an alias name, or an alias ARN.

For more information about symmetric encryption AWS KMS keys, see [Symmetric encryption KMS keys](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#symmetric-cmks) in the *AWS Key Management Service Developer Guide*.

### Required key policy permissions
<a name="_required_key_policy_permissions"></a>

Because AWS Assurance calls AWS KMS with the caller’s credentials, your key policy must grant the required permissions to the IAM principals that call AWS Assurance. The following example key policy grants the permissions that AWS Assurance needs.

**Note**  
The value `assurance.amazonaws.com` is a service namespace that identifies AWS Assurance in the `kms:ViaService` condition. It isn’t a principal, so don’t add it as a `Principal` in your key policy.

```json
{
  "Version": "2012-10-17",
  "Id": "assurance-key-policy",
  "Statement": [
    {
      "Sid": "AllowKeyAdministration",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::<account-id>:root"
      },
      "Action": "kms:*",
      "Resource": "*"
    },
    {
      "Sid": "AllowAssuranceKeyValidation",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::<account-id>:role/<caller-role>"
      },
      "Action": "kms:DescribeKey",
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "kms:ViaService": "assurance.<region>.amazonaws.com"
        }
      }
    },
    {
      "Sid": "AllowAssuranceContentCrypto",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::<account-id>:role/<caller-role>"
      },
      "Action": [
        "kms:GenerateDataKeyWithoutPlaintext",
        "kms:ReEncryptFrom",
        "kms:ReEncryptTo",
        "kms:Encrypt",
        "kms:Decrypt"
      ],
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "kms:ViaService": "assurance.<region>.amazonaws.com",
          "kms:EncryptionContext:aws:assurance:environmentArn": "arn:aws:assurance:<region>:<account-id>:environment/<environment-id>"
        }
      }
    }
  ]
}
```

This key policy contains the following statements:
+  `AllowKeyAdministration` grants the account root full administrative control of the key. This statement lets IAM administrators in your account manage the key policy.
+  `AllowAssuranceKeyValidation` lets the caller roles run `kms:DescribeKey` so that AWS Assurance can validate the key when you set it on an environment.
+  `AllowAssuranceContentCrypto` lets the caller roles run the crypto actions that AWS Assurance uses to encrypt and decrypt your content.

Replace `<account-id>`, `<region>`, `<caller-role>`, and `<environment-id>` with your own values. Add one principal entry for each IAM role that calls AWS Assurance.

### Principals that need access to the key
<a name="encryption-rest-principals"></a>

Add each of the following principals that applies to your environment to the key policy:
+  **Callers** – The IAM roles and users that call AWS Assurance from the AWS Management Console, the AWS CLI, or an SDK. A principal that sets the key on an environment also needs `kms:DescribeKey`.
+  **Identity Center role** – If you configured IAM Identity Center for the environment, the role that you specified as the Identity Center role. Requests from web application users run with this role’s credentials.
+  **Operator role** – If you configured an operator role for the environment, that role.
+  **Service-linked role** – When you set a customer managed key on an environment, AWS Assurance adds an inline policy named `AssuranceEvidenceKms-<environment-id>` to the `AWSServiceRoleForAssurance` service-linked role in your account. The policy lets the role use the key only through AWS Assurance and Amazon S3, and only for that environment. If the key is in the same account and its key policy has a statement that allows the account root principal `kms:*`, you don’t need to name the service-linked role in the key policy. If the key is in another account, name the role in the key policy. The other principals in this list still need access to the key.

  AWS Assurance adds and removes the inline policy with your credentials. To set the key, you must be able to use it, and you need `iam:PutRolePolicy` on the service-linked role. To clear the key, or to delete an environment that has a key, you need `iam:DeleteRolePolicy`. You can’t edit or delete the inline policy yourself. For an organization environment, only the management account can set or clear the key.

  If you add conditions to your key policy, allow the `kms:ViaService` values `assurance.<region>.amazonaws.com` and `s3.<region>.amazonaws.com`, and the encryption context key `aws:assurance:environmentArn`.

If a principal can’t use the key, its AWS Assurance requests that read or write encrypted content fail.

### Creating an environment with a customer managed key
<a name="_creating_an_environment_with_a_customer_managed_key"></a>

To encrypt a new environment with a customer managed key, specify the key ARN in the `kmsKeyArn` parameter when you call `CreateEnvironment`.

```bash
aws assurance create-environment \
    --environment-name my-environment \
    --kms-key-arn arn:aws:kms:<region>:<account-id>:key/<key-id>
```

AWS Assurance validates the key before it creates the environment. If the key doesn’t meet the requirements, or if the caller can’t use it, the request fails with a `ValidationException` (HTTP status code 400). For example, the request fails if the key policy doesn’t allow the caller `kms:DescribeKey`.

### Changing the encryption configuration for an existing environment
<a name="_changing_the_encryption_configuration_for_an_existing_environment"></a>

To change the encryption configuration for an existing environment, call `UpdateEnvironment`. To set or replace a customer managed key, specify the key ARN in the `kmsKeyArn` parameter.

```bash
aws assurance update-environment \
    --environment-arn arn:aws:assurance:<region>:<account-id>:environment/<environment-id> \
    --kms-key-arn arn:aws:kms:<region>:<account-id>:key/<key-id>
```

Replace `<region>`, `<account-id>`, `<environment-id>`, and `<key-id>` with your own values.

To stop using a customer managed key, pass an empty string for `kmsKeyArn`. After you clear the key, AWS Assurance encrypts new data with an AWS owned key.

```bash
aws assurance update-environment \
    --environment-arn arn:aws:assurance:<region>:<account-id>:environment/<environment-id> \
    --kms-key-arn ""
```

**Note**  
When you change or remove the AWS KMS key setting on an existing environment, only new data written after the change uses the new encryption configuration. There are no changes to the default encryption configuration for an existing environment that already has encryption configured. Previously encrypted data retains the encryption it was created with, so reading it still requires the earlier key. Keep the earlier key enabled, and keep its key policy grants, for as long as you need that data. Automatic rotation of the same customer managed key is transparent, because AWS KMS resolves the correct key version for you.

**Warning**  
If you disable or delete your customer managed key, AWS Assurance can’t decrypt the data that the key protects, and that data becomes permanently unreadable. This effect is known as crypto-shredding. Before you disable or delete a key, confirm that you no longer need the data that it protects. While a key is disabled, deleted, or has its permissions removed, AWS Assurance requests that need the key fail with an `AccessDeniedException` (HTTP status code 403).

### Scoping down access to your key
<a name="_scoping_down_access_to_your_key"></a>

We recommend that you scope down access to your customer managed key so that callers can use it only through AWS Assurance and only for your own environments. The example key policy uses the following conditions:
+  ** `kms:ViaService` ** – Limits use of the key to requests that come through AWS Assurance. The value is `assurance.<region>.amazonaws.com`. This condition prevents principals from using the key directly or through other services.
+  **Encryption context** – AWS Assurance includes an encryption context in its AWS KMS requests. The `kms:EncryptionContext:aws:assurance:environmentArn` condition limits the crypto permissions to a specific environment. AWS Assurance also verifies the encryption context on decrypt to prevent one environment’s ciphertext from being used with another environment.

AWS Assurance includes the following key in the encryption context:
+  `aws:assurance:environmentArn` – The ARN of the environment. This value also embeds the ID of the AWS account that owns the environment. To scope access by account, use the `kms:CallerAccount` or `aws:SourceAccount` condition key.

You can use the encryption context and the `kms:ViaService` condition together to protect against the confused deputy problem. For more information about encryption context, see [Encryption context](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#encrypt_context) in the *AWS Key Management Service Developer Guide*.

## Customer managed key on your IAM Identity Center instance
<a name="setting-up-identity-center-kms"></a>

You can encrypt your IAM Identity Center instance with a customer managed key in AWS Key Management Service (AWS KMS). This key is your IAM Identity Center instance key. AWS Assurance does not own or manage this key, and the requirements of IAM Identity Center govern its key policy. If the key policy does not meet those requirements, AWS Assurance can’t create or configure the IAM Identity Center application for your environment, and creating an environment with `CreateEnvironment`, or updating one with `UpdateEnvironment`, fails with a validation error.

At a minimum, the key policy must do the following:
+ Grant both the `sso.amazonaws.com` and `identitystore.amazonaws.com` service principals the `kms:DescribeKey`, `kms:Decrypt`, `kms:GenerateDataKeyWithoutPlaintext`, `kms:ReEncryptFrom`, and `kms:ReEncryptTo` actions, scoped with the `aws:SourceAccount` condition. Granting only `sso.amazonaws.com`, or only `kms:Decrypt`, is not sufficient and causes setup to fail.
+ Keep a key-administration statement that grants the account root user the `kms:*` actions. The KMS key policy is the root of trust for the key; without this statement, you can’t administer the key and you risk losing access to it.

AWS Assurance does not require any AWS Assurance-specific statement in this key policy. AWS Assurance is an AWS managed application that integrates with IAM Identity Center, so it is authorized through the IAM Identity Center key policy itself — do not add an `assurance.amazonaws.com` principal statement.

The following example shows a minimal key policy that satisfies these requirements. Replace `<account-id>` with the account ID of your IAM Identity Center instance.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowKeyAdministration",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::<account-id>:root"
      },
      "Action": "kms:*",
      "Resource": "*"
    },
    {
      "Sid": "AllowIdentityCenterToUseTheKey",
      "Effect": "Allow",
      "Principal": {
        "Service": ["sso.amazonaws.com", "identitystore.amazonaws.com"]
      },
      "Action": [
        "kms:DescribeKey",
        "kms:Decrypt",
        "kms:GenerateDataKeyWithoutPlaintext",
        "kms:ReEncryptFrom",
        "kms:ReEncryptTo"
      ],
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "aws:SourceAccount": "${aws:ResourceAccount}"
        }
      }
    }
  ]
}
```

For organization-wide access or more granular controls, such as restricting the key to a specific IAM Identity Center instance, use the IAM Identity Center key policy guidance as the source of truth. Do not expand this minimal policy for AWS managed application scenarios. For more information about IAM Identity Center key policies, see [Implementing customer managed KMS keys in AWS IAM Identity Center](https://docs.aws.amazon.com/singlesignon/latest/userguide/identity-center-customer-managed-keys.html) and [Baseline KMS key policy](https://docs.aws.amazon.com/singlesignon/latest/userguide/baseline-KMS-key-policy.html) in the *AWS IAM Identity Center User Guide*.

**Important**  
The customer managed key on your IAM Identity Center instance is different from the customer managed key for encrypting AWS Assurance evidence at rest. The IAM Identity Center key protects your IAM Identity Center instance, and its policy must meet the IAM Identity Center requirements described in this section. The evidence key protects the content that AWS Assurance stores, and its key policy grants permissions to the IAM roles that call AWS Assurance. Configure each key separately. The other sections of this topic describe the evidence key.

## Monitoring AWS Assurance interaction with AWS KMS
<a name="_monitoring_aws_assurance_interaction_with_aws_kms"></a>

You can use AWS CloudTrail (CloudTrail) to track the AWS KMS requests that AWS Assurance makes with your customer managed key. Because AWS Assurance calls AWS KMS with the caller’s credentials, the `userIdentity` in each event shows the identity of the caller, not an AWS Assurance service principal. During assessments, the events show the service-linked role `AWSServiceRoleForAssurance`.

 CloudTrail records the following AWS KMS event names for AWS Assurance activity:
+  `DescribeKey` 
+  `GenerateDataKeyWithoutPlaintext` 
+  `Encrypt` 
+  `Decrypt` 
+  `ReEncrypt` 

Each event includes an `encryptionContext` value in the `requestParameters` field. The encryption context contains the `aws:assurance:environmentArn` value, which identifies the environment (and embeds the owning account) for the request.

For more information about finding AWS KMS events in CloudTrail, see [Searching CloudTrail logs for KMS API calls](https://docs.aws.amazon.com/kms/latest/developerguide/logging-using-cloudtrail.html#searching-kms-ct) in the *AWS Key Management Service Developer Guide*.