CWE-117 · Słabość
Improper Output Neutralization for Logs
- Abstrakcja
- Bazowa
- Status
- Szkic
- Ryzyko wykorzystania
- średnie
- Dodano
- 19 lipca 2006
- Ostatnia zmiana
- 11 grudnia 2025
Opis
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.
Inne nazwy
- Log forging
- An attack-oriented term that could be used in cases in which the adversary can add additional log entries or modify how a log entry is parsed.
Skutki
Integrity, Confidentiality, Availability, Non-Repudiation
Modify Application Data; Hide Activities; Execute Unauthorized Code or Commands
Interpretation of the log files may be hindered or misdirected if an attacker can supply data to the application that is subsequently logged verbatim. In the most benign case, an attacker may be able to insert false entries into the log file by providing the application with input that includes appropriate characters. Forged or otherwise corrupted log files can be used to cover an attacker's tracks, possibly by skewing statistics, or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility.
Zapobieganie
Implementation · Input Validation
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 related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue."
Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
Implementation · Output Encoding
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 if they are not special in the original encoding. Attackers might then be able to exploit this discrepancy and conduct injection attacks; they even might be able to bypass protection mechanisms that assume the original encoding is also being used by the downstream component.
Implementation · Input Validation
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.
Przykłady podatności
- CVE-2006-4624 Chain: inject fake log entries with fake timestamps using CRLF injection
Słabość nadrzędna
Kiedy powstaje
- Implementation — REALIZATION: This weakness is caused during implementation of an architectural security tactic.
Dotyczy
Not Language-Specific
Źródła
- Seven Pernicious Kingdoms: A Taxonomy of Software Security Errors — Katrina Tsipenyuk, Brian Chess, Gary McGraw, NIST, 2005
- Exploiting Software: How to Break Code — Greg Hoglund, Gary McGraw, Addison-Wesley, 2004
- The night the log was forged — Alec Muffet
- OWASP TOP 10 — OWASP, 2007
Wpis z katalogu CWE 4.20.