More Info:

Ensure ECS task definition log configuration is enabledThis rule checks if secrets are passed as container environment variables in Amazon ECS task definitions. It marks the rule as non-compliant if one or more environment variable keys match a key listed in the ‘secretKeys’ parameter .

Risk Level

Low

Address

Security, Reliability

Compliance Standards

CBP,SEBI

Triage and Remediation

Remediation

To remediate secrets being exposed in container environment variables in AWS Kubernetes using the AWS console, follow these steps:

  1. Identify the exposed secrets: First, identify which secrets are being exposed in the container environment variables. You can do this by examining the Kubernetes deployment configuration or inspecting the running pods.

  2. Store secrets securely: AWS provides a service called AWS Secrets Manager that allows you to store, retrieve, and manage sensitive data such as passwords, API keys, and other secrets. Store the secrets in AWS Secrets Manager instead of hardcoding them in the container environment variables.

  3. Update Kubernetes deployment configuration:

    • Open the AWS Management Console and navigate to the Amazon EKS console.
    • Select your EKS cluster and navigate to the “Workloads” section.
    • Find the deployment that contains the exposed secrets and click on it to view the details.
    • Update the deployment configuration to fetch the secrets from AWS Secrets Manager instead of using them directly as environment variables.
  4. Use AWS IAM roles for service accounts: Instead of directly accessing AWS Secrets Manager from your application code, you can use IAM roles for service accounts (IRSA) to securely provide AWS permissions to your Kubernetes pods. This way, your pods can access AWS services securely without needing to store AWS credentials or secrets in the container environment variables.

  5. Monitor and audit: Regularly monitor and audit your Kubernetes clusters for any exposed secrets or misconfigurations. Set up alerts and notifications to detect any unauthorized access or changes to your secrets.

By following these steps, you can remediate secrets being exposed in container environment variables in AWS Kubernetes and ensure that your sensitive data is stored and accessed securely.