Soundiness
Soundiness是五年前的概念,学者们发现程序分析用于实际的现代语言中仍存在各种问题,这些问题是难以分析的语言特性导致的,因此提出Soundiness,说明如何处理这些难解的问题。
Hard features
Hard-to-analyze features: an aggressively conservative treatment to these features will likely make the analysis too imprecise to scale,rendering the analysis useless.
例如:
- Java
- Reflection,native code,dynamic class loading,…
- JavaScript
- eval,DOM(document object model),…
- C/C++
- 指针操作,函数指针,…
因为这些原因,实际上:
学术界所有技术应用于实际语言时都有unsound的情况;
工业界所有扫描器都必须接受unsound的结果。
这造成如下结果:
- 大多数学术工作宣称sound,但是由于这些特性实际不是sound的;
- 大部分工作不说如何处理hard,或者在实现章节等不起眼的部分简单介绍(off-hand manner);
- 这些hard分析会对分析结果造成巨大影响,如java反射;
- 对于非专家的读者,他们误以为别人论文都是sound的;
- 对专家,由于不了解 hard features 如何处理,很难判断分析精度。
Soundiness
最终,在2015年,十位PL的顶级专家联合宣言[1],呼吁学者们在今后论文里明确说明对hard feature的处理方式,捍卫Soundiness。
Soundiness词根来源于soundy:
A soundy analysis typically means that the analysis ismostly sound, with well-identified unsound treatments to hard/specific language features.
灵感来源于Truthiness,意思让人信以为真,却没有事实证明的理论。
Soundness, Soundiness and Unsoundness
- Soundness: 一个 sound 的分析可以考虑到所有的程序运行时行为;
- Soundiness:一个 soundiness 的分析对于程序 hard features 有一定合理的处理,绝大情况下是sound的;
- Unsoundness:方法设计中为追求速度、通用性等忽略sound的分析。
Reflection
反射是Java的动态特性,只有运行时才可知具体类。
String Constant Analysis + Pointer Analysis
Livshits[2] 等人使用字符串常量分析和指针分析获取反射的具体值,但是对于配置文件、网络、用户输出等复杂情况仍然具有局限性。
Type Inference + String analysis + Pointer Analysis
Li[3]等人(就是老师Orz)通过调用参数的类型、字符串分析和指针分析获取反射的具体值,即虽然在反射点无法解析类,但是通过使用时的特征可以推导原函数,在实验中,工具推导出50个目标的目标函数,其中48个是真实的。
他们的后继工作[4] 是目前最先进的反射处理方式:
Assisted by Dynamic Analysis
Bodden[5] 等人提出借助于测试用例动态运行程序,能解出真实的反射结果,这一类工作实际上成为最为常用的工作。
Native Language
JNI
Java通过JNI接口调用C/C++程序:
Solution
主要方法是手动建模,将JNI函数转化为java代码,再转化为分析规则
Fourtounis[6]等人将一些java的native函数还原成模型。
其他
其他与Soundiness的工作:http://soundiness.org/
References
- Livshits B, Sridharan M, Smaragdakis Y, et al. In defense of soundiness: a manifesto[J]. Communications of the ACM, 2015, 58(2): 44-46.
- Livshits B, Whaley J, Lam M S. Reflection analysis for Java[C]//Asian Symposium on Programming Languages and Systems. Springer, Berlin, Heidelberg, 2005: 139-160.
- Li Y, Tan T, Sui Y, et al. Self-inferencing reflection resolution for Java[C]//European Conference on Object-Oriented Programming. Springer, Berlin, Heidelberg, 2014: 27-53.
- Li Y, Tan T, Xue J. Understanding and analyzing java reflection[J]. ACM Transactions on Software Engineering and Methodology (TOSEM), 2019, 28(2): 1-50.
- Bodden E, Sewe A, Sinschek J, et al. Taming reflection: Aiding static analysis in the presence of reflection and custom class loaders[C]//2011 33rd International Conference on Software Engineering (ICSE). IEEE, 2011: 241-250.
- Fourtounis G, Triantafyllou L, Smaragdakis Y. Identifying Java calls in native code via binary scanning[C]//Proceedings of the 29th ACM SIGSOFT International Symposium on Software Testing and Analysis. 2020: 388-400.