[清华大学]漏洞挖掘之状态敏感的模糊测试StateFuzz

news2024/10/2 16:22:06

Dr.赵博栋 Prof.张超 清华大学 网络研究院 INSC
本文主要介绍了通过State Fuzz对Linux驱动程序进行模糊测试,该Fuzz方法由赵博栋博士在InForSec会议上分享,并在USENIX Security上发布.StateFuzz :System Call-Based State-Aware Linux Driver Fuzzing.该篇文章主要介绍了核心方法,为展示测试数据与实验展望.
在这里插入图片描述

前言:

模糊测试是当前主流的漏洞挖掘方法,近年来发现了大量的未知漏洞,受到工业界和学术界的广泛关注。其中,以代码覆盖率为进化指标的灰盒测试方案得到大量研究,衍生出了大量优化改进方案。但是,代码覆盖率与漏洞之间存在gap,提高代码覆盖率不一定能够有效发现潜在的安全漏洞。提出了状态敏感的模糊测试方法StateFuzz (USENIX’22),引入了程序状态作为进化指标,实验结果表明了该方法的有效性,在Linux和Android驱动中发现了数十个未知漏洞。本次报告将与大家探讨这一方案。

背景

漏洞:网络空间重要安全威胁

重要事件:乌克兰断电事件 震网病毒事件 WannaCry HeartBleed(websites) Aurora(Google)

漏洞:网络攻击的突破口

制导部分(漏洞) 战斗部分(漏洞利用) 控制部分(恶意代码)

