Skip to main content

Event Information

Meaning

  • The “Read environment variable from proc files” event in a Kubernetes cluster indicates that a process running within a container is attempting to read environment variables from the /proc filesystem.
  • This event could potentially indicate a security concern, as reading environment variables from /proc can expose sensitive information such as passwords or API keys.
  • To investigate this event, you can use the kubectl command to check the logs of the container where the event occurred. For example, you can use “kubectl logs <pod_name> -c <container_name>” to view the logs and look for any suspicious activity related to reading environment variables from /proc.

Remediation

  1. Isolate Environment Variables Using ConfigMaps:
    • Instead of allowing environment variables to be read from /proc, it is more secure to manage and inject environment variables using ConfigMaps or Secrets in Kubernetes.
    • Create ConfigMap
  2. Use Secrets for Sensitive Data:
    • If the environment variable contains sensitive information (like API keys or passwords), use a Secret instead of a ConfigMap:
    • Apply the Secret: kubectl apply -f secret.yaml
  3. Mount the ConfigMap or Secret to the Pod:
    • Modify the deployment manifest to reference the ConfigMap or Secret for injecting environment variables securely:
  4. Restrict Access to the /proc Filesystem:
    • Prevent processes from unnecessarily accessing the /proc filesystem by limiting the permissions of the container.
    • Ensure that the container is not running in privileged mode, which could allow it to access sensitive areas of the host system, including /proc. Modify the container’s security context to explicitly disable privileged access: