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

MySQL General Log RCE

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

MySQL General Log RCE is remote code execution achieved by abusing MySQL's general query log. An attacker with sufficient database privileges can write crafted output to a file path that the server later interprets as executable content, turning logging into code execution. The issue depends on write access, file placement and the server's runtime permissions.

How MySQL General Log RCE Works

MySQL General Log RCE is not a logging bug in isolation, it is a misuse of a legitimate administrative feature. The general query log can be directed to a file, and when an attacker can influence that file placement or the logged content under permissive server conditions, the log output becomes a path to arbitrary code execution rather than simple audit data.

The danger comes from combining database write capability with filesystem reach. A database principal that can change log settings, write to a web-accessible or otherwise executable location, or exploit permissive runtime permissions may be able to turn ordinary statements into a payload that the server later interprets as executable content.

Why This Vulnerability Class Is Dangerous

This pattern matters because it crosses two control planes at once: database privilege and host-level file handling. A weakness that looks like audit logging can become remote code execution when the database process has too much authority over the filesystem, especially in environments where database and web runtime paths overlap or where logging destinations are not tightly constrained.

It is particularly dangerous in shared or poorly segmented deployments, where a compromise in the database layer can pivot into application or operating-system level impact. The practical lesson is that logging features must be treated as security-sensitive write paths, not as harmless observability plumbing.

How Organisations Check Exposure

Exposure review starts with an inventory of database instances, their privilege models, and the exact file paths used by logging. Teams should verify whether the general log is enabled, whether log destination settings can be changed by non-administrative principals, and whether any log files land in directories that the server can later execute or serve.

Vendor guidance should be used to confirm the product-specific behaviour, because the exact execution path depends on server version, platform permissions, and local configuration. Internal review should also look for internet-exposed database services, since remote reachability sharply increases the value of any privilege escalation path that begins inside the database.

Remediation, Detection, and Recovery

The safest remediation is to remove the conditions that make log-to-execution possible: restrict who can alter logging settings, keep database write paths separate from executable or web-served locations, and harden filesystem permissions so the database process cannot place files where code execution is possible. Where immediate patching or reconfiguration is not feasible, compensating controls should reduce who can reach the database and what that account can change.

Detection should focus on unusual changes to logging configuration, unexpected writes to log files, and post-exploitation indicators such as new files in database or web directories. After containment, teams should review the host for secondary compromise, because successful exploitation can leave behind web shells, modified startup files, or stolen database credentials that outlive the original entry point.

Risk and Threat Considerations

This class of issue is attractive to attackers because it turns a trusted administrative feature into a code execution primitive. Once an attacker obtains sufficient database privileges, the remaining challenge is usually environmental, whether they can steer log output to a useful location and whether the server can write there with enough permission to matter.

Failure mechanism: The attack succeeds when database-level write capability is combined with a writable or executable filesystem path, allowing log output to be interpreted as active content rather than inert text.

Impact: Successful exploitation can lead to remote code execution, persistence on the host, lateral movement, and the need to rotate database credentials or other secrets that may have been exposed during the compromise.

Standards & Framework Alignment

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

NIST SP 800-53 Rev 5, CIS Controls v8 and OWASP ASVS set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5AC-6 — Least PrivilegeLimits who can change database logging paths and file writes.
SI-4 — System MonitoringSupports detection of suspicious log writes and post-exploit activity.
Recommendation — Restrict database and host privileges to prevent log-path abuse. Monitor database configuration changes and unexpected file writes.
CIS Controls v8CIS-5 — Account ManagementControls who can hold the privileges needed to abuse logging paths.
CIS-10 — Malware DefensesHelps detect and contain payloads dropped through log-based execution paths.
Recommendation — Review and restrict privileged database accounts that can alter logging. Use malware defenses to detect malicious files written through the database.
OWASP ASVSV13 — ConfigurationConfiguration hardening is central to preventing unsafe log destinations.
Recommendation — Harden configuration so logs cannot be redirected into executable paths.

Practitioner Guidance

What to watch for: Treat any database feature that writes to disk as a potential security boundary. The key governance decision is whether the database service, and any account that can influence it, is allowed to create files in locations that the operating system, web tier, or automation will later trust.

Practitioner takeaway: If a database can write where code can run, logging has become an attack surface, so configuration review and filesystem separation should be routine parts of hardening.

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 25, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org