Environment variables are sensitive to injection attacks, just like any other input.
Note also that environment variables can be exposed in multiple ways, storing sensitive information in them should be done carefully:
* on Unix systems environment variables of one process can be read by another process running with the same UID.
* environment variables https://docs.oracle.com/javase/tutorial/essential/environment/env.html[might be forwarded to child processes].
* application running in debug mode often exposes their environment variable.
This rule raises an issue when environment variables are read.
== Ask Yourself Whether
* Environment variables are used without being sanitized.
* You store sensitive information in environment variables and other processes might be able to access them.
You are at risk if you answered yes to any of those questions.
== Recommended Secure Coding Practices
Sanitize every environment variable before using its value.
If you store sensitive information in an environment variable, make sure that no other process can access them, i.e. the process runs with a separate user account and child processes don't have access to their parent's environment.
Don't run your application in debug mode if it has access to sensitive information, including environment variables.
* CWE - https://cwe.mitre.org/data/definitions/526[CWE-526 - Information Exposure Through Environmental Variables]
* CWE - https://cwe.mitre.org/data/definitions/74[CWE-74 - Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')]