Skip to content

Case notes.

Eight CVEs, flagged at the commit that introduced them

David Baker Effendi5 min read

Written by
David Baker Effendi
Published
By email
Subscribe

One way I like to test if SlopCop is a serious tool is to look at recent CVEs, most of them rated high or critical, and determine if SlopCop would be able to flag the commit that introduced the consequential bug.

The vulnerable code may have been missed during a code review, approved, and exploited months or years later. So the gist of this post describes the experiment: "if SlopCop was around then, could the CVE have been prevented?"

So this is how the experiment went: Look at a recent advisory that reports a specific commit or commits with vulnerable lines, replay that commit, and run slopcop check on the change. This is how SlopCop would be used if the change was introduced as a pull request or stop hook in a coding harness for an agent.

This post covers our experiment across 8 advisories spanning 7 repositories:

Table of eight advisories in seven projects, with each project's language and the line SlopCop flagged. Five pattern-match rows in TypeScript and Python are followed by two typestate rows in Java.
The commits were ordinary ones. The smallest touched a single file and the largest 58.

The easy findings

The first five rows, covering six advisories, are all from basic pattern matching rules. They come from only two kinds of rules: One flags code that evaluates a string as a program. The other flags a file or directory opened up to every user on the machine. Both look at one line and decide.

These are the kinds of rules any basic linter could flag... not just SlopCop.

This experiment does, however, show that evaluating (attacker-controlled) input as code shipped in four maintained projects: three calls to eval and one new Function. Two of them sat in the code for thirteen years before their advisory. A check that runs on every change would have put a warning on each line before the merge.

A rule that flags every use of eval is not very exciting, and the rule can be very noisy. Sometimes this noise can make a human reviewer complacent. For example, the Xinference line is worth a second look. Passing empty globals and locals to eval looks like a sandbox. It is not, and that is the kind of thing a tired reviewer accepts.

You bet I'd say something like "an agent doesn't get tired", because yes, they don't. Any agentic reviewer would probably have picked this up - it's like OWASP top 10 stuff. Whether the fix was actionable within the scope of that review is a separate conversation.

The more hardcore findings

The last two findings are marked "typestate" findings. This combines tracking program data flow with the state of the data or variable. A little more complicated for your average linter, but the kind of elaborate thing I felt like we needed to develop to become relevant.

Looking at the OpenNLP code:

try (ObjectInputStream ois = new ObjectInputStream(in)) {
  return (SvmDoccatModel) ois.readObject();
}

This is your typical try-with-resources kind of ObjectInputStream initialization and, while reading objects from streams in Java is a well-known source of trouble (see a past talk on deserialization vulnerabilities). People do this all the time and it can be safe.

However, this wasn't one of those times.

If you're going to choose this over any other of the safer ways to deserialize objects, you would ideally initialize the stream with a class filter. This is so that you only deserialize trusted classes/types.

In the above code, an object was read before a filter was applied, and the class cast only happens after the object was read in. This results in any serializable class on the class path to be deserialized, and if this input is attacker-controlled, can result in a gadget chain being executed.

A normal pattern match, or taint tracking for that matter, couldn't precisely tell this apart from a safe one:

ObjectInputStream ois = new ObjectInputStream(in);
ois.setObjectInputFilter(filter);
return ois.readObject();

This is because the two differ only in the order of calls: setObjectInputFilter has to run on the same stream before its first readObject.

To separate the two, a check has to follow one object through the method and know what state it is in at each call. That is typestate analysis.

The rule for this finding describes the stream as a small state machine: it starts unfiltered, setObjectInputFilter moves it to filtered, and a read while it is still unfiltered is the error. Bifrost, the analyzer behind SlopCop, then tracks each stream the change creates.

It flagged both readObject() calls in the JDBC wrapper and the one in OpenNLP, and it stays quiet on the filtered version.

Two things you should know about these two findings:

The rules are open-source

Every finding above came from a rule in the open Bifrost packs. You can read each one and run it yourself. We build the packs from leads on OSV.dev: when a kind of bug keeps turning into advisories, it becomes a rule.

There is no AI model in this path. A rule is a deterministic analysis of the code, so it gives the same answer every time, and it cannot have memorised these advisories.

Of course, we do recommend using SlopCop, which provides a hosted service to run the static analysis on and synchronize static and agentic findings with everyone on your team. Another reason is that typestate analysis has a tendency to blow up resources, so our 48 GB RAM AWS worker should have you covered on that!

What it did not flag

We tried fourteen advisories and six came back with nothing. We would rather say so than show you only the hits. SlopCop is still in development after all!

Some checks reported only the vulnerable line. Others reported it next to lower-severity quality notes, such as missing documentation, in the same files.

We review finding acceptance rates to fine-tune our rules and program analysis to ensure high-quality findings and precision.

In conclusion

Most of these bugs are not subtle. eval on input has been on every security checklist for twenty years, and deserializing untrusted bytes for nearly as long.

They still shipped, and still pop up on advisories. More code is being written faster than ever, much of it by agents, and review has not sped up to match.

A check that runs on every change does not get tired.

Try it

Run slopcop check on your change before you push it.

To run the deserialization rule on a Java change and see less certain findings:

slopcop check --certainty all --policy-id bifrost.security.java.objectinputstream-read-without-filter

Keep reading