Vulnerability scanners decide "affected or not" from the version range in an advisory. If the range is wrong, the scanner is wrong too, and nobody notices.
The transformers case
GHSA-x9r9-c232-4q39 (high) says transformers is affected up to 5.8.1, with no patched release. The fix (commit cbc1651) shipped in 5.17.0. Releases 5.9.0 to 5.16.1 still have every line that commit removes. pip-audit and Dependabot report all of them as clean.
How I checked
For every PyPI advisory that links its fix commit on GitHub, I compared the fix with the code of each release: the lines it removes should be gone, and the lines it adds should be there. Git tags alone were wrong most of the time (many releases got the fix as a backport), so only the code counts.
Five recent cases held up:
- transformers 5.9.0 to 5.16.1 (fixed in 5.17.0)
- nltk 3.9.4 to 3.10.2 (the advisory says fixed in 3.9.4, the fix is in 3.10.3)
- LightRAG 1.3.8 and 1.3.9 (says 1.3.8, the fix is in 1.4.0)
- streamlit 1.53.1 to 1.58.0 (one of the two fixes came later)
- Django 5.0.x (a branch the advisory doesn't list)
How many projects
I searched GitHub for lockfiles that pin those releases and opened each one to confirm it. At least 6,049 public repos (no forks), 2,138 of them on transformers. That's a floor: I only read the first 100 results per search.
Being on one of these releases doesn't always mean you're exposed. The transformers bug needs text generation with a model from a Hub repo you don't control. But today no scanner even lets you ask.
Pydantic fixed theirs: pydantic-ai moved its lock to 5.17.0 (PR #16123).
Try it
uvx --with pip-audit depquiet --range-check
It reads your installed packages and reports a release only when its files still have the code the fix removes. I tested it on Windows: 5.12.0 gets flagged, 5.17.0 comes back clean.
What didn't work
I ran the same check on npm and got almost nothing. Most npm packages ship built code, so the lines don't compare. That's in the study too.
Study, scripts and limits: benchmarks/range_check
Built with help from Claude Code.
Top comments (3)
The direction of the failure is what makes this worth the work. A scanner that flags a clean release gets investigated. A scanner that clears a vulnerable one is terminal, because nothing downstream asks again.
Your fix changes what is being measured, and that is the real move. The advisory range is a third party's claim. The lines the fix commit removes are either in the file or they are not. You replaced an attestation with a recomputation.
Regulated payments does the same thing for sanctions screening, and adds one field you are missing. A screening result is never stored as clear. It is stored as clear against list version X at time T, because the list is somebody else's assertion with its own lag, and a false clear has to be attributable to the list rather than invisible. So I would have the tool emit the advisory id and the range it held at run time, next to the code verdict. When GHSA-x9r9-c232-4q39 gets its range corrected, you can then find every build that was cleared under the old one. Without it you only ever know today's answer.
Where I think it stops working, past the npm case you already name. Line comparison answers whether a release contains a fix. It does not answer whether the path is reachable, which you say yourself about transformers needing a Hub repo you do not control. Better question, still not the real one.
And backports look exactly like the failure. You found the nltk fix shipped outside its advisory range, and you say many releases got the fix as a backport. A maintainer who fixes the same bug with different lines on a stable branch reads as unfixed. In a report that is a false positive. In a merge gate it is worse than one, because the first few teach people to add the override flag, and after that the gate is decoration. I would keep this as a report with the diff attached rather than a pass or a fail, at least until the backport rate is measured.
Thanks Arun, this is a really useful comment.
On backports: agreed, that's the main way this can go wrong, so I measured it. On PyPI, when I only looked at git tags, most "missing fix" results were actually backports. Checking the code instead fixed most of that: a release that has the lines the fix adds is never reported, even if the commit itself isn't there. After that, I still check every result by hand before calling it a finding. Outside Python (Rust, Go, PHP) I checked 20 by hand: 13 held up and 7 didn't. Two of those were merge commits (their diff is a whole branch), one was code that moved to another package, two were cases where the vendor lists the affected versions on purpose, one was a partial fix by design, and one was a stray tag. So yes: it only reports, it never changes the exit code, and I'd keep it that way.
On recording the advisory and range at scan time: good idea. The JSON output already has the advisory ID and the range it read, but not when the advisory was last modified. I'll add that so you can re-check a result when the range gets fixed.
On reachability: that's a separate check (--fix-evidence), and you're right that a version check alone can't tell if your code ever hits the bug.
Shipped in 0.74.0: with --range-check --json, each result now keeps the advisory's published and modified dates as read at scan time. Thanks for the idea.