• Log injection attacks may occur if a log contains malicious user inputs due to improper validation mechanism or improper sanitization
  • Attackers can split a log entry into two log entries using carriage return and line feed (CRLF) sequences or insert a fake log entry
  • Also, logging malicious inputs that are not sanitized can result in information leakage

Vulnerable Code

  • In the code, username is logged for invalid user request without proper validation

Secure Code

In the code, validation is performed before logging username