Summary
sqlite-mcp's default read-only mode can be bypassed through SQL statement handling and caller-controlled table names used in a PRAGMA operation. A client able to reach the server can potentially attach databases, access other SQLite files, or make a protected database writable.
Affected context
The issue affects sqlite-mcp deployments where the server's tools are reachable and the default read-only mode is relied on to restrict database operations. The vulnerable paths are execute_query, which may allow trailing statements after a leading SELECT, and describe_table, which interpolates the supplied table name into PRAGMA table_info. The server listens on all interfaces at :8080 by default and does not provide built-in authentication, so exposure depends on network access and any protections placed in front of it.
Exploit preconditions
- Attack surface: The sqlite-mcp tool interface, commonly reachable on port
8080 - Required access: Network reachability to the server; an authenticating proxy or equivalent control can restrict access
- Trigger point: A client invokes
execute_queryordescribe_tablewith input that reaches the vulnerable statement handling - Why exploitation is possible: Trailing SQL statements may be executed, and caller-controlled table names are interpolated into a PRAGMA statement, allowing
ATTACH DATABASEoperations despite the intended read-only restriction
Why this happens
The query path does not reliably constrain execution to a single permitted statement, while the table-description path inserts caller-controlled text into SQL syntax. These are SQL injection risks (CWE-89). The read-only mode also fails to enforce the intended access restriction across these operations, which is an authorization enforcement weakness (CWE-863).
Potential impact
- A client may make a protected database writable despite the default read-only mode.
- A client could read data from other SQLite database files accessible to the server process.
- The server may create a SQLite-format file at a path writable by its process.
- Database integrity or confidentiality could be affected, depending on the server's filesystem permissions and reachable files.
General mitigation guidance
Defensive patterns should ensure that read-only behavior is enforced at every database operation, not just through a connection mode.
- Restrict query execution to a single, explicitly permitted statement and reject trailing statements.
- Avoid constructing SQL from caller-controlled identifiers; validate identifiers against an allowlist and use safe quoting where appropriate.
- Explicitly deny or tightly control database attachment operations.
- Apply authentication and network access controls, and avoid exposing the tool interface to untrusted clients.
- Limit the server process's filesystem permissions so it can access only the database files it needs and cannot write to sensitive locations.
How teams detect issues like this
- Use static analysis and code review to identify SQL assembled through string interpolation, especially in PRAGMA statements and other identifier-bearing operations.
- Check whether query APIs reject multiple statements and whether read-only policy is enforced for every tool and database operation.
- Review deployment policies for unauthenticated service endpoints, broad interface binding, and unnecessary filesystem write access.
- Monitor database activity for unexpected
ATTACH DATABASEoperations and for creation or access of database files outside approved paths.