美国军火商Lockheed-Martin提出的"杀伤链"

  • Reconnaissance 目标侦查 (漏洞挖掘
    Research,identification,and selection of targets

  • Weaponization 武器定制 (漏洞利用
    Pairing remote access malware with exploit into a
    deliverable payload(e.g.Adobe PDF and Microsoft Office files)

  • Delivery 武器投放(主动/被动)
    Transmission of weapon to target(e.g. via email attachments websites,r USB drivers)

  • Exploitation 武器生效(漏洞触发与劫持)

    Once delivered,the weapon’s code is triggered,exploiting vulnerable applications or systems.

  • Installation 持久驻留(恶意代码

    The weapon installs a backdoor on a target’s system allowing persistent access.

  • Command & Control 远程控制(僵尸网络)

    Outside server communicates with the weapons providing "hands on keyboard access"inside the

    target’s network.

  • Actions on Objective 最终行动(窃密/破坏/跳板)

    The attacker works to achieve the objective of the intrusion,which can include exfiltration or destruction of data,or intrusion of another target.

漏洞与漏洞利用

漏洞挖掘与漏洞利用生成本质上都是输入空间搜素问题
输入样本空间 -> 漏洞Poc样本空间 -> 目标(软件、硬件、网络)
漏洞示例CVE-2009-4270

int outprintf(const char *fmt,...)
{
  int count;char buf[1024];va_list args;
  va_start(args,fmt);
  count = vsprintf(buf,fmt,args);
  outwrite(buf,count);//print out
}
int main(int argc,char* argv[])
{
  const char *arg;
  while((arg = *argv++)!=0){
    switch(arg[0]){
      case '-':{
        switch(arg[1]){
          case 0;
          default:
              outprintf("unknown switch %s\n",arg[1]);
            }
          }
          default:...
        }
        ...

count = vsprintf(buf,fmt,args);没有对内存拷贝长度进行限制,造成了栈溢出问题
Vul trigger conditions:

  • Path constraints 路径约束
  • Vul constraints 漏洞约束
    Discover vulnerabilities:
  • Symbolic execution 符号执行
  • Fuzzing(testing) 模糊测试
    基于代码覆盖率的Fuzzing更擅长解决Path constraints,

漏洞挖掘技术概览

漏洞挖掘技术发展历史

第一阶段(1960s-1970s):人工审核(依赖经验、无法扩展) -> 源代码审计、逆向工程、经验规则
第二阶段(1970s-1990s):规则扫描(误报高/可扩展性差) -> 静态分析、符号执行、模型检验
第三阶段(1990s-2013s):动态测试(漏报高、覆盖率低) -> 随机畸形测试例,模拟攻击者攻击输入
第四阶段(2013s-2023s):智能挖掘(智能进化) -> 知识与数据驱动,遗传进化算法

第二代方案:规则扫描 静态分析(SAST)

  • 基于经验规则静态扫描

优点:速度快
缺点:误报高、无法输出poc验证脚本
瓶颈:不可判定(rice定理)

第三代方案:动态测试 DAST、IAST

  • 基于动态信息的漏洞挖掘

优点:误报低
缺点:覆盖率低,漏报高
工业化产品:OWASP BURPSUITE VERACODE

第三代方案:模糊测试(fuzzing)

  • Fuzzing 模糊测试

生成/变异测试例,测试,检查,重复…
Generator/Mutator -> inputs -> monitor(target program) -> Security violation? -> bugs

  • 科学问题/挑战:

在无穷的输入空间中,如何高校搜素有限的漏洞样本?

Fuzzing 1:Generation-based

基于模块生成测试用例(e.g. grammar,specification)

优点: valid inputs,more code coverage
缺点: hard to setup,requires input knowledge(human efforts)
工业界应用:peach bstorm

Fuzzing 2:Mutation-based

变异旧测试用例来生成新的测试用例

优点:easy to setup,no prior knowledge required
缺点:invalid inputs,limited code coverage(checksum,magic number etc.)
工业界应用:Google OSS-Fuzz Micorsoft Project OneFuzz

第四代方案:智能模糊测试

目前学术界的探索方向:
广度:支持不同类型的目标软件
模糊测试系统应用到目标软件里面。
深度:提升种子生成、变异、测试效率
主要在种子变异和种子挑选环节进行方法优化。

提供较好的初始种子测试例 -> 种子池挑选种子 -> 种子变异 ->能量分配(变异次数) -> 新测试例 -> 测试执行(覆盖率跟踪/安全监控)
主要思想是优胜劣汰的方法,覆盖率跟踪使用遗传算法实现,得到的测试例覆盖率如果得到提升(进化),将会被筛选出作为种子放入种子池中。

VUL337 课题组漏洞挖掘研究成果

广度探索:

  • 固件/硬件 IOT 芯片 Bios/TEE
  • 内核/驱动 Windows MacOS Linux
  • 系统软件 浏览器 hypervisor SGX/TEE应用
  • 用户态软件 代码库 二进制程序 GUI程序
  • 区块链 符号执行 智能合约 DeFi
  • 网络设备/协议 网络服务 5G、路由器 网联车
    深度探索:
  • 种子生成 > 自动/智能 输入格式识别
  • 种子排序挑选 > 自动/智能程序语义理解
  • 种子变异
  • 测试性能优化 > 并行化、硬件协同
  • 进化信号跟踪 > 精确、轻量化
  • 进化策略 > 代码覆盖率、状态制导
  • 安全违例检测 > 定向挖掘、瓶颈爆破

状态敏感模糊测试USENIX 2022

Code Coverage - Limitation

  • Example:maze game

most code can be explored easily
no guidance to trigger the bug
State:values of maze[y][x]

while(true){
  ox=x; oy=y;

  switch(input[i]) {
    case: 'W': y--;break;
    case: 'S': y+=;break;
    case: 'A': x--;break;
    case: 'D': x+=;break;
      }
  if (maze[y][x]=='#'){Bug();}
  //If target is blocked,do not advance.
  if (maze[y][x] != ' '){x = ox; y =oy;}
}
  • Another Example:DNN testing

most (Python) code can be explored easily
State:output of neurons(activated or not)

StateFuzz:State-aware Fuzzing

  • Intuition:guide fuzzers to explore more program states
    我们通过引导模糊测试,去探索更多的程序状态(Program State)。
    Program State:A combination of Register values and Memory values.
    所有寄存器的值和内存的值的组合。
    问题:如何去跟踪这样庞大的组合?
  • Intuition: guide fuzzers to explore more program states
  • Need to answer 3 quesions

Q1: what are appropriate program states?如何定义一个确认的程序状态?
Q2: how to recognize and track program states?如何识别与跟踪程序状态?
Q3: how to guide fuzzers to explore program states?如何去引导模糊测试?

Q1:What are program states?

  • Values of all memory and registers?

the number of such states is overwhelmingly large
hard to track in practice

  • Manual annotation:

human efforts needed

  • Protocal status code:

not always available

  • Using variables to represent states is very common
    使用变量来标识状态,我们也可以通过变量作为我们的程序状态。
  • Ideally,a state is a combination of all program variables(including memory and register values)

state explodsion!

  • Practically,states will persist across interaction boundaries,which will be read by an interaction,and
    written another interaction.

have a long life time
can be updated(i.e… state transition)by users
can affect the program’s control flow or memory access
Ex:FTP Server Program
User -> Pass Packet / User Packet -> FTP Server

int ftpUSER(PFTPCONTEXT context,const char *params);
int ftpPASS(PFTPCONTEXT context,const char *params);

Ex:the variable context -> Access is shared by the Pass and List request

int ftpLIST(PFTPCONTEXT context,const char *params){
  if (context->Access == FTP ACCESS_NOT_LOGGED_IN)
    return sendstring(context,error530);
}
int ftpPASS(PFCONTEXT context,const char *params){
  ...
  if (strcasecmp(temptext,"admin")==0){
    context->Access = FTP_ACCESS_FULL;
  }
}

Q2:How to track states?

  • Step1:Recognize State Variables(varialbes shared by different user actions)

    step 1.1:recognize user actions 识别状态变量

    • interaces that could be accessed by users

    step 1.2:recognize variables accessed by actions

    • read/write variables

    step 1.3:intersection of actions’ variable

    • read by one action,and write by the other action
  • Example:the Maze game

    variables read by action ‘w’:LVMap[‘w’]={y}
    variables written by action ‘s’:SVMap[‘s’]={y}
    State variable set V=V U (LVMap[‘w’] 交 SVMap[‘s’])

while(true){
  ox=x; oy=y;

  switch(input[i]) {
    case: 'W': y--;break;
    case: 'S': y+=;break;
    case: 'A': x--;break;
    case: 'D': x+=;break;
      }
  if (maze[y][x]=='#'){Bug();}
  //If target is blocked,do not advance.
  if (maze[y][x] != ' '){x = ox; y =oy;}
}
  • Step2:Calculate and track states(a combination of all state variables)

how?

Recall:How does AFL track code coverage?

  • coverage = combinations of code blocks
  • But number of combinations is too large.

Instution:state coverage = combinations of state-variables’ values.

Analyze the value ranges of each state-variable

  • e.g. (MIN,0],[0,4],(4,10],(10.MAX))
    跟踪变量的值域范围,而不是跟踪某一个值.
    We identify value ranges by solving constrains of condition statements.
    But the value set of each state-variables is too large,which causes edge explosion.

通过判断变量是否影响相同的程序控制流,对变量进行组合.
The combination of two relevant state-variables values.
Both variables affect the same control-flow path or memory accessing.

if (x<0)
  ...
else if(x<=4)
  ...
else 
  ...

Q3:How to explore program sates?

遗传算法,使用代码覆盖率作为反馈Check Feedback.我们将状态变量的值域也作为遗传算法的指标.

  • Based on existing genetic algorithm

    which relies only on code coverage feedback currently

    • Our solution: 3-dimension feedback machanism
  • A test case is interesting,if it

discovers new code
discovers new value ranges of state variables
discover new extremum values of state variables

StateFuzz:Implementation

1.Kernel Source code -> Program State Recognition(Static Analysis静态分析->State-variable List状态变量集合->Static Symbolic Execution静态符号执行->提取约束条件State-Variable Value Ranges)
2.Instrumentation(State-variable Tracking Instrumentation &Code Coverage Instrumentation->Instrumented Kernel内核插桩)
3.Fuzzing Loop(根据代码插桩情况选择如何保留种子Seed Preservation -> Seed Selection ->Mutation)

具体实现细节

  • State Recognition

    DIFUZE(for program action recognition)
    CRIX(for building call graph)
    Clang Static Analyzer(for static symbolic execution)

  • Instrumentation

    LLVM Sancov
    SVF

  • Fuzzing loop

    Syzkaller

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1089406.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

国际通用的Bug管理工具推荐:多款工具助力项目开发与管理

国际通用的bug管理工具有&#xff1a;1、Zoho Projects&#xff1b;2、Tracup&#xff1b;3、Bugtags&#xff1b;4、QC(QualityCenter)&#xff1b;5、Bugzilla&#xff1b;6、EasyBUG&#xff1b;7、Mantis&#xff1b;8、WebIssues。Zoho Projects拥有专业的缺陷管理模块&am…

Webmin(CVE-2019-15107)远程命令执行漏洞复现

漏洞编号 CVE-2019-15107 webmin介绍 什么是webmin Webmin是目前功能最强大的基于Web的Unix系统管理工具。管理员通过浏览器访问Webmin的各种管理功能并完成相应的管理动作http://www.webmin.com/Webmin 是一个用 Perl 编写的基于浏览器的管理应用程序。是一个基于Web的界面…

项目管理必备工具推荐:提高效率、协作与跟踪的实用工具盘点

如果你是一个项目经理&#xff0c;你就会明白拥有合适的工具的重要性。如果没有正确的工具&#xff0c;将很难保持项目的组织和正常运行。幸运的是&#xff0c;有许多可用的项目管理工具可以帮助您提高项目的生产力和效率。这些工具旨在简化项目管理过程&#xff0c;使您更容易…

MySQL使用函数、存储过程实现:向数据表快速插入大量测试数据

实现数据表快速插入20W测试数据 实现过程创建表开启允许创建函数生成随机字符串生成随机整数生成随机地址创建存储过程调用存储过程查看插入数据 其他实用函数生成随机浮点数生成随机日期时间生成随机布尔值生成随机姓名生成随机手机号码生成随机邮箱地址生成随机IP地址生成随机…

【代码随想录】算法训练营 第二天 第一章 数组 Part 2

977. 有序数组的平方 题目 暴力解法 思路 原地更新所有数组元素为其平方数后&#xff0c;再使用sort函数排序&#xff0c;对vector使用sort函数时&#xff0c;两个参数分别是vector的起始元素和终止元素。 代码 class Solution { public:vector<int> sortedSquares(…

Linux shell编程学习笔记11:关系运算

Linux Shell 脚本编程和其他编程语言一样&#xff0c;支持算数、关系、布尔、字符串、文件测试等多种运算。前面几节我们研究了 Linux shell编程 中的 字符串运算 和 算术运算&#xff0c;今天我们来研究 Linux shell编程中的的关系运算。 一、关系运算符功能说明 运算符说明…

LeetCode34 在排序数组中寻找元素的第一个和最后一个位置

题目&#xff1a; 思路&#xff1a; https://blog.csdn.net/wangjiaqi333/article/details/124526112 直观的思路肯定是从前往后遍历一遍。用两个变量记录第一次和最后一次遇见target的下标&#xff0c;但这个方法的时间复杂度为O(n)&#xff0c;没有利用到数组升序排列的条件…

50 二叉树中的最大路径和

二叉树中的最大路径和 题解1 DFS 二叉树中的 路径被定义为一条节点序列&#xff0c;序列中每对相邻节点之间都存在一条边。同一个节点在一条路径序列中 至多出现一次。该路径 至少包含一个节点&#xff0c;且不一定经过根节点。 路径和 是路径中各节点值的总和。 给你一个二…

Spring中PointcutAdvisor和IntroductionAdvisor梳理

一、Advisor Advisor是SpringAOP的顶层抽象&#xff0c;用来管理Advice和Pointcut 1、Advice也叫增强器 Spring中有五种增强&#xff1a;BeforeAdvide&#xff08;前置增强&#xff09;、AfterAdvice&#xff08;后置增强&#xff09;、RoundAdvice&#xff08;环绕增强&#…

论文导读 | 7月8月上旬MSOM文章精选

编者按 淘宝店承诺的交货时间早些还是晚些更有利&#xff1f; 波动的市场环境下如何进行分布式储能的选址与运营&#xff1f; 企业存在服务竞争时如何对待“共享库存”这一模式&#xff1f; 网约车平台在线派单时能否综合权衡司机资质、等待时间、订单远近等多种因素&#xff1…

供应链 | 在线平台系列解读(三):B2C 平台市场中物流战略与平台渠道结构设计之间的相互作用

论文解读&#xff1a;张怡雯&#xff0c;温梓曦&#xff0c;肖善&#xff0c;杨子豪 The interplay between logistics strategy and platform’s channel structure design in B2C platform market 原文作者信息 H. Liu, T. Xu, S. Jing, Z. Liu, S. Wang (2023) The interpl…

Java语法基础案例(二)

目录 案例六&#xff1a;抢红包 案例七&#xff1a;找素数 方法一&#xff1a; 方法二&#xff1a; 方法三&#xff1a; 案例八&#xff1a;实现双色球 关于本项目所用所有方法的解释&#xff1a; 案例六&#xff1a;抢红包 一个大V直播时发起了抢红包活动&#xff0c;分…

PyQt5 PyQt6 Designer 的安装

pip国内的一些镜像 阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 豆瓣(douban) http://pypi.douban.com/simple/ 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ 中国科学技术大学 http://pypi.mirrors.ustc.…

力扣164最大间距

1.前言 因为昨天写了一个基数排序&#xff0c;今天我来写一道用基数排序实现的题解&#xff0c;希望可以帮助你理解基数排序。 这个题本身不难&#xff0c;就是线性时间和线性额外空间(O(n))的算法&#xff0c;有点难实现 基数排序的时间复杂度是O(d*(nradix))&#xff0c;其中…

HTML图片标签(2) HTML5+CSS3+移动web 前端开发入门笔记(三)

图片标签 HTML中&#xff0c;可以使用标签来插入图片。具体的语法为&#xff1a; <img src"图片路径" alt"替代文本">其中&#xff0c;src属性用于指定图片的路径&#xff0c;可以是相对路径或绝对路径。常见的有相对当前HTML文件的路径&#xff0…

Golang 实现接口和继承

小猴子继承了老猴子&#xff0c;这样老猴子拥有的能力包括字段&#xff0c;方法就会自动的被老猴子继承。 小猴子不需要做任何处理就可以拿到老猴子的字段和它的方法&#xff0c;因为是继承关系。 但是小猴子还会其他的技能&#xff0c;比如还会像小鸟一样飞翔&#xff0c;希…

国际减灾日 | 智慧减灾——百分点科技的数据科学视角

国际减轻自然灾害日简称“国际减灾日”&#xff0c;由联合国于1989年设立&#xff0c;旨在关注全球灾害风险&#xff0c;呼吁各国政府、组织和个人积极参与减灾工作&#xff0c;以保护人民生命财产安全。今年10月13日是第34个国际减灾日&#xff0c;主题为“共同打造有韧性的未…

卫星影像如何插入到AutoCAD使用

工具 Bigemap gis office地图软件 BIGEMAP GIS Office-全能版 Bigemap APP_卫星地图APP_高清卫星地图APP 第一步&#xff1a; 首先需要下载影像&#xff0c;选择一个区域下载&#xff0c;影像下载方式有以下几种&#xff1a; 那么通过下载方式选择好了范围以后&#xff0c;选…

【C++】-c++11的知识点(中)--lambda表达式,可变模板参数以及包装类(bind绑定)

&#x1f496;作者&#xff1a;小树苗渴望变成参天大树&#x1f388; &#x1f389;作者宣言&#xff1a;认真写好每一篇博客&#x1f4a4; &#x1f38a;作者gitee:gitee✨ &#x1f49e;作者专栏&#xff1a;C语言,数据结构初阶,Linux,C 动态规划算法&#x1f384; 如 果 你 …

基于Labview的噪声采集分析系

目录 摘 要......................................................................................................................... 3 第一章 绪论.............................................................................................................…