Accepting Including user input in log files can result in log forging. For example, a user could be able to break might split a legitimate log entry into two log entries by entering a carriage return and line feed (CRLF) sequence. The second entry could be intentionally misleading; for example, it may warn the administrator that a reboot is required to install critical security updates. Consequently, either of which might be misleading. To prevent such attacks, user input must be sanitized before being used or logged.
...
Code Block | ||
---|---|---|
| ||
logger.severe("Invalid username:" + getUserName()); |
This is noncompliant because ????
Compliant Solution
This compliant solution sanitizes the user name input before logging it. Refer to rule IDS00-J. Sanitize untrusted data passed across a trust boundary for more details on input sanitization.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="857505976f5056fb-33e9e93a-4e4544fc-a820914f-c56f2e51302f6c6283827ba4"><ac:plain-text-body><![CDATA[ | [[MITRE 2009 | AA. Bibliography#MITRE 09]] | [CWE ID 144 | http://cwe.mitre.org/data/definitions/144.html] "Improper Neutralization of Line Delimiters" | ]]></ac:plain-text-body></ac:structured-macro> |
| CWE ID 150 "Improper Neutralization of Escape, Meta, or Control Sequences" |
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="72025988a9e8bc5d-3015e8cb-494146a2-97638b32-4f924c784c7b83a75122367b"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] | ]]></ac:plain-text-body></ac:structured-macro> |
...