---
title: "SQLVerifier admits SELECT ... INTO, which creates…"
description: "GHSA-6m2h-98rq-4f53: SQLVerifier admits SELECT ... INTO, which creates a table and writes rows, as a read-only query. Affected and fixed versions of qwed."
url: https://qwedai.tech/security/advisories/ghsa-6m2h-98rq-4f53
---

[Security](https://qwedai.tech/security) · [Advisories](https://qwedai.tech/security/advisories) · GHSA-6m2h-98rq-4f53

# SQLVerifier admits SELECT ... INTO, which creates a table and writes rows, as a read-only query

medium Fixed in 11.0.0 GHSA-6m2h-98rq-4f53 · Published 20 November 2026

## Impact

`SQLVerifier.verify_sql` (`POST /verify/sql`, batch SQL items) returns `VERIFIED · ADMIT`, as a read-only query, for `SELECT ... INTO`, which creates a table and writes the selected rows into it. The SDK's `SQLGuard.verify_query` refuses the same statements.

Checked on `main` @ `ec50c2ac`, without a schema:

| Dialect | Query | `verify_sql` | `SQLGuard` `verified` |
| --- | --- | --- | --- |
| postgres | `SELECT id, name INTO newtab FROM users` | **ADMIT** | False |
| postgres | `SELECT id INTO TEMP t FROM users`, `INTO UNLOGGED t` | **ADMIT** | False |
| postgres | `SELECT * FROM (SELECT id INTO t2 FROM users) s` | **ADMIT** | False |
| postgres | `WITH c AS (SELECT 1 AS a) SELECT a INTO t3 FROM c` | **ADMIT** | False |
| postgres | `SELECT id INTO t4 FROM users UNION SELECT id FROM users` | **ADMIT** | False |
| tsql | `SELECT id INTO #tmp FROM users`, `INTO dbo.newtab` | **ADMIT** | False |
| duckdb, snowflake, redshift | `SELECT id INTO newtab FROM users` | **ADMIT** | False |
| mysql | `SELECT id INTO @v FROM users LIMIT 1` | **ADMIT** | False |
| postgres | `CREATE TABLE t AS SELECT * FROM users` (control) | BLOCKED | False |

With a schema (`POST /verify/sql` requires one), the schema check refuses a name the schema does not hold (`INTO newtab`), but because the table is not in the schema, not because the statement writes; nothing in 10.0.0 refuses the write itself.

A caller that runs verified SQL as read-only lets a query create tables and copy rows into them, which can fill storage or place data where other users can read it.

## Affected

`qwed` (PyPI) through 10.0.0. Reachable from `POST /verify/sql`, batch SQL items and `SQLVerifier.verify_sql`, with a schema and without one.

## Reproduction

```python
from qwed_new.core.sql_verifier import SQLVerifier
from qwed_new.core.diagnostics import admission_decision

result = SQLVerifier().verify_sql("SELECT id, name INTO newtab FROM users", None, dialect="postgres")
print(admission_decision(result).value)  # ADMIT
```

## Details

`SQLVerifier.DESTRUCTIVE_COMMANDS` (`src/qwed_new/core/sql_verifier.py:632`) lists `Drop`, `Delete`, `Update`, `Insert`, `Alter`, `Truncate`, `Create` and `Merge`, and `_check_command_type` (`:945`) blocks any of them anywhere in the tree. sqlglot parses `SELECT ... INTO` as a `Select` holding an `Into` node, so the root is a read-only type and no listed node is found. `SQLGuard` adds `exp.Into` to its mutation types (GHSA-45jv-2j44-4c2q); the verifier was not given the same.

## Patches

Fixed in [11.0.0](https://github.com/QWED-AI/qwed-verification/releases/tag/v11.0.0). Upgrade with `pip install -U "qwed>=11.0.0"`. `SELECT ... INTO`, MySQL's `INTO @var` included, is a destructive command (`sql_verifier.malicious`), refused unless destructive statements are allowed, as `CREATE TABLE ... AS SELECT` is.

## Workarounds

Run verified SQL with a database user that cannot create tables. A schema is not a fix on its own (see above).

Advisory page: [https://qwedai.tech/security/advisories/ghsa-6m2h-98rq-4f53](https://qwedai.tech/security/advisories/ghsa-6m2h-98rq-4f53)

[All advisories](https://qwedai.tech/security/advisories)

Affected and fixed

qwed

Affected <= 10.0.0 Fixed in 11.0.0

Weakness

CWE-184 Incomplete List of Disallowed Inputs

[View on GitHub](https://github.com/QWED-AI/qwed-verification/security/advisories/GHSA-6m2h-98rq-4f53)
