1 Log Forging
Log injection (log forging) occurs when unsanitized user input containing newline characters is written to log files. Attackers can inject fake log entries to cover their tracks or frame innocent users.
Vulnerable example (Python):
username = request.form["username"]
logging.info(f"Login attempt: {username}")An attacker sends username: admin\n[INFO] Login attempt: root - SUCCESS
The log file shows two entries:
[INFO] Login attempt: admin
[INFO] Login attempt: root - SUCCESSThe forged entry makes it appear root logged in successfully, obscuring what actually happened. Attackers use this to remove evidence of intrusion attempts from log analysis tools.