How well does PVS-Studio for Java detect security defects? We put it to the test using the OWASP Benchmark, an independent test suite designed to evaluate SAST tools. Read on to see how PVS-Studio performed, what the results revealed, and which enhancements we made to the analyzer along the way.

OWASP is a community focused on application security. One of its projects, OWASP Benchmark, is an independent test suite for evaluating how effective vulnerability detection tools are, SAST analyzers among them.
A test like this is particularly useful. We have claimed that PVS-Studio detects vulnerabilities in 9 of the 10 OWASP Top Ten categories (another OWASP project that lists the 10 most common types of security risks to web applications). However, it's hard for an outside observer to verify this claim without running tests themselves.
With Java, we got lucky. Unlike many other programming languages, Java has its own independent OWASP benchmark in the form of a dedicated application, complete with everything needed for testing:
Our support team has been asked about our benchmark results from time to time, so it was only a matter of time before we ran the tests ourselves.
Now we have the results: PVS-Studio 8.02 performed strongly, outperforming open-source tools and is close to the performance of other commercial analyzers.

Read on to learn what it took to achieve these results and how we improved the analyzer along the way.
Our first benchmark run did not go well. But the numbers don't tell the whole story. Let's start by looking at PVS-Studio 8.00's score:

For comparison, here is the result for the free FBwFindSecBugs v1.4.6:

The comparison was disappointing, to put it mildly. The analyzer engine was only part of the problem (more on that below). A few smaller issues also dragged down the score significantly:
The analysis engine really did need several improvements:
We also identified several security issues that weren't yet covered by the analyzer's diagnostic rules. We'll cover those and the improvements to the analysis engine in the next sections.
We were able to close these smaller gaps fairly quickly. The entire process took just a couple of weeks. We added an extra configuration setting and adjusted the reporting threshold to favor reporting a warning unless the analyzer could rule out a vulnerability.
There were a few rules the analyzer didn't have yet, so we added them:
They map to three OWASP Top Ten 2025 categories:
This also helped us identify areas where we could expand the analyzer's coverage of the OWASP ASVS standard and detect more vulnerabilities covered by the OWASP Top Ten 2025.
Next, we turned to improvements to the analysis engine. Let's start with a simple example:
var a = 5;
var b = a * 2;
if (b > 10) {
// SQLi
}
Execution will never reach // SQLi, because b equals 10, which is not greater than 10. The analyzer used to issue an SQL injection warning here.
The OWASP test suite also showed us a different kind of case:
int num = 106;
bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param;
String sql
= "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
// sqli
The example is still contrived, but it challenged our assumption that reporting a vulnerability was justified simply because potentially dangerous code was present. We'd encountered this kind of test more than once, so we decided it was time to address the issue.
Fortunately, the technique we needed had been around for a long time: conditional constant propagation. In simple terms, before analyzing the code, we need to calculate and keep track of values that can be determined at compile time. In our first example, these include:
a, which equals 5;b, which equals 10;b > 10, which evaluates to false.It's called propagation because we don't just calculate 2 * 5. We also need to remember the values we've already computed so they can be used in subsequent calculations. For example, we need to retain the value of a to calculate b. And it's conditional because we evaluate conditions as well.
We calculate all these values using the familiar worklist algorithm, which iteratively updates the values in a method until they stop changing (that is, until a fixed point is reached).
Once we have these values, we can simply remove unreachable branches from the control flow graph (I covered CFG in an earlier article on SAST, and recently wrote adding it to our JavaScript/TypeScript analyzer). The analyzer can then proceed with its usual analysis, without reporting vulnerabilities in code that can never execute.
These improvements have been available since PVS-Studio 8.01. Here's how the results looked at the time of its release:

As we can see, the score improved substantially, with the overall Score surpassing that of FindSecBugs mentioned above. We were still slightly behind some of our competitors, though, so there was more work to do.
At that point, we still had a few individual cases to address and some engine bugs to fix. Since we hadn't previously calculated values across the control flow graph, we hadn't noticed some inaccuracies in its representation, such as the incorrect handling of ternary operators. Also, resolving the most challenging issue took quite a bit longer. That's what we'll look at next.
Let's look at one of the benchmark tests:
String bar = "safe!";
HashMap<String, Object> map21657 = new java.util.HashMap<String, Object>();
map21657.put("keyA-21657", "a_Value"); // put some stuff in the collection
map21657.put("keyB-21657", param); // put it in a collection
map21657.put("keyC", "another_Value"); // put some stuff in the collection
bar = (String) map21657.get("keyB-21657"); // get it back out
bar = (String) map21657.get("keyA-21657"); // get safe value back out
String sql
= "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')";
// sqli
Here, param is tainted data received from a cookie. It never makes it into the sql string, though.
To handle cases like this, we had to extend the engine with several new techniques and improve existing ones:
Implementing these techniques took the most time. We had to deal with problems that surfaced along the way, too, fit everything into the existing engine, and work through the complexity of the approach itself. In the end, though, we made collection analysis more precise and eliminated a whole range of false positives.
Collection analysis and other minor fixes will ship in the PVS-Studio 8.02 release, due in a few weeks. Here are the latest results, once again:

Over the course of two to three months, we managed to improve our score from 18% to 77%, achieving results comparable to those of established commercial SAST tools. This benchmark gave us an opportunity to put the analyzer to the test, identify its weaknesses, and improve its detection capabilities. And the results speak for themselves.
You can always find the latest OWASP Benchmark coverage data on the corresponding page of our website. It provides more details about our testing methodology and explains how to verify the results yourself.
That's all from me for now. If you'd like to read more about programming and static analysis, you can follow us or subscribe here:
0