Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
How PVS-Studio for Java scored 77%...

How PVS-Studio for Java scored 77% on the OWASP Benchmark

Nov 27 2026

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.

What is the OWASP Benchmark?

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:

  • A set of Java files containing known vulnerabilities (SQLi, XSS, Path Traversal, the use of weak encryption algorithms, and others).
  • A matching set of files with negative cases to check that the analyzer reports issues only where it should and doesn't produce false positives.
  • A utility that automatically evaluates a generated SARIF report and builds a coverage table showing the results (TP, FP, overall score).

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.

Getting started

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:

  • OWASP uses a configuration for an older version of Java, which doesn't work particularly well with the JDT compiler that underlies our analyzer.
  • Some methods and classes lacked annotations that help the analyzer understand the code it's analyzing. In this case, the annotations identify sources of tainted data. Unfortunately, we sometimes miss parts of the standard library or popular third-party libraries when adding annotations. Here, the outdated API made things even worse. For cases like this, among other things, we provide a way to add user annotations.
  • The analyzer's default settings were too conservative, a result of our approach to general analysis. It often prioritizes minimizing false positives. With SAST, however, the priorities are different, as our C++ colleagues have also noted in their article.

The analysis engine really did need several improvements:

  • Dead code elimination. The analyzer produced many false positives on code that could never be executed.
  • More precise collection analysis. Previously, once external data entered a collection, we treated the entire collection as tainted. We needed to take this a step further and track taint at the level of individual elements.

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.

Analyzer enhancements

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.

New diagnostic rules

There were a few rules the analyzer didn't have yet, so we added them:

  • V5341. OWASP. A cookie was created without enabling the 'Secure' attribute. This may lead to the exposure of sensitive data.
  • V5342. OWASP. Potentially tainted data is stored in an object that can be used as a source of trusted data.
  • V5343. OWASP. A cryptographically weak random number is used for sensitive data.

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.

Dead code elimination

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

BenchmarkTest00105.java:69

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.

Working with collections

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

BenchmarkTest00113.java:66

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:

  • Heap abstraction. This is a fairly broad topic in static analysis. Previously, we could treat a collection as just another variable within a method. Now we needed to distinguish between its individual elements. To do that, we introduced a model of the relevant memory regions.
  • k-limiting. Collections can contain other collections, which can contain objects, which can in turn contain more collections, and so on. Tracking all this state would be extremely expensive and, in some cases, impossible. A common way to address this problem is k-limiting: restricting the nesting depth to a fixed constant, k. In our case, we set this limit to four levels.
  • Reverse postorder. In the article mentioned above, I explained that our taint analysis runs from the end of the control flow graph to the beginning. This meant we also had to learn to compute values in reverse order. The tricky part is that we start by assuming the collection may contain any value, even though we don't yet know its actual contents. The advantage is that this approach reduces the number of repeated computations since it's closely related to topological sorting.

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.

Final results

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:

  • PVS-Studio on X;
  • our monthly article digest;
  • Author's personal blog.
Subscribe to the newsletter
Want to receive a monthly digest of the most interesting articles and news? Subscribe!
Popular related articles

Comments (0)

Next comments next comments
close comment form