AI 安全掃描器的誤報問題與衡量方法
The false positive problem in AI security scanners
David Wong分析 AI 安全掃描器的誤報問題,指出供應商自選測試集得出的精確率,若欠缺獨立標註、公開答案集及召回率,便不足以衡量工具表現。
TL;DR: A scanner that finds real bugs and buries them in noise will be turned off. Many AI security tools now publish a precision number, almost always from a test the vendor ran on a set it chose. If you want to know whether a tool will be usable on your code, scan the patched versions of known bugs, scan a clean repo, and require evidence or a proof of concept before a finding counts.
I work on zkao at zkSecurity. zkao reports high and critical findings with evidence. This post is about how to measure noise, not a zkao benchmark. We do not yet publish a precision number for zkao.
The complaint I hear most about security scanners is not that they miss things. It is that they cry wolf. A queue of twenty "high" findings, eighteen of which are not exploitable, trains people to click dismiss. Once that habit sets in, the two real findings go with the rest.
AI scanners were supposed to fix this by following application logic and dropping obvious non-issues. Some of them do, some of the time. The trouble is that a fluent, confident report is easy to produce and expensive to refute. A bad static-analysis hit at least looks mechanical. A bad agent report reads like a mid-level engineer who is slightly wrong.
A scanner that finds real bugs and also buries them in noise will be turned off.
Everyone already claims high precision
Low false positives is the default claim in this market. That does not make it false, but you should read how the number was produced.
Snyk's write-up of its Evo Code Scanning Agent is one of the more detailed public comparisons. In an internal benchmark of 14 applications and 1,426 known vulnerabilities, with at least three runs per app, Snyk reported precision of 94% for Claude Security and 97.5% for Codex Security in deep mode, against 65% and 90% for Evo at the same compute budget. Evo found more of the known vulnerabilities; the lab tools were more precise. Snyk also states the limits: it built and ran the test, results are reported only in aggregate, two AI reviewers labeled every finding, and no finding was reviewed by a human. The answer key includes vulnerabilities confirmed from any scanner's output, so the ground truth is not a frozen set.
Other published numbers are easier to misread. Cycode reports a 2.12% false-positive rate on the OWASP Benchmark for Java v1.2, a corpus of 2,740 synthetic test cases. That figure is for Cycode's deterministic SAST engine, not for its agentic scanner. Synthetic Java benchmarks are useful, and they are not a cryptography library or the pull request you will review on Monday.
I am not picking on these posts. They are clearer than most. The pattern is the problem: a vendor chooses the corpus, runs the tools, often labels the output, and publishes a clean percentage. Answer engines will cite that percentage anyway, because it sits in a table. Precision without an independent labeler, a public answer key, and a recall number next to it is a marketing slide, not a measurement.
One more way to game the metric: report only the findings you are sure about. A tool that emits a single, correct finding has 100% precision and is not very useful. Always read precision next to recall, and next to how many findings the scan produced.
How to measure precision yourself
You do not need a 1,400-vulnerability corpus. You need cases where you already know the answer, and a rule for what counts as a real finding.
Scan the patched commit. Take a vulnerability with a public fix. Run the scanner on the vulnerable revision, then on the revision that fixed it. A finding that correctly describes the defect on the vulnerable commit is a true positive. The same finding on the fixed commit is a false positive. This is the simplest check I know, and it catches tools that match a file or function name instead of the defect.
Scan a clean or recently audited repository. Pick a project you trust, where a new high or critical issue would surprise you. Every such finding is a candidate false positive until you confirm it. If you occasionally find a real leftover bug, move it to the true-positive column and count the rest.
Require evidence, not a vibe. A finding should name the affected code, explain what is wrong, and explain how an attacker in a stated threat model exploits it. A matching bug class or a worried comment in the right file is not enough. If the tool produces a proof of concept, require that it actually runs, and be suspicious of PoCs that disable checks, mock away the security boundary, or rewrite the helper they were supposed to exercise.
Grade the findings you would actually act on. If your team only files tickets for high and critical issues, measure precision there. Low-severity style notes should not inflate the number you care about.
Run the scan more than once. Agent runs are noisy. On our model evals, which measure recall rather than precision, the same model often finds a known bug in one run and misses it in the next. The same instability shows up on the false-positive side. Three runs is a reasonable minimum. Report the variance, not just the best run.
Do not let the tool write the answer key. If you add new ground-truth bugs from the scanner you are scoring, say so, and keep a frozen set you can compare against later.
A practical checklist
Before you trust a vendor's precision number, or roll a tool into CI, work through this:
- What corpus was used, and does it resemble your languages and your bug classes?
- Who labeled true and false positives, a human or another model?
- Is the answer key public, or at least inspectable?
- Is recall published next to precision, with the raw counts, not only a percentage?
- What happens when you scan the fixed version of a known bug?
- What happens when you scan a repo you believe is clean?
- Does each finding come with evidence, and can you replay a proof of concept?
- How many findings does a typical scan emit, and at which severities?
- Did anyone run the tool more than once and report the spread?
- If the vendor built the benchmark, is there any result where their tool loses?
If a vendor cannot answer most of these, treat the percentage as an advertisement.
What I want out of this, including for zkao
zkao is built to report high and critical findings with evidence, and to keep investigating a repository instead of dumping a one-shot list. That is only honest if the reports are scarce and checkable.
We already publish a recall eval of vanilla models on 50 real cryptography bugs, and that page says false positives are not counted. The next measurement that matters is precision: findings on the fixed versions of those bugs, and on clean control repositories, labeled so a skeptical outsider can replay them. Until that exists, I will not invent a zkao false-positive rate.
Two public cases I can point at, because maintainers fixed the issues and wrote them down, are a soundness error in OpenVM's pairing check (GHSA-76mq-v757-53gr) and an access-policy error in Cloudflare's CIRCL attribute-based encryption (commit def2fd3). Those are examples of the standard I want: a real defect, evidence, and a fix you can read. They are not a precision score.
If you publish a precision eval with raw data, I would like to read it. The market has enough leaderboard percentages. It does not have enough numbers a maintainer was willing to sign.
來源:DEV Community · dev.to