QWED

Type to search pages, engines and advisories.

    Looking for API details?Search the docs

    Security·Advisories·GHSA-xpfc-qm4c-xf6q

    SQLVerifier admits column-reading tautologies, whole-row reads of tables with protected columns, and a MySQL '--x' that MySQL does not treat as a comment

    mediumFixed in 11.0.0GHSA-xpfc-qm4c-xf6q · Published 20 November 2026

    Impact

    POST /verify/sql returns VERIFIED, is_valid: true and admission ADMIT for queries that read every row or every column of a protected table. Schema: CREATE TABLE users (id INT, name TEXT, password TEXT);

    Dialect Query main @ d4ca8dc
    sqlite SELECT id, name FROM users WHERE id = 5 OR name LIKE '%' VERIFIED, is_valid: true, ADMIT
    sqlite SELECT id, name FROM users WHERE id = 5 OR id = id + 0 VERIFIED, is_valid: true, ADMIT
    sqlite SELECT id, name FROM users WHERE id = 5 OR abs(id) >= 0 VERIFIED, is_valid: true, ADMIT
    postgres SELECT row_to_json(u) FROM users u VERIFIED, is_valid: true, ADMIT
    mysql SELECT id FROM users WHERE id = 1 --1 OR 1=1 VERIFIED, is_valid: true, ADMIT
    sqlite ... WHERE id = 5 OR 1 = 1 (control) VERIFIED, is_valid: false, BLOCKED
    postgres SELECT password FROM users (control) VERIFIED, is_valid: false, BLOCKED
    mysql ... WHERE id = 1 OR 1=1 (control) VERIFIED, is_valid: false, BLOCKED

    The same results on sqlglot 28.0.0 and 30.7.0. The image pins 30.25.0, which was not tested.

    Affected

    qwed (PyPI) through 10.0.0. Reproduced on main @ d4ca8dc.

    Reachable from POST /verify/sql, batch SQL items and SQLVerifier.verify_sql.

    The SDK's SQLGuard.verify_query is affected by the MySQL comment form too. It does not use _AMBIGUOUS_TOKENIZATION, so with sqlglot 28.0.0 it returns verified: True for SELECT 1 --1; DROP TABLE users (dialect="mysql") as one read-only statement, while MySQL reads --1 as - -1 and, where multiple statements are allowed, runs DROP TABLE users as a second one. sqlglot 30.31.0 reads --1 as MySQL does.

    Reproduction

    from qwed_new.core.sql_verifier import SQLVerifier
    from qwed_new.core.diagnostics import admission_decision
    
    ddl = "CREATE TABLE users (id INT, name TEXT, password TEXT);"
    for dialect, q in [("sqlite", "SELECT id, name FROM users WHERE id = 5 OR name LIKE '%'"),
                       ("sqlite", "SELECT id, name FROM users WHERE id = 5 OR id = id + 0"),
                       ("postgres", "SELECT row_to_json(u) FROM users u"),
                       ("mysql", "SELECT id FROM users WHERE id = 1 --1 OR 1=1")]:
        dr = SQLVerifier().verify_sql(q, ddl, dialect=dialect)
        print(dialect, q, dr.status.value, dr.developer_fields.get("is_valid"), admission_decision(dr).value)
    

    Details

    • Tautologies that read a column. Constant predicates are folded and refused, but a predicate that reads a column is judged against known shapes: self-comparison is caught only for a bare column on both sides (_self_comparison, src/qwed_new/core/sql_verifier.py:295-300). name LIKE '%', id = id + 0 and abs(id) >= 0 are true for every non-null row and pass.
    • Whole-row reads. Protected columns are matched by name. A whole-row reference (row_to_json(u), or SELECT u FROM users u) returns the password column without naming it.
    • MySQL comments. MySQL treats -- as a comment only when whitespace follows it; sqlglot drops --1 OR 1=1 as a comment for every dialect. _AMBIGUOUS_TOKENIZATION (src/qwed_new/core/sql_verifier.py:66) describes this case but is used only by the stacked-query check (:88), so the MySQL server would run OR 1=1 that the verifier never saw. The SDK's SQLGuard does not use it at all.

    Patches

    Fixed in 11.0.0. Upgrade with pip install -U "qwed>=11.0.0". The operands of an OR, XOR or IN list in a filter must each restrict one column to values, and a negated AND is refused (sql_verifier.unrestricted_or). Whole-row references (a table or alias used as a column, COLUMNS(), positional columns and similar) are refused where the schema gives the table a protected column. A query that sqlglot and a database can split into tokens differently is BLOCKED (sql_verifier.ambiguous_tokenization), and SQLGuard refuses it with AMBIGUOUS_TOKENS.

    Advisory page: https://qwedai.tech/security/advisories/ghsa-xpfc-qm4c-xf6q

    All advisories

    Affected and fixed

    qwed

    Affected<= 10.0.0 Fixed in11.0.0
    Weakness
    CWE-89 Improper Neutralization of Special Elements used in an SQL CommandCWE-697 Incorrect Comparison
    View on GitHub