Join our Newsletter — 33% off our NHI Course
Home› Glossary› Threats, Abuse & Incident Response› MySQL General Log Poisoning
Threats, Abuse & Incident Response

MySQL General Log Poisoning

← Back to Glossary
By NHI Mgmt Group Updated November 16, 2026 Domain: Threats, Abuse & Incident Response

MySQL General Log Poisoning is an attack that abuses the MySQL general query log to place attacker-controlled content where it can later be executed or interpreted. It typically depends on write access to the log location and a separate path that treats the log as code or a web file.

What the attack is doing under the hood

MySQL general log poisoning turns a benign operational log into an execution or inclusion primitive. The attacker is not “hacking the log” in isolation, they are abusing a path where database output is written in a form that another component later treats as code, markup, or a file to be served.

This makes the attack especially dependent on environment design. A logging location that is writable, web-accessible, or otherwise reinterpreted by another service can turn ordinary query text into a payload delivery channel. The danger is the coupling between logging and downstream execution, not the log itself.

Why the technique is dangerous

The general query log can capture raw client activity, so any attacker who can influence what gets written there may be able to plant controlled content without needing direct filesystem upload rights. If that log is then reachable by a web server, parser, include path, or scheduled task, the attacker may convert write access into code execution or command execution.

The risk is amplified when log files sit inside shared directories, inherit permissive permissions, or are rotated into locations that are more broadly exposed than the database administrators expect. In practice, the security boundary is often broken by file placement and service misconfiguration rather than by a flaw in MySQL itself.

How organisations assess exposure

Exposure review starts with locating where the general log is stored, who can write to it, and whether any application, reverse proxy, or maintenance job can read or execute from that path. Teams should verify whether the log directory sits under a web root, symlinked path, backup location, or shared volume that another service consumes.

It is also important to review database and host configuration together, because a “safe” database setting can still become dangerous if the underlying directory permissions, container mount, or web server routing makes the file reachable. In a database breach context, a playbook such as Database Breach Response Playbook is useful for scoping what was accessed and preserving logs that may show how the poisoning occurred.

Remediation and defensive handling

The preferred fix is to remove the exposure chain, not just the malicious content. That means moving logs out of executable or web-served locations, tightening filesystem permissions, restricting who can enable or write the general log, and ensuring that rotated or archived copies are not exposed through a different path.

If the environment cannot be changed immediately, compensating controls should focus on containment: deny access from the web tier to log locations, disable any include or execution path that can reach the file, and treat the affected log directory as untrusted input until it is rebuilt. Because the threat is often post-write reinterpretation, cleanup must include every path that might still resolve the poisoned file.

Detection and recovery checks

Detection usually depends on correlating database logs, web logs, and filesystem activity. Look for unexpected log writes that contain PHP, shell fragments, template syntax, or other markup that would be harmless in a query log but dangerous if interpreted elsewhere. Unexpected requests to a log file path can also indicate that an attacker is testing whether the poison was exposed.

After remediation, review whether the log was ever served, parsed, or executed and whether any follow-on compromise occurred. If the poisoned content was reachable, assume the incident may have affected sessions, credentials, or adjacent data paths, and validate the integrity of any systems that consumed the file.

Risk and Threat Considerations

MySQL general log poisoning is dangerous because it combines an ordinary administrative feature with a second trust failure: a file that was meant for troubleshooting becomes attacker-controlled input to another component. That can turn a logging weakness into code execution, web shell placement, or indirect data exposure.

Failure mechanism: The attacker first gets controlled content written into the general log, then relies on a separate misconfiguration, such as a web-served directory or inclusion path, to reinterpret that content as executable or active content.

Impact: Successful exploitation can lead to remote code execution, disclosure of sensitive database activity, tampering with audit trails, and broader host compromise if the poisoned path is executed with service privileges.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK addresses the attack surface, CIS Controls v8 and NIST SP 800-53 Rev 5 set the technical controls, and ISO/IEC 27001:2022 defines the regulatory obligations.

FrameworkControl / ReferenceRelevance
CIS Controls v8CIS-4 — Secure Configuration of Enterprise Assets and SoftwareLog placement and permissions are a secure configuration issue that creates or removes the attack path.
Recommendation — Harden log storage paths and permissions so log files cannot be served or executed.
NIST SP 800-53 Rev 5SI-10 — Information Input ValidationThe attack depends on attacker-controlled content being written and later misused as active input.
AU-9 — Protection of Audit InformationThe general log is audit material whose integrity and protection matter to this attack path.
Recommendation — Validate and constrain what can be written to and consumed from log-driven paths. Protect audit logs from unauthorized access, modification, and unintended execution.
ISO/IEC 27001:2022A.8.9 — Configuration managementThe attack emerges from unsafe configuration of log locations and downstream handling.
Recommendation — Review database and web configurations together to keep logs outside executable paths.
MITRE ATT&CKT1190 — Exploit Public-Facing ApplicationThe technique often becomes actionable when a web-exposed path interprets the poisoned file.
Recommendation — Hunt for exposed file paths that turn logged content into an execution path.

Practitioner Guidance

What to watch for: Treat the general log as sensitive operational data, not as a harmless text file. The key operational question is whether any non-database process can reach or interpret that file, because that is what converts a logging issue into an exploitable attack path.

Governance implication: Assign explicit ownership for database log placement, rotation, access control, and exposure review. Logging settings, filesystem permissions, and web-server mappings should be reviewed together, because no single team usually sees the whole attack path on its own.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 16, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org