QWED

Type to search pages, engines and advisories.

    Looking for API details?Search the docs

    Security·Advisories·GHSA-5h3v-3463-78hf

    /verify/math returns VERIFIED and ADMIT for false identities: unknown function names parse as products of symbols, and n is assumed a positive integer

    mediumFixed in 9.0.0GHSA-5h3v-3463-78hf · Published 6 November 2026

    Impact

    POST /verify/math (and batch math items) return VERIFIED, is_valid: true and admission ADMIT for false identities. Two separate parser behaviours cause it: safe_parse_expr turns an unknown function name into a product of single-letter symbols, and it gives the name n hidden assumptions (positive integer).

    expression main @ b74ac00 Correct
    sinc(0) = 0 VERIFIED, is_valid: true, ADMIT false: sinc(0) = 1
    zeta(0) = 0 VERIFIED, is_valid: true, ADMIT false: ζ(0) = −1/2
    Abs(n) = n VERIFIED, is_valid: true, ADMIT false for negative n
    sqrt(n**2) = n VERIFIED, is_valid: true, ADMIT false for negative n
    floor(7/2) = 3 VERIFIED, is_valid: false (proven false) true claim
    ln(e) = 1 VERIFIED, is_valid: false (proven false) true claim
    Abs(x) = x, 2+2 = 5 (controls) VERIFIED, is_valid: false correct

    What the parser builds:

    • safe_parse_expr("sinc(0)") → 0: sinc is split into s*i*n*c, which is 0 at the argument 0. zeta(0) → 0 the same way.
    • safe_parse_expr("floor(7/2)") → 7*f*l*o**2*r/2.
    • safe_parse_expr("n") → a Symbol with integer=True, positive=True. The assumption appears in neither the evidence nor the agent message.

    Affected

    qwed (PyPI) through 8.0.0. Reproduced on main @ b74ac00.

    Reachable from:

    • POST /verify/math in a = b form, and batch math items (both use math_identity_result);
    • safe_parse_expr, and every engine that parses with it.

    Reproduction

    from qwed_new.core.math_identity import math_identity_result
    from qwed_new.core.diagnostics import admission_decision
    from qwed_new.core.safe_parser import safe_parse_expr
    
    for ex in ["sinc(0) = 0", "zeta(0) = 0", "Abs(n) = n", "sqrt(n**2) = n", "floor(7/2) = 3", "2+2 = 5"]:
        dr = math_identity_result(ex)
        print(ex, dr.status.value, dr.developer_fields.get("is_valid"), admission_decision(dr).value)
    print(safe_parse_expr("floor(7/2)"), safe_parse_expr("n").assumptions0)
    

    Details

    src/qwed_new/core/safe_parser.py:

    • Lines 986-989: the main parse uses implicit_multiplication_application, which includes split_symbols and implicit_application. A name the allowlist does not bind, followed by (, is split into letters and multiplied by the bracket.
    • Lines 855-861: the local namespace binds n as Symbol("n", integer=True, positive=True) and Greek names such as zeta and gamma as plain Symbols, so zeta(0) and gamma(…) also become products.

    Patches

    Fixed in 9.0.0 (48c4bc0). Upgrade to 9.0.0 or later.

    • The parser no longer splits a name into letters: a multi-letter name is one symbol. 2x, x(x+1) and sin x read as before.
    • A name of two or more letters in call position (before a bracket or an operand, after a power, or in parentheses) must be a supported function. Any other is an input error (Unknown function), which /verify/math reports as BLOCKED with math.parse_error. A single letter before a bracket is still a product: f(0) is f*0.
    • n is a plain symbol with no assumptions.

    On 9.0.0, sinc(0) = 0, zeta(0) = 0 and floor(7/2) = 3 are refused as unknown functions, and Abs(n) = n and sqrt(n**2) = n are proven false. ln(e) = 1 is still proven false: e is a free symbol, and Euler's number is E (ln(E) = 1 is VERIFIED).

    Upgrade note: write * between names you mean to multiply. xy is now one name, so xy and yx are different symbols.

    All advisories