Summary
SQLBot versions prior to 1.7.0 contain a Server-Side Request Forgery (SSRF) flaw in the datasource connectivity check that can be abused to read arbitrary files from the server.
By configuring a forged MySQL data source and leveraging the LOCAL INFILE capability via a rogue MySQL server, an attacker can trick SQLBot into loading and exfiltrating system or application files such as /etc/passwd and sensitive configuration data.
Affected context
This vulnerability appears in SQLBot deployments that:
- Allow users to create or modify external data sources through the
/api/v1/datasource/checkAPI. - Permit outbound connections from the SQLBot server to attacker-controlled MySQL endpoints.
- Do not restrict or sanitize MySQL connection parameters (e.g.,
extraJdbc) that enableLOAD DATA LOCAL INFILE.
The risk is elevated in environments where SQLBot runs with permissions to read system files or application configuration files containing secrets (database credentials, API keys, tokens).
Exploit preconditions
- Attack surface: The
/api/v1/datasource/checkHTTP endpoint responsible for validating data source connectivity. - Required access: Ability to invoke the data source check API and supply connection parameters (e.g., authenticated user with permission to add or validate data sources, or any exposed integration using that API).
- Network conditions: The SQLBot server must be able to initiate outbound MySQL connections to an attacker-controlled host and port.
- Trigger point: During the MySQL handshake and subsequent connection verification, when the backend honors
extraJdbc="local_infile=1"and processesLOAD DATA LOCAL INFILEcommands. - Why exploitation is possible: The backend implicitly trusts the remote MySQL server, permits
LOCAL INFILEoperations, and runs with filesystem access broad enough to read arbitrary files whose paths are specified by the rogue server. Combined with SSRF-style control over the target MySQL endpoint, this leads to remote-triggered file reads from the SQLBot host.
Why this happens
The bug stems from combining unguarded outbound connectivity (SSRF) with insecure handling of database client capabilities that access local resources.
Concretely, the /api/v1/datasource/check logic allows user-controlled configuration of a MySQL data source, including parameters enabling local_infile. When the backend connects to the supplied host, it acts as a MySQL client and follows instructions from the remote server, including LOAD DATA LOCAL INFILE, which causes the client to read local files and send them over the connection.
This behavior maps to:
- CWE-918 (Server-Side Request Forgery): The application performs network requests to attacker-specified endpoints (rogue MySQL server) without proper validation or restriction.
- CWE-73 (External Control of File Name or Path): The external MySQL server can influence the file path used in
LOAD DATA LOCAL INFILE, effectively controlling which local files are accessed. The system treats this external input as trusted when performing local file operations.
The insecure pattern is: a server-side connectivity check that accepts attacker-controlled endpoints and protocol options, then delegates powerful local operations (file access) to that external party without constraining what can be requested.
Potential impact
- Exposure of sensitive system files (e.g.,
/etc/passwd, OS configuration). - Disclosure of application configuration files containing database credentials, API keys, and encryption secrets.
- Leakage of source code or SQLBot internal logic, aiding further exploitation.
- Facilitation of lateral movement if leaked credentials are reused across infrastructure.
- Enhanced reconnaissance for attackers, including environment metadata and deployment details.
General mitigation guidance
Effective mitigation focuses on constraining both outbound connectivity and local file access paths triggered by external services:
- Constrain SSRF capabilities:
- Limit which hosts and ports the SQLBot server can reach for data source validation, using allowlists, service discovery, or explicit network policies.
- Reject or tightly validate user-supplied hostnames, IP addresses, and connection strings to avoid arbitrary endpoints (including internal networks or loopback).
- Disable or restrict
LOCAL INFILE: - Configure MySQL client libraries such that
LOAD DATA LOCAL INFILEis disabled by default, unless explicitly required and carefully controlled. - If local import is needed, restrict it to predefined directories or mapped paths and enforce strict filename and path validation.
- Harden data source configuration handling:
- Treat advanced parameters like
extraJdbcas high-risk, disallowing or sanitizing options that affect local file access or client capabilities. - Introduce a schema or whitelist for allowed connection parameters that excludes file-related or arbitrary command options.
- Reduce file system exposure:
- Run SQLBot under a dedicated, minimally privileged account with limited read access, especially to system directories and secret-bearing files.
- Isolate configuration secrets using environment variables, secret management systems, or dedicated secret volumes with restricted access, rather than world-readable files.
- Apply defense-in-depth:
- Enforce network-level egress controls so application servers cannot freely connect to arbitrary external databases.
- Use container or OS-level sandboxing (e.g., chroot-like isolation, read-only file systems where practical) to reduce the blast radius of any file-read capability.
How teams detect issues like this
Detecting this class of vulnerability benefits from both code-centric and operational monitoring approaches:
- Static analysis and code review:
- Search for code paths where user-supplied connection parameters (host, port,
extraJdbc, JDBC URLs) are passed directly into database clients used for connectivity checks. - Flag uses of MySQL client options enabling
LOCAL INFILEor similar features that access local files, especially when options are constructed from user input. - Review any logic that performs network requests from servers on behalf of users (health checks, data source validators) for SSRF-like patterns and absence of host allowlists.
- Policy and configuration enforcement:
- Define security policies that disallow
LOCAL INFILEin production clients unless explicitly justified. - Implement CI/CD checks that scan configuration and source for dangerous database options or unconstrained outbound validation endpoints.
- Runtime monitoring and logging:
- Enable detailed logging of outbound connections from SQLBot, including destination hosts and ports for data source checks.
- Monitor database client logs for use of
LOAD DATA LOCAL INFILEand investigate unusual or unexpected file paths. - Use network monitoring to detect connections from the application server to unapproved or external database hosts initiated by data source checks.
- Automated security tooling:
- Integrate SAST tools capable of identifying SSRF sinks (HTTP clients, DB clients) fed by user input.
- Use DAST or integration tests that attempt to configure rogue data sources and verify that local file access operations are blocked.

