CreateKey
Event Information
- The CreateKey event in AWS Key Management Service (KMS) refers to the action of creating a new customer master key (CMK) in KMS.
- When this event occurs, it indicates that a new CMK has been created and is ready to be used for encrypting and decrypting data in AWS services and applications.
- This event is important for auditing and compliance purposes, as it allows organizations to track the creation of new keys and monitor the usage of encryption in their AWS environment.
Examples
- If the IAM user or role used to create the key does not have the necessary permissions, it can lead to security issues. It is important to ensure that only authorized users or roles have the necessary permissions to create keys in AWS KMS.
- If the key policy associated with the created key is not properly configured, it can result in security vulnerabilities. The key policy should define the appropriate permissions for key usage and restrict access to only authorized entities.
- If the key material is not properly protected, it can compromise the security of the key. AWS KMS automatically manages the key material, but it is important to ensure that the key material is securely stored and protected from unauthorized access.
Remediation
Using Console
-
Identify the affected AWS KMS key:
- Log in to the AWS Management Console.
- Go to the AWS KMS service.
- Navigate to the “Customer managed keys” section.
- Look for the key mentioned in the previous response.
-
Update key policy to restrict access:
- Select the key and click on “Key policy” tab.
- Review the existing key policy and identify the necessary changes based on the examples provided.
- Click on “Edit” and modify the key policy accordingly.
- Ensure that only authorized IAM users or roles have the necessary permissions.
- Save the changes to update the key policy.
-
Monitor and review key usage:
- Enable AWS CloudTrail to capture API calls related to the KMS key.
- Set up CloudWatch alarms to notify any suspicious or unauthorized key usage.
- Regularly review the CloudTrail logs and CloudWatch alarms to identify any potential security issues.
- Take necessary actions to investigate and remediate any unauthorized access or suspicious activities.
Note: It is important to thoroughly understand the existing key policy and the specific requirements of your organization before making any changes. It is recommended to test the changes in a non-production environment before applying them to production keys.
Using CLI
To remediate the issues related to AWS KMS using AWS CLI, you can follow these steps:
-
Enable AWS KMS key rotation:
- Use the
enable-key-rotation
command to enable key rotation for a specific AWS KMS key. - Example:
aws kms enable-key-rotation --key-id <key-id>
- Use the
-
Enable AWS KMS key deletion protection:
- Use the
enable-key-deletion
command to enable deletion protection for a specific AWS KMS key. - Example:
aws kms enable-key-deletion --key-id <key-id>
- Use the
-
Enable AWS KMS key usage audit logging:
- Use the
enable-key-usage-logging
command to enable key usage audit logging for a specific AWS KMS key. - Example:
aws kms enable-key-usage-logging --key-id <key-id>
- Use the
Note: Replace <key-id>
with the actual ID of the AWS KMS key you want to remediate.
Using Python
To remediate the issues related to AWS KMS using Python, you can follow these steps:
- Enable AWS CloudTrail for KMS:
- Use the
boto3
library to create a new CloudTrail trail for KMS. - Set the appropriate parameters such as the S3 bucket to store the logs and the KMS key to encrypt the logs.
- Enable logging for KMS API events by specifying the appropriate event selectors.
- Use the
- Enable AWS Config for KMS:
- Use the
boto3
library to create a new AWS Config rule for KMS. - Specify the rule parameters such as the required KMS key tags and the desired compliance level.
- Use the
- Enable AWS Security Hub for KMS:
- Use the
boto3
library to enable AWS Security Hub for KMS. - Specify the appropriate product ARN for KMS.
- Use the
Please note that you need to have the necessary permissions and credentials set up to execute these scripts successfully.