QWED

Type to search pages, engines and advisories.

    Looking for API details?Search the docs

    Security·Advisories·GHSA-q7m5-rmvq-v848

    /verify/math returns VERIFIED and ADMIT for false identities: superscript and subscript digits fold into neighbouring numbers, and Float rounding counts as proof

    mediumFixed in 11.0.0GHSA-q7m5-rmvq-v848 · Published 20 November 2026

    Impact

    POST /verify/math (and batch math items) return VERIFIED, is_valid: true and admission ADMIT for false identities. Two separate causes: the parser folds superscript and subscript digits into the digits or names beside them, and the identity check accepts a zero difference that only exists because SymPy rounded a Float.

    expression main @ d4ca8dc (route and batch) Correct
    2² = 22 VERIFIED, is_valid: true, ADMIT false: 2² = 4
    (x+1)² = 2x + 2 VERIFIED, is_valid: true, ADMIT false
    2₃ = 23 VERIFIED, is_valid: true, ADMIT not the claim written
    1 + 1.0e-17 = 1 VERIFIED, is_valid: true, ADMIT false
    1.0e20 + 1 = 1.0e20 VERIFIED, is_valid: true, ADMIT false
    Float(1000, 1) + 1 = 1000 VERIFIED, is_valid: true, ADMIT false
    2² = 4 VERIFIED, is_valid: false (proven false) true claim
    3² + 4² = 5² VERIFIED, is_valid: false (proven false) true claim
    2 + 2 = 5 (control) VERIFIED, is_valid: false correct

    Models write ² often, so the first class is easy to hit by accident as well as on purpose.

    More forms of the same causes, each VERIFIED, is_valid: true, ADMIT on main @ ec50c2ac: NFKC also reads letters in other forms as ASCII letters, so Ⅰ = I and ℑ(I) = -1 read a Roman numeral and a black-letter I as the imaginary unit I; implicit multiplication reads 1 000 as 1*000 and 2 2 as 2*2 (1 000 = 0, 2 2 = 4); and evaluation can hide the Float (1 + 1.0e-17 - 1 = 0, Integer(Float(1000, 1) + 1) = 1000).

    Affected

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

    Reachable from:

    • POST /verify/math in a = b form, and batch math items;
    • safe_parse_expr, and every engine that parses with it;
    • VerificationEngine.verify_math, which serves /verify/natural_language and the consensus SymPy engine: verify_math("1 + 1.0e-17", 1, tolerance=0), verify_math("1.0e20 + 1", 1e20) and verify_math("2²", 22) return VERIFIED with is_correct: true.

    Reproduction

    from qwed_new.core.math_worker import verify_math_request, verify_batch_math
    from qwed_new.core.diagnostics import admission_decision
    
    for ex in ["2² = 22", "(x+1)² = 2x + 2", "2₃ = 23", "1 + 1.0e-17 = 1",
               "1.0e20 + 1 = 1.0e20", "Float(1000, 1) + 1 = 1000", "2² = 4", "2 + 2 = 5"]:
        for dr in (verify_math_request(ex, {}), verify_batch_math(ex)):
            print(ascii(ex), dr.status.value, dr.developer_fields.get("is_valid"), admission_decision(dr).value)
    

    Details

    • Digit folding. safe_parse_expr applies unicodedata.normalize("NFKC", ...) before its charset check (src/qwed_new/core/safe_parser.py:1002; the same at src/qwed_new/core/verifier.py:458). NFKC maps ² to 2 and ₃ to 3, so 2² becomes 22 and (x+1)² becomes (x+1)2, which implicit multiplication reads as (x+1)*2.
    • Float rounding as proof. The identity check returns VERIFIED when difference == 0 (src/qwed_new/core/verifier.py:715) before it checks difference.has(Float) (:717). SymPy has already rounded 1 + 1.0e-17 to 1.0 and 1.0e20 + 1 to 1.0e20 while parsing, so the difference is an exact zero. Float is in the parser's namespace (src/qwed_new/core/safe_parser.py:897), so the input can also choose a low precision.

    Related, not part of this report: a single letter before a bracket is a product (f(0) is f*0), as documented in the 9.0.0 fix for unknown function names. With it, f(a+b) = f(a) + f(b) and f(0) = 0 are ADMIT. Whether that reading should stay is a separate decision.

    Patches

    Fixed in 11.0.0. Upgrade with pip install -U "qwed>=11.0.0". Characters NFKC reads as other text (superscripts, subscripts, Roman numerals, squared units, letters in another width or font), two numbers with only space between them and numbers the parser splits in two are refused. When a side holds a Float, a zero difference stands only if the claim holds with its decimals read exactly; otherwise the claim is disproven or UNVERIFIABLE (math.inexact_decimal). Values, derivatives, indefinite integrals and limits are re-checked the same way, in VerificationEngine too. With no tolerance, verify_math still accepts a claim within its default bound, min(1e-6, max(1e-9 × |value|, 1e-12)) (since 9.0.0, GHSA-8hp7-jqjc-hrhf), so verify_math("1 + 1.0e-17", 1) still returns VERIFIED, with match {"kind": "default_bound"} rather than exact. Pass tolerance=0 to compare exactly.

    Advisory page: https://qwedai.tech/security/advisories/ghsa-q7m5-rmvq-v848

    All advisories

    Affected and fixed

    qwed

    Affected<= 10.0.0 Fixed in11.0.0
    Weakness
    CWE-176 Improper Handling of Unicode EncodingCWE-697 Incorrect Comparison
    View on GitHub