CVE-2025-62611 Overview
CVE-2025-62611 affects aiomysql, an asyncio-based Python library for accessing MySQL databases. Versions prior to 0.3.0 fail to verify client-side local_infile settings before transmitting local files to the MySQL server. A rogue MySQL server can emulate authorization, ignore client capability flags, and request arbitrary files from the client by issuing a LOAD_LOCAL instruction packet. The flaw is tracked as [CWE-73: External Control of File Name or Path] and was fixed in aiomysql version 0.3.0.
Critical Impact
An attacker controlling a malicious MySQL server can exfiltrate arbitrary files readable by the aiomysql client process, including credentials, configuration files, and application source code.
Affected Products
- aiomysql versions prior to 0.3.0
- Python applications using aiomysql with client_flag set to include CLIENT.LOCAL_FILES
- Asyncio-based services connecting to untrusted MySQL endpoints
Discovery Timeline
- 2025-10-22 - CVE-2025-62611 published to NVD
- 2026-04-15 - Last updated in NVD database
Technical Details for CVE-2025-62611
Vulnerability Analysis
The MySQL wire protocol supports a LOAD DATA LOCAL INFILE mechanism that allows the server to request files from the client. Legitimate use cases involve bulk data loading from the application host. The protocol design places trust in the client to decide whether to honor such requests, controlled by capability flags negotiated during connection handshake.
In vulnerable aiomysql releases, the client does not enforce its own local_infile setting before responding to LOAD_LOCAL packets. A rogue server can advertise itself, accept any credentials, and then send a LOAD_LOCAL packet specifying an arbitrary path such as /etc/passwd or ~/.aws/credentials. The client reads the file from disk and streams its contents back to the attacker-controlled server.
Root Cause
The defect resides in aiomysql/connection.py. The constructor accepted a local_infile parameter but only used it to OR the CLIENT.LOCAL_FILES capability bit into client_flag. It never persisted the value as an instance attribute for later enforcement. When a LOAD_LOCAL packet arrived, the handler had no state to consult and serviced the request unconditionally.
Attack Vector
Exploitation requires the victim application to initiate an outbound MySQL connection to a server controlled by the attacker. This occurs in scenarios involving misconfigured connection strings, DNS hijacking, man-in-the-middle positioning on unencrypted MySQL traffic, or applications that accept user-supplied database hostnames.
# Patch applied in aiomysql/connection.py
self._encoding = charset_by_name(self._charset).encoding
- if local_infile:
+ self._local_infile = bool(local_infile)
+ if self._local_infile:
client_flag |= CLIENT.LOCAL_FILES
client_flag |= CLIENT.CAPABILITIES
Source: GitHub Commit 32c4520
The patch stores local_infile as self._local_infile so the connection handler can check it before honoring server-side file requests. Passing CLIENT.LOCAL_FILES through client_flag alone is no longer sufficient to enable local file loading.
Detection Methods for CVE-2025-62611
Indicators of Compromise
- Outbound MySQL connections (TCP/3306 or custom ports) to unexpected or untrusted hosts from application servers
- MySQL protocol traffic containing LOAD_LOCAL packets targeting sensitive paths such as /etc/passwd, /proc/self/environ, or cloud credential files
- Python application logs showing aiomysql connections established to dynamically resolved or user-supplied hostnames
Detection Strategies
- Inventory Python dependencies and flag any environment using aiomysql at a version below 0.3.0 via pip list or SBOM tooling
- Inspect application code for instances where client_flag is set to include CLIENT.LOCAL_FILES without an explicit local_infile=False parameter
- Deploy network monitoring rules that alert on MySQL LOAD DATA LOCAL INFILE responses originating from client hosts to non-corporate database endpoints
Monitoring Recommendations
- Enable egress filtering to restrict MySQL connections to a known allowlist of database servers
- Log and review file access events from Python interpreter processes targeting sensitive paths outside the application's data directory
- Monitor for unexpected DNS resolutions that redirect known database hostnames to external IPs
How to Mitigate CVE-2025-62611
Immediate Actions Required
- Upgrade aiomysql to version 0.3.0 or later in all affected applications and rebuild deployment artifacts
- Audit all aiomysql.connect() and create_pool() invocations and remove CLIENT.LOCAL_FILES from client_flag unless local file loading is explicitly required
- Verify database connection endpoints are static, validated, and not derived from user input or untrusted configuration sources
Patch Information
The fix is included in aiomysql version 0.3.0 via Pull Request #1044 and commit 32c4520. Loading local data now requires explicitly setting the local_infile=True parameter. Passing the capability through client_flag alone no longer enables the feature. Full advisory details are in GHSA-r397-ff8c-wv2g.
Workarounds
- Set local_infile=False explicitly on all aiomysql connections and remove CLIENT.LOCAL_FILES from any client_flag values
- Restrict outbound network connectivity from application hosts so only trusted MySQL servers are reachable
- Enforce TLS for all MySQL connections to mitigate man-in-the-middle redirection to rogue servers
# Upgrade aiomysql to the patched release
pip install --upgrade 'aiomysql>=0.3.0'
# Verify installed version
python -c "import aiomysql; print(aiomysql.__version__)"
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

