Description
The product constructs a log message from external input, but it does not neutralize or incorrectly neutralizes special elements when the message is written to a log file.
Potential Impact
Integrity, Confidentiality, Availability, Non-Repudiation
Modify Application Data, Hide Activities, Execute Unauthorized Code or Commands
Demonstrative Examples
String val = request.getParameter("val");try {
int value = Integer.parseInt(val);
}catch (NumberFormatException) {log.info("Failed to parse val = " + val);}...Mitigations & Prevention
Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across relat
Use and specify an output encoding that can be handled by the downstream component that is reading the output. Common encodings include ISO-8859-1, UTF-7, and UTF-8. When an encoding is not specified, a downstream component may choose a different encoding, either by assuming a default encoding or automatically inferring which encoding is being used, which can be erroneous. When the encodings are inconsistent, the downstream component might treat some character or byte sequences as special, even
Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.
Detection Methods
- Automated Static Analysis High — Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then sea
Real-World CVE Examples
| CVE ID | Description |
|---|---|
| CVE-2006-4624 | Chain: inject fake log entries with fake timestamps using CRLF injection |
Related Weaknesses
Taxonomy Mappings
- 7 Pernicious Kingdoms: — Log Forging
- Software Fault Patterns: SFP23 — Exposed Data
- The CERT Oracle Secure Coding Standard for Java (2011): IDS03-J — Do not log unsanitized user input
- SEI CERT Oracle Coding Standard for Java: IDS03-J — Do not log unsanitized user input
Frequently Asked Questions
What is CWE-117?
CWE-117 (Improper Output Neutralization for Logs) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product constructs a log message from external input, but it does not neutralize or incorrectly neutralizes special elements when the message is written to a log file.
How can CWE-117 be exploited?
Attackers can exploit CWE-117 (Improper Output Neutralization for Logs) to modify application data, hide activities, execute unauthorized code or commands. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-117?
Key mitigations include: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not stric
What is the severity of CWE-117?
CWE-117 is classified as a Base-level weakness (Medium abstraction). It has been observed in 1 real-world CVEs.