5.4.1 Prefer using secrets as files over secrets as environment variables

Information

Kubernetes supports mounting secrets as data volumes or as environment variables. Minimize the use of environment variable secrets.

Rationale:

It is reasonably common for application code to log out its environment (particularly in the event of an error). This will include any secret values passed in as environment variables, so secrets can easily be exposed to any user or entity who has access to the logs.

Solution

If possible, rewrite application code to read secrets from mounted secret files, rather than from environment variables.

Impact:

Application code which expects to read secrets in the form of environment variables would need modification

Default Value:

By default, secrets are not defined

References:

https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets

Notes:

Mounting secrets as volumes has the additional benefit that secret values can be updated without restarting the pod

See Also

https://workbench.cisecurity.org/files/2662

Item Details

Category: CONFIGURATION MANAGEMENT

References: 800-53|CM-6, CSCv7|14.4, CSCv7|14.8

Plugin: Unix

Control ID: d5bedd255664750431ea8535f93c8bee49cd81aca5f0c2c443a56725dd802294