Skip to main content

Triage and Remediation

Remediation

Using Console

Below are step‑by‑step console instructions to ensure you’re actually using AWS Secrets Manager (with KMS) rather than just KMS alone for secrets.

1. Choose or Create a KMS Key for Secrets Manager

  1. Sign in to AWS Management Console.
  2. Go to IAM > left menu Encryption keys (KMS)
    or directly open AWS Key Management Service (KMS).
  3. In the left pane, select Customer managed keys.
  4. Either:
    • Use an existing key: Note the Key ID or Alias you want Secrets Manager to use,
      or
    • Create a new KMS key:
      1. Click Create key.
      2. Key type: Symmetric and Encrypt and decrypt.
      3. Give it an Alias (e.g. alias/secrets-manager-key).
      4. Configure key administrators and key usage permissions.
      5. Finish. Note the alias or key ID.
This key will encrypt the secrets stored in Secrets Manager.

2. Create a Secret in AWS Secrets Manager

  1. In the console, go to AWS Secrets Manager.
  2. Click Store a new secret.
  3. Under Secret type, choose the appropriate option:
    • Other type of secret for arbitrary key/value pairs, or
    • A specific type like Credentials for RDS database, etc.
  4. In Key/value pairs, add your secret values (for example username, password, apiKey, etc.).
  5. Under Encryption key, choose:
    • aws/secretsmanager (AWS-managed)
      or
    • Your customer-managed KMS key (e.g. alias/secrets-manager-key).
  6. Click Next.
  7. Enter a Secret name (e.g. prod/db/credentials).
  8. (Optional) Add a Description and Tags.
  9. Click Next to pass rotation for now, or configure it (see step 3).
  10. Review and click Store.
Your secret is now stored and encrypted with KMS, satisfying “Secrets Manager in use.”
  1. In Secrets Manager, click the secret you just created.
  2. Go to the Rotation tab.
  3. Click Edit rotation.
  4. Check Enable automatic rotation.
  5. Choose Create a new Lambda function or Use an existing Lambda function to rotate the secret.
  6. Set the Rotation interval (e.g. every 30 days).
  7. Save changes.

4. Update Applications to Use Secrets Manager Instead of KMS/Plaintext

Your misconfiguration is typically that apps are:
  • Hardcoding secrets, or
  • Storing them encrypted with KMS directly (e.g. via Encrypt/Decrypt API) but not using Secrets Manager.
Update each application to fetch secrets from Secrets Manager:

A. Grant the Application IAM Permissions

Assign an IAM role or user policy like:
If using a customer-managed KMS key, ensure the role is also allowed to use it in the KMS key policy.

B. Update Code to Call Secrets Manager

Example patterns:
  • AWS SDK (pseudo-code):
Do this instead of:
  • Reading a plaintext config file, or
  • Calling KMS Decrypt directly on some encrypted blob.
Test the app, deploy changes, and confirm it runs using Secrets Manager.

5. Decommission Old Secret Storage

Once all consumers have been migrated to Secrets Manager:
  1. Remove old secrets from:
    • Plaintext config files / environment variables.
    • SSM Parameter Store (if previously used for secrets in plaintext).
    • Custom KMS-encrypted blobs in S3, etc.
  2. If you had separate KMS keys only used for that old pattern:
    • Confirm they are no longer needed.
    • Schedule key deletion in KMS (optional, and only after verifying everything works).

6. Verify Remediation

  1. In Secrets Manager, verify:
    • All required secrets exist.
    • They are encrypted with a KMS key.
    • Rotation is configured (if applicable).
  2. In CloudTrail, you should see GetSecretValue calls from your application role.
  3. Confirm your security tool / compliance rule for “Secrets Manager should be in use” is now passing.
If you share the exact rule (e.g., from Security Hub, Config, or a CSPM tool), I can tailor the minimum required steps specifically for that control.
Below are CLI-focused steps to get secrets into AWS Secrets Manager and away from direct KMS usage.Assumptions:
  • You currently have some secret (password/API key/etc.) stored outside Secrets Manager (maybe in plaintext, SSM Parameter, environment variables, or encrypted manually with KMS).
  • You want to store it in AWS Secrets Manager and encrypt it with a KMS key.

1. Choose or create a KMS key for Secrets Manager

If you already have a suitable customer managed key (CMK), note its key-id/ARN and skip creation.Create a new KMS key:
Capture the KeyId or Arn from the output, e.g.:
Optionally give it an alias:

