Strap in, we's going on a ride, a static analysis ride. I recently...

@dcuthbert
Daniel Cuthbert@dcuthbert
12 views Apr 11, 2024 ~4 min read
Advertisement
1
Strap in, we's going on a ride, a static analysis ride. I recently came across this paper, which looked at a wide variety of SAST tools against a number of Java apps.

Java being the choice of enterprise, and often not the best Java approaches out there, so it's a good choice
Media image
2
First up, what did they use and what did they benchmark it against?

They looked at free tools, tools that specifically supported Java and most importantly, are being actively maintained.
Media image
3
The target was the @owasp owasp.org/www-project-be… project, a good choice imho. They also looked for Java apps with bugs with disclosed CVEs which was around 680 programs.

This gives them a fair amount of apps to look at, which is good
4
It's important to state here that there are two types of vulns: synthetic and real-world.

Synthetic vulnerabilities refer to deliberately introduced flaws or weaknesses in software that are designed to mimic real-world vulnerabilities. They 'should' be easier to spot
5
My one concern is that such vulns might not fully capture the complexity, context, or nuances of vulnerabilities found in actual software projects. I do, however, appreciate the need of them in the overall testing process.
6
What became clear was that with all the tools tested, there existed a stark contrast in the effectiveness of tools when shifting from controlled synthetic environments to more complex, real-world scenarios.

Horusec, Contrast and SpotBugs with Find Security Bugs all did well
7
Pero pero, the tools all struggled with with real-world vulnerabilities. This disparity highlights the challenge such tools face in detecting complex, real-world vulnerabilities that are often more nuanced and harder to model than synthetic ones.

contrary to what they say
8
This table is actually incredibly useful. A good SAST tool makes use of rules, and it's the quality of such rules that differentiate the vendors. For example, i dislike closed-source/hidden rules, favoring CodeQL/Semgrep's approach here.
Media image
9
Ideally, looking at that graph, you want to concentrate on recall (actual vulns identified), precision and f1 (combination of the others, which is a single measure of accuracy), this is where the money shot is and Contrast wins here
10
On the topic of synthentic vulns, Contrast and SBwFSB can detect close to all, with F1-score 84.4%, and 82.8%, respectively. CodeQL and SBwFSB may be preferable when the correct classification of CVEs is critical.
Media image
11
However, we operate in the real world and this is where they all struggled. 85% of CVEs were ignored by the tools. Notably, Contrast, the most effective tool according to the OWASP Benchmark, failed to detect all the CVEs in all 4 scenarios.
12
The paper didnt go into how you'd run most of these tools. In an ideal situation, you'd have it running on each save in the IDE, and then as part of a modern CI/CD pipeline. This way you stop vulns being introduced into the pipeline (as best you can) and then have guardrails
13
What you don't want, and this is common with many legacy SAST tools, is them taking a zip of the repo, pushing it to some secondary processing stage and then a mega scan happens. This adds friction to any developer and we do avoid using such tools, because they suck
14
I've been a fan of @semgrep for ages, mostly due to their approach and openness of the rules. The results show that Semgrep is effective in method-level detection of real-world vulnerabilities when CWE class accuracy is not required
15
What is meant by this is when say a tool correctly identifies a vuln in the code but does not necessarily need to classify it correctly according to CWE in order for it to be marked as a win/successful detection
16
Wrapping up, it's clear to me from this paper that we still have a long way to go to properly detect vulnerabilities and bugs are hard. We have a high rate of undetected vulnerabilities and more worryingly, overstatement of detection capabilities
17
If bugs are not your world and passion, then I'd be walking away from this report with the following:

choose your tools well. no single SAST tool excels in all areas, if a vendor says this, they are lying. some are good at synthetic detection but suck at real-world
18
There is no such thing as a single tool that does it all. you need diversity here, as I've hopefully shown from this reports results. They also need constant benchmarking by people who know bugs and the nuances of bugs
19
Tools often claim to detect more than they actually can in practice. It is crucial to have realistic expectations and understand that the claims may not always match actual capabilities. Push your vendors hard, I do not trust a single one and for a reason
20
In light of everyone now offering AI this and AI that, automated tools are not a substitute for expert manual review. They should be seen as complementary to human expertise, especially for complex and nuanced vulnerabilities that automated tools may miss.
21
The full paper can be read over at sen-chen.github.io/img_cs/pdf/fse… and I thank the authors for doing this, it was cool last night to read it and tear it apart
Actions
What You Can Do
  • Export as PDF or Markdown
  • Batch Export to Notion
  • Bookmark & Highlight
  • Screenshot Tweet
Create Free Account

Includes 7-day Premium trial

Advertisement