AWS inspector medium security documentation change
Summary
Updated encryption documentation for Lambda code scanning - replaced CodeGuru references with Amazon Q, simplified KMS policy requirements, removed grant-based encryption workflow, and added detailed key policy examples
Security assessment
The changes enforce stricter encryption controls by replacing temporary grants with permanent key policy requirements. This addresses potential security risks from grant lifecycle management and ensures encryption context validation through 'kms:EncryptionContext' conditions. The explicit IAM role ARN requirements and source account/ARN restrictions reduce privilege escalation risks.
Diff
diff --git a/inspector/latest/user/encryption-rest.md b/inspector/latest/user/encryption-rest.md index e650f2223..a86f5ec10 100644 --- a//inspector/latest/user/encryption-rest.md +++ b//inspector/latest/user/encryption-rest.md @@ -24,4 +23,0 @@ If you disable Amazon Inspector, it permanently deletes all resources it stores -###### Note - -The content in the following sections is subject to change soon. You can expect aspects of the encryption workflow and permissions for encrypting a customer managed KMS key to be updated. - @@ -30 +26 @@ The content in the following sections is subject to change soon. You can expect -For Amazon Inspector Lambda code scanning, Amazon Inspector partners with CodeGuru to scan your code for vulnerabilities. When a vulnerability is detected CodeGuru extracts a snippet of your code containing the vulnerability and stores that code until Amazon Inspector requests access. By default CodeGuru uses an AWS owned key to encrypt the extracted code, however, you can configure Amazon Inspector to use your own customer managed AWS KMS key for encryption. +For Amazon Inspector Lambda code scanning, Amazon Inspector partners with Amazon Q to scan your code for vulnerabilities. When a vulnerability is detected, Amazon Q extracts a snippet of your code containing the vulnerability and stores that code until Amazon Inspector requests access. By default, Amazon Q uses an AWS owned key to encrypt the extracted code. However, you can configure Amazon Inspector to use your own customer-managed AWS KMS key for encryption. @@ -34 +30 @@ The following work flow explains how Amazon Inspector uses the key you configure - 1. You supply a AWS KMS key to Amazon Inspector using the Amazon Inspector [UpdateEncryptionKey](https://docs.aws.amazon.com/inspector/v2/APIReference/API_UpdateEncryptionKey.html) API. + 1. You supply an AWS KMS key to Amazon Inspector using the Amazon Inspector [UpdateEncryptionKey](https://docs.aws.amazon.com/inspector/v2/APIReference/API_UpdateEncryptionKey.html) API. @@ -36 +32 @@ The following work flow explains how Amazon Inspector uses the key you configure - 2. Amazon Inspector forwards the information about your AWS KMS key to CodeGuru. CodeGuru stores the information for future use. + 2. Amazon Inspector forwards the information about your AWS KMS key to Amazon Q, and Amazon Q stores the information for future use. @@ -38 +34 @@ The following work flow explains how Amazon Inspector uses the key you configure - 3. CodeGuru requests a [grant](https://docs.aws.amazon.com/kms/latest/developerguide/grants.html) from AWS KMS for the key you configured in Amazon Inspector. + 3. Amazon Q uses the KMS key you configured in Amazon Inspector through the key policy. @@ -40 +36 @@ The following work flow explains how Amazon Inspector uses the key you configure - 4. CodeGuru creates an encrypted data key from your AWS KMS key and stores it. This data key is used to encrypt your code data stored by CodeGuru. + 4. Amazon Q creates an encrypted data key from your AWS KMS key and stores it. This data key is used to encrypt your code data stored by Amazon Q. @@ -42 +38 @@ The following work flow explains how Amazon Inspector uses the key you configure - 5. Whenever Amazon Inspector requests data from code scans CodeGuru uses the grant to decrypt the encrypted data key, then uses that key to decrypt the data so it can be retrieved. + 5. When Amazon Inspector requests data from code scans, Amazon Q uses the KMS key to decrypt the data key. When you disable Lambda Code Scanning, Amazon Q deletes the associated data key. @@ -47,2 +42,0 @@ The following work flow explains how Amazon Inspector uses the key you configure -When you disable Lambda code scanning CodeGuru retires the grant and deletes the associated data key. - @@ -51,7 +45 @@ When you disable Lambda code scanning CodeGuru retires the grant and deletes the -To use encryption you need to have a policy that allows access to AWS KMS actions, as well as a statement that grants Amazon Inspector and CodeGuru permissions to use those actions through condition keys. - -If you are setting, updating, or resetting the encryption key for your account you will need to use an Amazon Inspector administrator policy, such as [AWS managed policy: AmazonInspector2FullAccess](./security-iam-awsmanpol.html#security-iam-awsmanpol-AmazonInspector2FullAccess). You will also need to grant the following permissions to read-only users who need to retrieve code snippets from findings or data about the key chosen for encryption. - -For KMS, the policy must allow you to perform the following actions: - - * `kms:CreateGrant` +For encryption, you must create a KMS key with [a policy](https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-overview.html) that includes a statement allowing Amazon Inspector and Amazon Q to perform the following actions. @@ -63,2 +50,0 @@ For KMS, the policy must allow you to perform the following actions: - * `kms:GenerateDataKeyWithoutPlainText` - @@ -67 +53,3 @@ For KMS, the policy must allow you to perform the following actions: - * `kms:RetireGrant` + * `kms:GenerateDataKey` + + * `kms:GenerateDataKeyWithoutPlainText` @@ -72 +60,3 @@ For KMS, the policy must allow you to perform the following actions: -Once you've verified that you have the correct AWS KMS permissions in your policy, you must attach a statement that allows Amazon Inspector and CodeGuru to use your key for encryption. Attach the following policy statement: +###### Policy statement + +You can use the following policy statement when creating the KMS key. @@ -76 +66 @@ Once you've verified that you have the correct AWS KMS permissions in your polic -Replace Region with the AWS Region you have Amazon Inspector Lambda code scanning enabled in. +Replace ``account-id`` with your 12-digit AWS account ID. Replace ``Region`` with the AWS Region where you enabled Amazon Inspector and Lambda code scanning. Replace ``role-ARN`` with the Amazon Resource Name for your IAM role. @@ -80 +69,0 @@ Replace Region with the AWS Region you have Amazon Inspector Lambda code scannin - "Sid": "allow CodeGuru Security to request a grant for a AWS KMS key", @@ -82 +71,9 @@ Replace Region with the AWS Region you have Amazon Inspector Lambda code scannin - "Action": "kms:CreateGrant", + "Principal": { + "Service": "q.amazonaws.com" + }, + "Action": [ + "kms:Encrypt", + "kms:Decrypt", + "kms:GenerateDataKeyWithoutPlaintext", + "kms:GenerateDataKey" + ], @@ -85,9 +82,15 @@ Replace Region with the AWS Region you have Amazon Inspector Lambda code scannin - "ForAllValues:StringEquals": { - "kms:GrantOperations": [ - "GenerateDataKey", - "GenerateDataKeyWithoutPlaintext", - "Encrypt", - "Decrypt", - "RetireGrant", - "DescribeKey" - ] + "StringLike": { + "kms:EncryptionContext:aws:qdeveloper:lambda-codescan-scope": "account-id" + }, + "StringEquals": { + "aws:SourceAccount": "account-id" + }, + "ArnLike": { + "aws:SourceArn": "arn:aws:qdeveloper:Region:account-id:scans/*" + } + } + }, + { + "Effect": "Allow", + "Principal": { + "Service": "q.amazonaws.com" @@ -94,0 +98,3 @@ Replace Region with the AWS Region you have Amazon Inspector Lambda code scannin + "Action": "kms:DescribeKey", + "Resource": "*", + "Condition": { @@ -96,3 +102,4 @@ Replace Region with the AWS Region you have Amazon Inspector Lambda code scannin - "kms:ViaService": [ - "codeguru-security.Region.amazonaws.com" - ] + "aws:SourceAccount": "account-id" + }, + "ArnLike": { + "aws:SourceArn": "arn:aws:qdeveloper:Region:account-id:scans/*" @@ -103 +109,0 @@ Replace Region with the AWS Region you have Amazon Inspector Lambda code scannin - "Sid": "allow Amazon Inspector and CodeGuru Security to use your AWS KMS key", @@ -108,3 +114,2 @@ Replace Region with the AWS Region you have Amazon Inspector Lambda code scannin - "kms:RetireGrant", - "kms:DescribeKey", - "kms:GenerateDataKeyWithoutPlaintext" + "kms:GenerateDataKeyWithoutPlaintext", + "kms:GenerateDataKey" @@ -111,0 +117,3 @@ Replace Region with the AWS Region you have Amazon Inspector Lambda code scannin + "Principal": { + "AWS": "role-ARN" + }, @@ -115,4 +123,19 @@ Replace Region with the AWS Region you have Amazon Inspector Lambda code scannin - "kms:ViaService": [ - "inspector2.Region.amazonaws.com", - "codeguru-security.Region.amazonaws.com" - ] + "kms:ViaService": "inspector2.Region.amazonaws.com" + }, + "StringLike": { + "kms:EncryptionContext:aws:qdeveloper:lambda-codescan-scope": "account-id" + } + } + }, + { + "Effect": "Allow", + "Action": [ + "kms:DescribeKey" + ], + "Principal": { + "AWS": "role-ARN" + }, + "Resource": "*", + "Condition": { + "StringEquals": { + "kms:ViaService": "inspector2.Region.amazonaws.com" @@ -122,0 +146 @@ Replace Region with the AWS Region you have Amazon Inspector Lambda code scannin +The policy statement is formatted in JSON. After you include the statement, review the policy to make sure the syntax is valid. If the statement is the last statement in the policy, place a comma after the closing brace for the previous statement. If the statement is the first statement or between two existing statements in the policy, place a comma after the closing brace for the statement. @@ -126 +150,3 @@ Replace Region with the AWS Region you have Amazon Inspector Lambda code scannin -When you add the statement, ensure that the syntax is valid. Policies use JSON format. This means that you need to add a comma before or after the statement, depending on where you add the statement to the policy. If you add the statement as the last statement, add a comma after the closing brace for the preceding statement. If you add it as the first statement or between two existing statements, add a comma after the closing brace for the statement. +Amazon Inspector no longer supports [grants](https://docs.aws.amazon.com/kms/latest/developerguide/grants.html) to encrypt code snippets extracted from packages. If you are using a grant-based policy, you can still access your findings. However, if you ever update or reset your KMS key or disable Lambda Code Scanning, you will need to use the KMS key policy described in this section. + +If you set, update, or reset the encryption key for your account, you must use an Amazon Inspector administrator policy, such as the AWS managed policy `AmazonInspector2FullAccess`. @@ -146 +172 @@ If you attempt to use `GetEncryptionKey` when you haven't set a customer managed -If you delete or the key or change it's policy to deny access to Amazon Inspector or CodeGuru you will be unable to access your code vulnerability findings and Lambda code scanning will fail for your account. +If you delete the key or change it's policy to deny access to Amazon Inspector or Amazon Q you will be unable to access your code vulnerability findings and Lambda code scanning will fail for your account.