Bagel's query_messages Was Read-Only by Label, Not by Capability
A read-only annotation describes an intended use. It does not reduce the authority of the database engine that receives the query. CVE-2026-138027 affected Bagel before 2.5.5 because the query_messages MCP tool could execute DuckDB SQL with file and network capabilities despite its read-only label.
The exposed surface
The CVE record says the tool allowed functions such as read_csv_auto, COPY TO, and httpfs. DuckDB can read files, write files, and make HTTP requests when those capabilities are available. A query that looks analytical can therefore inspect local data or send a request outside the container.
Prompt injection is the delivery path. The record says untrusted content in recorded logs or topics could influence the model that drives the tool. The SQL is then executed by a process that has more authority than the label suggests.
Why the annotation is insufficient
An MCP tool description is consumed by a model. A read-only annotation may affect how the model selects the tool, but the server still needs to enforce the restriction. Enforcement can come from a query parser, a limited SQL dialect, database configuration, process sandboxing, or a combination of those controls.
Keyword blocking is fragile around functions and aliases. Capability removal is stronger. If the agent only needs aggregate access to a fixed table, expose a narrowly defined function instead of general SQL. If general SQL is required, use a database role and extension configuration that cannot read arbitrary paths or open outbound connections.
Impact
The CVE lists CVSS 4.0 and 3.1 at 7.7 and 7.5. The 3.1 vector requires user interaction through the prompt path but still results in high confidentiality, integrity, and availability impact. The score is not evidence that every deployment permits DuckDB extensions or filesystem access.
A successful call may expose local files, write to paths the service can reach, or contact an internal endpoint. The actual blast radius depends on the container mount, service account, network policy, and DuckDB configuration.
Remediation
Upgrade to Bagel 2.5.5 or later. Review the query entry points in the deployed version and confirm that the read-only path cannot load extensions, attach external databases, read arbitrary paths, or write files. Remove broad mounts from the MCP container. Keep the data needed for analysis in a read-only volume and put outbound network access behind an explicit allow-list.
Audit prompts and recorded topics that can reach the model. Treat log content and prior conversation as untrusted input. A stored message can contain instructions just as easily as a current message can.
Validation
Run a harmless read_csv_auto against an approved fixture and confirm that unapproved paths are rejected. Attempt a write to a disposable path that the service account should not have. Attempt an outbound request to a controlled listener. The tests should verify the server's enforcement, not only whether the model declines the request.
Bagel's advisory groups fixes in version 2.5.5. The difference between the two Bagel CVEs matters operationally: CVE-2026-138028 concerns argument injection in an rsync task, while CVE-2026-138027 concerns unsandboxed DuckDB SQL. Both can reach process authority, but they need different tests and logging.

