Both environment variables and system properties provide user-defined mappings between keys and their corresponding values and can be used to communicate those values from the environment to a process. According to the Java API \[ [API 2006|AA. References#API 06]\] {{ Wiki Markup java.lang.System
}} class documentation:
Environment variables have a more global effect because they are visible to all descendants of the process which defines them, not just the immediate Java subprocess. They can have subtly different semantics, such as case insensitivity, on different operating systems. For these reasons, environment variables are more likely to have unintended side effects. It is best to use system properties where possible. Environment variables should be used when a global effect is desired, or when an external system interface requires an environment variable (such as
PATH
).
...
The default values of system properties are set by the Java Virtual Machine (JVM) upon startup and can be considered trusted. However, they may be overridden by properties from untrusted sources, such as a configuration file. System properties from untrusted sources must be sanitized and validated before use.
_The Java Tutorial_ \[ [Campione 1996|AA. References#Campione 96]\] states: Wiki Markup
To maximize portability, never refer to an environment variable when the same value is available in a system property. For example, if the operating system provides a user name, it will always be available in the system property
user.name
.
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
ENV02-J | low | likely | low | P9 | L2 |
Bibliography
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="5ea0d93a-e5da-4eef-add2-75ce0393ba1e"><ac:plain-text-body><![CDATA[ | [ [API 2006AA. References#API 06] ] |
| ]]></ac:plain-text-body></ac:structured-macro> | <ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="1e1f8478-ecb9-48ad-b609-7bfb80caa2e9"><ac:plain-text-body><![CDATA[ |
[ [Campione 1996AA. References#Campione 96] ] | ]]></ac:plain-text-body></ac:structured-macro> |
...