# GHSA-PVF2-6H4X-R24J: Read-only mode and the write-approval gate are bypassed by SELECT ... INTO

- Database: GitHub
- Severity: CVSS 6.2 (Medium)
- Published: 2026-09-30
- Modified: 2026-09-30

## Affected versions

- github.com/clidey/whodb (Go): from 0.88.0, fixed in 0.134.0

## Description

### Summary

WhoDB classifies SQL before applying the CLI read-only gate and the MCP `--confirm-writes` approval gate. Statements beginning with `SELECT` are treated as reads unless a token appears in `sqlguard.mutatingKeywords`. `INTO`, `OUTFILE`, and `DUMPFILE` are absent, so write-capable `SELECT ... INTO` forms are classified as non-mutating.

Confirmed examples include:

```sql
SELECT * INTO evil_copy FROM users
select id, email into stolen from accounts
SELECT * FROM users INTO OUTFILE '/tmp/dump.txt'
SELECT data FROM blobs INTO DUMPFILE '/tmp/x.bin'
```

The first two forms create and populate a PostgreSQL table. The latter forms write files on the MySQL server.

### Confirmed affected paths

`Classification.Mutating` controls all of these paths:

- `cli/internal/database/manager.go`: CLI read-only mode checks `IsMutationQuery`, which delegates to `sqlguard.Classify`.
- `cli/pkg/mcp/tools.go`: `--confirm-writes` requests approval only when `!sqlguard.IsReadOnly(query)`.
- `cli/pkg/mcp/validation.go`: MCP read-only validation accepts statements for which `Classification.Mutating` is false.

The same classification reaches CE and EE because both editions use the shared CLI/MCP and source session execution layers.

### Maintainer verification

The issue was reproduced end to end against the code shipped in 0.131.0. The 0.131.0 `core/src/sqlguard/classify.go` blob is identical to the tested checkout.

PostgreSQL:

- Standard `--confirm-writes` did not request confirmation and `SELECT ... INTO` created a table.
- Strict `--confirm-writes` also did not request confirmation and created a table when the target name did not incidentally match a strict substring rule.
- Current read-only mode rejected the statement with SQLSTATE 25006 and did not persist the table. This protection comes from the database-enforced read-only transaction added in 0.130.0; it does not correct the classifier or confirmation gate.

MySQL 8.4:

- Standard `--confirm-writes` did not request confirmation and `SELECT ... INTO OUTFILE` wrote a file.
- Current read-only mode also wrote the file. MySQL permits this server-side file operation inside the transaction mode currently used by WhoDB.
- Strict mode blocked `INTO OUTFILE` and `INTO DUMPFILE` through its existing dangerous-function substring list. Strict mode is not the default and does not block PostgreSQL `SELECT ... INTO <table>`.

Classifier-only tests also confirmed that all four submitted statements produce `Mutating=false`.

### Impact

A model or local caller can execute these statements without the approval promised by `--confirm-writes`. On affected backends, read-only mode may also fail to prevent the write.

Impact is bounded by the connected database account and server configuration:

- PostgreSQL table creation requires `CREATE` permission in the target schema.
- MySQL `INTO OUTFILE` and `INTO DUMPFILE` require the `FILE` privilege. `secure_file_priv`, when configured, restricts the destination directory. Existing files cannot be overwritten.

The confirmed outcomes are unauthorized table creation within the connected PostgreSQL database and server-side file creation on MySQL. No broader host compromise was tested or established.

### Affected versions

The original report identified `>= 0.123.0` based on the introduction of `core/src/sqlguard/classify.go`. That range was too narrow: the same first-keyword decision existed before the shared classifier.

- The vulnerable MCP confirmation gate is present from 0.88.0.
- The vulnerable CLI read-only gate is present from 0.105.0.
- The shared `sqlguard` implementation is vulnerable from 0.123.0 through the current 0.131.0 release.

The combined affected range is therefore `>= 0.88.0`. No patched release exists yet.

### Required remediation

A complete fix must:

1. Classify write-capable output/creation clauses structurally, including PostgreSQL `SELECT ... INTO <table>`, MySQL `SELECT ... INTO OUTFILE/DUMPFILE`, and equivalent leading forms such as `TABLE ... INTO OUTFILE`.
2. Use the corrected verdict consistently for read-only validation and write confirmation.
3. Preserve database-enforced read-only execution as a second boundary, while recognizing that transaction read-only does not prevent every server-side side effect on every backend.
4. Add backend-specific end-to-end tests through the actual CLI/MCP execution path.

Until a patched release is available, use a database account without schema-creation or MySQL `FILE` privileges. MySQL users should configure `secure_file_priv`. MCP users should not rely on standard `--confirm-writes` or read-only mode as the only boundary for untrusted SQL.

### Disclosure

The reporter supplied a deterministic classifier reproduction and clearly noted that they had not performed live database writes. Maintainer testing subsequently confirmed the end-to-end PostgreSQL and MySQL behavior described above.

## References

- https://github.com/clidey/whodb/security/advisories/GHSA-pvf2-6h4x-r24j

Page: https://cve.now/GHSA-PVF2-6H4X-R24J

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
