GHSA-q5g6-6cw2-cjm3
SQLVerifier admits a tautology hidden in a MySQL executable comment, and queries on tables outside the declared schema
mediumPublished 13 October 2026
Impact
SQLVerifier.verify_sql admits two kinds of query that its own checks would reject in plain form. This affects every caller that gates on admission_decision, including POST /verify/sql.
- MySQL executable comments. With
dialect="mysql", a tautology inside/*!NNNNN ... */is not seen, and the query comes backVERIFIED,is_valid: true,ADMIT, with no issues. The same query without the comment is caught asinjection_tautology. MySQL and MariaDB execute the contents of executable comments, so the query returns every row. This is the same class of bug as GHSA-q8r4-6gpp-5fx2 in qwed-finance's QueryGuard. - Tables outside the schema. When
schema_ddldeclares the allowed tables, a query on another table is recorded asschema_table_missing, butis_validstays true and admission isADMIT. The same applies to aUNIONthat reads an undeclared table. The schema check reports the violation without affecting the decision.
Reproduction (qwed 7.2.2, main 3e91f12)
from qwed_new.core.sql_verifier import SQLVerifier
from qwed_new.core.diagnostics import admission_decision
ddl = "CREATE TABLE users (id INT, name TEXT, role TEXT)"
cases = [
("SELECT * FROM users WHERE id = 1 /*!50000 OR 1=1 */", "mysql"), # VERIFIED True ADMIT, issues []
("SELECT * FROM users WHERE id = 1 OR 1=1", "mysql"), # VERIFIED False BLOCKED, injection_tautology
("SELECT id FROM secrets", "postgres"), # VERIFIED True ADMIT, schema_table_missing
("SELECT id FROM users WHERE id = 1 UNION SELECT id FROM secrets", "postgres"), # VERIFIED True ADMIT
]
for query, dialect in cases:
r = SQLVerifier().verify_sql(query, ddl, dialect)
print(r.status.value, r.developer_fields["is_valid"], admission_decision(r).value)
Patches
Fixed in 7.2.3:
- MySQL and MariaDB executable comments (
/*! ... */,/*!NNNNN ... */,/*M! ... */) are expanded before analysis, whatever the declared dialect, so SQL inside them is checked.developer_fields.executable_comments_expandedrecords when this happened. - With
schema_ddl, a table outside the declared schema is an admission failure:is_valid: false, constraintsql_verifier.schema_violation. Names defined by the query itself (CTEs) are not treated as tables; withoutschema_ddl, tables are not checked.
Workarounds
Until you upgrade:
- Reject queries that contain
/*!before callingverify_sql. - Treat
schema_table_missingindeveloper_fields.issuesas a reason not to run the query.
Credit
Found by the soundness eval (#439) while writing its SQL cases.
Affected and fixed
- Package
- qwed
- Affected
- <= 7.2.2
- Fixed in
- 7.2.3
- Severity
- medium
- Weakness
- CWE-184 Incomplete List of Disallowed InputsCWE-436 Interpretation ConflictCWE-863 Incorrect Authorization