---
title: "QWEDLocal.verify_math and verify() report a model's…"
description: "GHSA-r9hc-57m3-2r9f: QWEDLocal.verify_math and verify() report a model's answer as verified when SymPy, run on the model's… Affected and fixed versions of qwed."
url: https://qwedai.tech/security/advisories/ghsa-r9hc-57m3-2r9f
---

[Security](https://qwedai.tech/security) · [Advisories](https://qwedai.tech/security/advisories) · GHSA-r9hc-57m3-2r9f

# QWEDLocal.verify\_math and verify() report a model's answer as verified when SymPy, run on the model's own expression, agrees with it

high Fixed in 11.0.0 GHSA-r9hc-57m3-2r9f · Published 20 November 2026

## Summary

`QWEDLocal.verify_math()` asks the configured model two things about the query: an answer, and a SymPy expression for it. It evaluates that expression with SymPy and returns `verified=True` with `confidence=1.0` whenever the result equals the answer.

Both come from the same model, and nothing checks that the expression computes what the query asks. So a wrong answer is reported as verified whenever the model's two replies agree with each other:

-   "What is 2 + 2?" answered `5` with `sympy.simplify(2+3)` comes back `verified=True`, `value="5"`.
-   `QWEDLocal.verify()` calls `verify_math`, and so do the `qwed verify` and `qwed interactive` commands, so all of them do the same.
-   The verified result is cached and served again.

## Affected components

| Component | Location |
| --- | --- |
| `QWEDLocal.verify_math` | `qwed_sdk/qwed_local.py` L838-965: `is_correct = _math_answers_match(llm_answer, verified_result)`, where `verified_result` is SymPy run on the model's own expression, then `VerificationResult(verified=is_correct, confidence=1.0 if is_correct else 0.0)` |
| `QWEDLocal.verify` | `qwed_sdk/qwed_local.py` L819-836: returns `self.verify_math(query)` |
| The `qwed verify` and `qwed interactive` commands | `qwed_sdk/cli.py`: build a `QWEDLocal` and call `verify(query)` |
| The LangChain integration on `QWEDLocal` | `qwed_sdk/integrations/langchain.py`: `client.verify(query)` |
| The local result cache | `verify_math` stores a verified result (cache policy `v1`, 24 hours by default) and returns it for the same query without calling the model |

## Root cause

-   **Self-consistency, not verification.** The model supplies both the claim (the answer) and the computation it is checked against (the SymPy expression). SymPy computes the expression correctly, but nothing ties the expression to the query. Agreement between two outputs of one model is not evidence that either is right.
-   **Nothing ties the expression to the query.** No check compares the expression with the question, and `QWEDLocal` returns no admission decision, so `verified` is the only signal a caller has.

This is not the code-execution issue in the same path, fixed by GHSA-xmm6-8r3x-j567 and GHSA-4v5r-g7f4-vvgc. Those concerned how the answer and the expression are parsed. This concerns what a successful comparison is taken to mean.

## Proof of concept (local, synthetic, inert payloads)

The model's two replies are replaced by fixed strings, so nothing is sent anywhere:

```python
from qwed_sdk.qwed_local import QWEDLocal

local = QWEDLocal(base_url="http://localhost:11434/v1", model="llama3", cache=False)
replies = iter(["5", "sympy.simplify(2+3)"])
local._call_llm = lambda prompt, system=None: next(replies)  # the model's two replies

r = local.verify_math("What is 2 + 2?")
print(r.verified, r.value, r.confidence)  # True 5 1.0
```

Checked on `main` at `026704e9` (9.1.0 plus later fixes; the code of this path is the same as in 9.1.0):

| Method | Query | Model's answer | Model's expression | Result |
| --- | --- | --- | --- | --- |
| `verify_math` | What is 2 + 2? | `5` | `sympy.simplify(2+3)` | `verified=True`, `value="5"`, `confidence=1.0` |
| `verify_math` | What is the derivative of x\*\*2? | `3*x**2` | `sympy.diff(x**3, x)` | `verified=True`, `value="3*x**2"`, `confidence=1.0` |
| `verify` | What is 10 / 4? | `3` | `sympy.simplify(9/3)` | `verified=True`, `value="3"`, `confidence=1.0` |

## Impact

This affects the integrity of maths answers. An application, agent or script that acts on `QWEDLocal.verify(...).verified` or `verify_math(...).verified`, or on the "VERIFIED" that `qwed verify` prints, acts on whatever the model answered, as long as its two replies agree.

-   **Who can cause it:** a query that steers the model (prompt injection), or a model that is simply wrong, gets `verified=True` with `confidence=1.0`. No credentials are needed.
-   **The cache makes it last:** with the cache on, which is the default, the verified answer is served again for the same query for 24 hours.

## Affected versions

-   From tag `v2.1.0` (introduced in `82fbafab`) through **10.0.0** (`qwed_sdk/qwed_local.py` is unchanged from 9.1.0 to 10.0.0).

## 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"`. `QWEDLocal.verify_math` and `QWEDLocal.verify` never return `verified`, and `qwed verify` exits 1. `evidence["consistent"]` and `error` say whether the model agreed with its own expression, and results cached as verified are not served. To verify a maths claim, write it as an equation and send it to `/verify/math`.

## Workarounds

-   Do not act on `verified` from `QWEDLocal.verify` or `verify_math`, or on `qwed verify`'s verdict.
-   To check a maths claim, state it yourself as an equation and send it to the server's `/verify/math`, or use `VerificationEngine` in process. The verdict is then about the expression you wrote, not about a model's paraphrase of the question.
-   Construct `QWEDLocal(..., cache=False)` so a result is not reused.

Advisory page: [https://qwedai.tech/security/advisories/ghsa-r9hc-57m3-2r9f](https://qwedai.tech/security/advisories/ghsa-r9hc-57m3-2r9f)

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

Affected and fixed

qwed

Affected \>= 2.1.0, <= 10.0.0 Fixed in 11.0.0

Weakness

CWE-345 Insufficient Verification of Data Authenticity

[View on GitHub](https://github.com/QWED-AI/qwed-verification/security/advisories/GHSA-r9hc-57m3-2r9f)