2. Create the secret in Secrets Manager

If you already have the secret value available in plaintext locally (e.g. in a shell variable):
If the value is in a file:
secret.json could be:

3. (Optional) Enable automatic rotation for the secret

You need a Lambda function that knows how to rotate this secret. Assume you already created a rotation Lambda with ARN in $ROTATION_LAMBDA_ARN.Enable rotation every 30 days:

4. Update application to read from Secrets Manager (CLI test)

Confirm you can read the secret:
Use the returned value in your application (via SDK / environment init script, etc.), instead of directly from KMS or plaintext.

5. Remove old KMS-based / plaintext storage

Once your app is confirmed to be using Secrets Manager:
  • If you were storing the secret in an SSM parameter:
  • If you stored ciphertext via KMS directly (e.g., in a file / config store), delete or overwrite that configuration securely.
  • If you had environment variables or config files containing the secret, remove/rotate them.

6. Lock down IAM so secrets must live in Secrets Manager

Example: grant your app role permission to read the secret, not to use KMS directly for secret decryption.Inline policy example (modify as needed):
And optionally restrict general KMS access so applications are not expected to manage sensitive secrets using bare KMS calls.
If you tell me how your secret is currently stored (SSM, env var, KMS-encrypted file, etc.), I can give exact CLI commands tailored to that case.
To remediate “Secrets Manager should be in use” for secrets currently stored/managed via KMS, you essentially need to:
  1. Store the secret in AWS Secrets Manager (encrypted with KMS).
  2. Update applications to read from Secrets Manager instead of wherever they’re getting the secret now.
  3. Optionally delete/retire the old KMS-based secret storage.
Below are the steps and example Python (boto3) snippets.

1. Prerequisites

  • Python 3.x
  • boto3 installed:
  • AWS credentials configured (via environment variables, shared credentials file, or IAM role).
  • A KMS key you want Secrets Manager to use (can be the AWS-managed default or a customer-managed key).

2. Create a Secret in AWS Secrets Manager (using KMS)

Assume you currently have a secret value (e.g., password or API key) that might be stored in a config file, environment variable, or some other non–Secrets Manager location.
Remediation impact:
  • Secret is now stored in Secrets Manager, encrypted with KMS.
  • Access is controlled via IAM policies and Secrets Manager resource policies.

3. Retrieve the Secret from Secrets Manager in Your App

Replace existing logic (e.g., reading from env vars, files, or direct KMS Decrypt) with Secrets Manager retrieval.

4. (Optional) Enable Automatic Secret Rotation

If the secret is a database password or similar, use a Lambda rotation function. The basic API call:
You must:
  • Implement the Lambda function to actually change the secret in the target system (DB, API, etc.).
  • Attach a role to the Lambda allowing it to read/write the secret and update the backend credential.

5. Decommission the Old KMS-Based Storage (If Applicable)

If your prior pattern was something like:
  • Encrypting secrets manually with KMS and storing ciphertext in files/parameters, or
  • Storing plaintext secrets in config with occasional KMS use,
then after updating all consumers to use Secrets Manager:
  1. Verify no application still reads the old data.
  2. Remove or redact old secrets (e.g., from SSM Parameter Store, config files, S3, etc.).
  3. Optionally schedule deletion of the KMS key if it was dedicated purely for that legacy pattern and is no longer needed:

6. IAM Permissions (High-level)

Ensure the application role or user has at least:
  • To read the secret:
    • secretsmanager:GetSecretValue
  • To create/manage the secret (for your provisioning code):
    • secretsmanager:CreateSecret
    • secretsmanager:PutSecretValue
    • secretsmanager:UpdateSecret
    • secretsmanager:RotateSecret (if using rotation)
And appropriate KMS permissions for the key in KmsKeyId:
  • kms:Encrypt
  • kms:Decrypt
  • kms:GenerateDataKey
  • kms:DescribeKey

If you share what your current KMS usage pattern is (e.g., using kms:Decrypt on ciphertext from a file, SSM parameter, etc.), I can give a more exact “before/after” Python example for that specific migration.
This change does not force replacement of the KMS key; it creates a new Secrets Manager secret encrypted with that key (creating the KMS key itself is also non-disruptive unless you switch existing resources to use it).Verification: terraform plan should show 3 to add (aws_kms_key.APP_KMS_KEY, aws_secretsmanager_secret.APP_SECRET, aws_secretsmanager_secret_version.APP_SECRET_VALUE) and no changes to existing resources unless you wire this secret into them.