OWASP Hunting

Injection

Log Injection

Log injection inserts malicious content into application log files to forge log entries, hide attacks, or exploit log viewers.

Payloads are read from main at 35c1f2b (committed 22 Nov 2026). Project version 1.0.2.

These payloads are for authorized testing only: systems you own, authorized bug bounty programs, or controlled lab environments. Unauthorized testing is illegal.

Payload files

Folder on GitHub

Use the arrow keys to move between payloads. Press Enter or C to copy the focused payload.

log-injection-payloads.txt

130 payloads · 6.2 KB
Source

Loading payloads for Log Injection…

What it is#

Log Injection occurs when an application writes unsanitized user input to log files. An attacker can inject newlines to forge additional log entries, obfuscate attack evidence, or exploit log management tools that process log data (e.g., triggering XSS in a web-based log viewer). In severe cases, log injection can be chained with log4shell-style vulnerabilities to achieve RCE.

Attack vectors#

  • Any input field that is logged (usernames, search queries, error inputs)
  • HTTP headers logged by access log systems
  • User-Agent and Referer headers in web server logs
  • Application error messages containing user input

Testing methodology#

  1. Submit \n or %0a followed by a fake log entry to test newline injection
  2. Check if CR (\r) or LF (\n) characters are reflected in logs
  3. Test for JNDI injection strings if the target uses Log4j
  4. Inject HTML/JS in log entries and check web-based log viewers

Indicators of vulnerability#

  • Log file contains injected newlines and fabricated entries
  • JNDI lookup request received on attacker-controlled server
  • Log viewer renders injected HTML or JavaScript

Detection guidance#

Sanitize all user-supplied values before writing to logs by stripping or encoding control characters. Ensure log management tools treat log data as untrusted input.

Mitigation and remediation#

  • Encode or strip newline characters (\n, \r) from all logged input
  • Use a structured logging format (JSON) instead of free-form text
  • Update Log4j to a patched version (2.17+) to prevent Log4Shell
  • Set log4j2.formatMsgNoLookups=true as a mitigation
  • Treat log viewer output as untrusted and apply output encoding

References#

Responsible Use

All content in this reference is for authorized security testing only. Use only on systems you own or have explicit written permission to test.

  • Systems and applications you own
  • Authorized penetration testing engagements
  • Bug bounty programs with defined scope
  • Educational lab environments (DVWA, WebGoat, HackTheBox)