时兴的静态漏洞挖掘工具
- Amandroid
2014年发表论文,2018发论文更新维护,提出了更多的优化。这个软件主要基于Flowdroid对于图进行更新。相比较于后面的,实际上这个并没有那么流行
有以下特点:
- point-to,做到流敏感,做到上下文敏感
- inter-procedural control flow graph (ICFG),flow and context-sensitive,相比较于Soot构建的ICFG更加精确
- Data Flow Graph (DFG),是由ICFG和ICFG中每一个节点的reaching fact set组成
- 通过DFG构建data dependence graph (DDG)
- ST:summary table,记录component之间的沟通信息(通过RPC等)
- 可以添加插件
2018年提出的更新大多数是在算法上
主要功能点是在inter-component communication上的bug检出率高,相比较于Flowdroid针对每一个app构建一个model,这个软件细化到component层面。通过上述的图,检查出bug,例如用DDG检测是否有信息泄露。
这个软件在构建图上,相比较别的软件,速度更快
但是在例如域敏感上,有调研显示这个软件做得不是很好
ErrorProne
https://storage.googleapis.co...
- 由error-prone接管compiler,在代码编译时进行检查,并抛出错误中断执行
样例:
private void testCollectionIncompatibleType() { Set<Short> set = new HashSet<>(); set.add(Short.valueOf("1")); set.remove(0); }
- set是一个接受Short类型的集合
- 我们想通过类似从List.remove(index)方式删除一个元素
但是Set没有remove(index)方法,有的只是remove(Object)方法,普通编译器不会报错,而error-prone则会发现
error: [CollectionIncompatibleType] Argument '0' should not be passed to this method; its type int is not compatible with its collection's type argument Short set.remove(0); ^ (see http://errorprone.info/bugpattern/CollectionIncompatibleType)
第二个样例
"hello World".getBytes().toString(); error: [ArrayToString] Calling toString on an array does not provide useful information "hello World".getBytes().toString(); ^ (see http://errorprone.info/bugpattern/ArrayToString)
byte[].toString()方法打印没有有用信息
- BugPattern有三种严重程度,如下
ERROR: 如EmptyIf
- WARNING: 如CatchFail,catch这里的结果并不重要
- SUGGESTION:byte[].toString()方法打印没有有用信息
只有ERROR的严重程度才会中断当前的编译,其他情况都会以日志输出形式展现。
显示出来的能力不如SpotBugs,XSS和SQL注入不支持检测,NullPointerException支持检测,例如 x.equals(null) 会报ERROR
现在的检测比较简单,intraprocedural,无dataflow analyze,论文中也没有对算法进行详细的论述
- nullaway
是error prone的一个插件
样例
static void log(Object x) {
System.out.println(x.toString());
}
static void foo() {
log(null);
}
warning: [NullAway] passing @Nullable parameter 'null' where @NonNull is required
log(null);
- Dependency-Check
用来检测java程序的依赖中,是否存在一些已知的CVE漏洞
<entry id="CVE-2012-5055">
...
<vuln:vulnerable-software-list>
<vuln:product>cpe:/a:vmware:springsource_spring_security:3.1.2</vuln:product>
<vuln:product>cpe:/a:vmware:springsource_spring_security:2.0.4</vuln:product>
<vuln:product>cpe:/a:vmware:springsource_spring_security:3.0.1</vuln:product>
</vuln:vulnerable-software-list>
...
</entry>
例如用JarAnalyzer扫描:Manifest, pom.xml, and the package names within the JAR files
记录依赖的开发者、产品、版本,并进行比对,进而找出潜在的CVE漏洞
- SpotBugs
支持SQL注入、XSS检测,是FindBugs的继承者,但是没有找到deserialization
包含的bug种类很全面,从大的漏洞到小的warning
除了control flow graph之外,还用到了
- simple analysis techniques( method names, signatures, class hierarchy)
- state machine
- Find Security Bugs
https://find-sec-bugs.github.io/
是一个spotbugs的插件,添加之后表现比单独使用spotBugs好很多
这两个网上的文章很少,大部分是关于findbugs的
- PMD
https://pmd.github.io/latest/... 支持的bug
在一些论文里,PMD的表现往往很好,但是PMD没有dataflow模块,大多数是依据style进行分析,这也是比较奇怪,通过style匹配就能达到这样的效果
- 同一类的bug,被存在同一个XML里面
- pmd 使用 JavaCC 和 JJTree 生成每种 Java 语言元素的节点表示,随后访问每一个节点
- 支持XSS,SQL不是很确定
infer
https://fbinfer.com/docs/abou...
使用起来的命令行和PMD类似的,同时也支持sql注入和xss
优点是速度快
新技术:
- Separation logic:可以对程序占用的内存分为多个小部分进行分析,而不是每一步都要分析整个内存空间的状态
算法大致看了一下,例如内存被分为两个部分,一部分在此次更新中用到了,另一部分没有用到,那么就只考虑前一部分。
Bi-abduction:对于独立的代码段,如果在更新中这一段的行为没有变化,那么infer将reuse这段代码的行为特征,降低开销。
上述两个或许可以理解为增量分析
其他
java bug集合BugSwarm dataset,这个在论文里用的非常多,比较成熟
java bug集合 defects4j dataset
consists of 15 Java projects with 594 known bugs
https://github.com/analysis-t... java 代码审计工具汇总
参考文献中有用的
https://people.ece.ubc.ca/mju... amdroid
https://dl.acm.org/doi/pdf/10... spotbugs/errorprone
https://dl.acm.org/doi/pdf/10... amandroid
https://dl.acm.org/doi/10.114... defects4j
https://mcours.net/cours/pdf/...
。。。
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。