WAF log poisoning is an attack where someone sends crafted input that a WAF, web server or application writes into its logs. That stored text can later forge records, mislead analysts or run as code when the log is read, viewed or loaded by another system.
How WAF Log Poisoning Works
Logs record attacker-controlled input by design: headers, paths and parameters may be written to disk. A log poisoning attack abuses how another component later reads or processes that text. Depending on the vulnerability, it can lead to code execution, forged records or attacks against people viewing logs.
Code execution through file inclusion.
An attacker places code such as
<?php ... ?>in a field like User-Agent or Referer, and the server writes it to a log. If the application has a Local File Inclusion (LFI) flaw, the attacker may be able to make it include the log file, causing PHP to execute the embedded code. This chain requires an injectable logged field, an LFI flaw and access to the log file. Real servers add friction: Apache’s logging documentation describes how certain special characters are escaped in logged request lines and headers. On default Debian-based installations, access logs are also typically restricted to privileged users and the adm group, so the web user may not be able to read or include them unless permissions have been changed. Log injection attacks: forgery and misdirection.
CWE-117 covers log messages built from external input without properly neutralizing special elements. A carriage return and line feed (CRLF) in a request can introduce fake log lines, including fabricated timestamps. Attackers may use these entries to cover their tracks, skew statistics, implicate another party or confuse log-processing tools. In CVE-2024-1681, a CRLF sequence in a request path allowed attackers to inject fake entries into Flask-CORS debug logs. This type of WAF log injection or application log injection can undermine the reliability of security records. In a security information and event management (SIEM) system, SIEM log poisoning can raise false alerts or bury real ones.
Cross-site scripting in log viewers.
A script payload stored in a log may run when an administrator opens a vulnerable log viewer. In CVE-2026-45560, the Roxy-WI log viewer rendered log lines as HTML, allowing a payload written to an HAProxy or Nginx access log to execute in the administrator’s session. WAF consoles, SIEM dashboards and other log viewers can face similar risks if they do not safely encode output.
A related but distinct case involves a logging library interpreting logged text. In Log4Shell (CVE-2021-44228), certain logged strings could trigger lookups in vulnerable versions of Log4j. This was a vulnerability in the logging library, rather than simply an attack on a log file or viewer.
WAF Logging Risks
WAF logs concentrate much of the hostile input an organization receives, and blocked requests may also be recorded in them. Logs can contain sensitive information, too. Cloudflare notes that headers and payloads can contain cookies and credentials, which it treats as sensitive data. Its logging approach can limit payload collection and encrypt selected data using a customer-provided key.
A WAF that blocks PHP code or script tags in headers may stop some attempts before they reach origin logs, but this does not eliminate every risk. Encoded or unusual payloads may still be logged, and the WAF’s own logs or downstream monitoring tools may handle them differently. These WAF logging risks make safe log storage, parsing and display important even when the WAF blocks the original request.
How to Prevent WAF Log Poisoning
Fix LFI vulnerabilities.
Never build file inclusion paths from untrusted user input. Apply authorization checks and ensure that applications cannot include log files.
Neutralize input when logging.
Safely handle CR, LF and other control characters before writing data to logs. Prefer structured logging and use appropriate escaping to prevent a log injection attack.
Encode output when displaying logs.
Escape HTML in log viewers, restrict who can access them, and use a suitable content security policy (CSP) for administrative consoles.
Limit file access.
Store logs outside the web root where practical, apply least-privilege file permissions, and avoid granting the web application unnecessary access to log files.
Treat logs as untrusted in the SIEM.
Ship logs off-host where appropriate, parse structured fields safely, and correlate events across sources. Review WAF SIEM integration and WAF event correlation for related practices.
Detecting suspicious input.
Alert on unexpected line breaks within logged fields, suspicious script or PHP strings, and unusual patterns in headers and query strings. Treat these indicators as investigation signals rather than proof of an attack. See WAF logging and how a WAF blocks XSS attacks.
Protecting the Logging Pipeline Prevents Log Poisoning Risks
WAF log poisoning highlights a critical risk in security monitoring: data collected to investigate attacks can itself become a vehicle for deception or exploitation. Even when a WAF blocks malicious requests, attacker-controlled input may still reach logs or other monitoring systems. Preventing security log manipulation requires safely handling input before it is logged, encoding data when it is displayed, restricting access to log files and monitoring for suspicious entries. By securing the entire logging pipeline, organizations can preserve the integrity of their security records and reduce the risk of logs becoming another attack path.
Frequently Asked Questions (FAQ)
1. What is the difference between log poisoning and log injection?
The terms overlap. Log injection usually refers to the weakness of writing untrusted input to logs without properly neutralizing special characters, as described in CWE-117. Log poisoning often refers to an attack that exploits this weakness, such as inserting crafted content into a log file that is later included or processed unsafely.
2. Can a WAF stop log poisoning?
Partly. A WAF can block requests carrying suspicious script tags or PHP code before they reach backend logs, depending on its rules and configuration. However, it cannot fix an LFI flaw or an unsafe log viewer. Application and logging controls are still needed.
3. Does log poisoning still work on modern servers?
Some techniques are harder under secure default configurations because servers may escape certain special characters and restrict log-file permissions. However, log poisoning can still succeed when an application has an LFI flaw, permissions are overly broad, or a log viewer renders untrusted content unsafely.
4. How can you tell if logs have been poisoned?
Look for suspicious strings in User-Agent, Referer and path fields; unexpected line breaks; implausible timestamps; duplicated or malformed records; and unusual administrator activity after someone viewed a log. Investigate these signs in context, because individual indicators do not necessarily confirm log poisoning.
Block threats before they reach your app
See how a modern WAF detects and stops SQL injection, XSS, and zero-day attacks in real time.