Avoid Log forging vulnerabilities ( CWE-117 ) | CAST Appmarq

Avoid Log forging vulnerabilities ( CWE-117 )

CRITICAL

Rule Definition
Writing unvalidated, unsanitized user input to log files can allow an attacker to forge log entries or inject malicious content into the logs. Applications typically use log files to store a history of events or transactions for later review, statistics gathering, or debugging. Depending on the nature of the application, the task of reviewing log files may be performed manually or sometimes automated with a tool that automatically gathers log data for important events or trending information. Interpretation of the log files may be hindered or misdirected if an attacker can supply data to the application that is subsequently logged verbatim.

Remediation
Code the appropriate input validation as close as possible to the user input call.

Violation Code Sample
String val = request.getParameter("value");
try {
    int value = Integer.parseInt(value);
}
catch (NumberFormatException) {
    log.info("Failed to parse value = " + value);
}
Fixed Code Sample
String val = request.getParameter("value");
try {
    int value = Integer.parseInt(value);
}
catch (NumberFormatException) {
    String sanitizedValue = ... // Sanitize here the value
    log.info("Failed to parse value = " + sanitizedValue);
}

Reference
http://cwe.mitre.org/data/definitions/117.html

Related Technologies
.Net JEE

Health Factor

  Security


Technical Criterion
CWE-117 - Improper Output Neutralization for Logs

About CAST Appmarq

CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.

Benchmark Statistics

Global Compliance

98.76%

Total Violations
1,333
Total Opportunities
107,114
Average Violations / App.
7.28
The compliance score represents 1 minus the ratio between the number of times a rule has been violated compared to the number of opportunities in a set of applications that the rule could have been violated.

Industry Insights

Select from drop-down

99.41%

Financial Services

98.41%

Software ISV

99.85%