Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the “Secrets Manager Should Be In Use” misconfiguration in AWS using the AWS console, follow these steps:
  1. Log in to the AWS Management Console.
  2. Navigate to the AWS Secrets Manager service.
  3. Click on the “Create secret” button.
  4. Select the type of secret you want to create (such as “Other type of secrets”).
  5. Enter the details for the secret, such as the secret name and the secret value.
  6. Click on the “Next” button.
  7. Configure the rotation settings for the secret, if applicable.
  8. Click on the “Next” button.
  9. Review the details of the secret.
  10. Click on the “Store” button to create the secret.
Once you have created the secret in AWS Secrets Manager, you can use it in your applications and services to securely store and retrieve sensitive information. Make sure to update your applications and services to use the new secret, and delete any other instances of the sensitive information that may have been stored elsewhere.

To remediate the issue of not using Secrets Manager in AWS, you can follow the below steps using AWS CLI:
  1. First, create a new Secrets Manager secret for the sensitive data that needs to be stored securely.
  2. Then, update the application code to retrieve the sensitive data from Secrets Manager instead of being hardcoded in the code.
  3. Next, remove any sensitive data that is currently stored in environment variables or configuration files.
  4. Finally, update the IAM policies to grant the necessary permissions to access the Secrets Manager secret.
To create a new Secrets Manager secret using AWS CLI, follow these steps:
  1. Open the AWS CLI and run the following command to create a new secret:
  1. Replace my-secret with the name of the secret you want to create, and my-secret-value with the value of the secret. You can also use the --secret-file option to specify a file containing the secret value.
  2. Once the secret is created, you can update the application code to retrieve the secret value from Secrets Manager.
  3. To remove any sensitive data that is currently stored in environment variables or configuration files, review the code and remove any references to the sensitive data.
  4. Finally, update the IAM policies to grant the necessary permissions to access the Secrets Manager secret. You can use the aws secretsmanager get-secret-value command to retrieve the secret value, so the IAM policy should include the secretsmanager:GetSecretValue action for the relevant resource.
To remediate the misconfiguration “Secrets Manager Should Be In Use” for AWS using Python, you can follow these steps:
  1. First, ensure that you have the necessary AWS SDK for Python (Boto3) installed on your system.
  2. Next, you can use the Boto3 SDK to create a Secrets Manager resource in your AWS account. You can do this by creating a new Secrets Manager client object and using the create_secret method to create a new secret.
Here’s some sample Python code that demonstrates how to create a new secret using Boto3:
In this example, we’re creating a new secret named “my-secret” with a username and password stored as a JSON string in the SecretString field.
  1. Once you’ve created your new secret, you can update your application or infrastructure to use the Secrets Manager client to retrieve the secret values at runtime. This will ensure that your secrets are securely stored and managed by AWS.
Here’s some sample Python code that demonstrates how to retrieve a secret using Boto3:
In this example, we’re retrieving the value of the “my-secret” secret and printing it to the console.By following these steps, you can remediate the misconfiguration “Secrets Manager Should Be In Use” for AWS using Python and ensure that your secrets are securely managed by AWS.
This finding cannot be remediated directly on aws-managementandgovernance-resourcemanager-organization-account; it is satisfied by having at least one Secrets Manager secret in the account, such as the one above encrypted with a KMS CMK.terraform plan should show the creation of one aws_kms_key, one aws_secretsmanager_secret, and one aws_secretsmanager_secret_version, with no replacements of existing resources.