Minderbinder是一款基于eBPF的进程安全测试工具,在该工具的帮助下,广大研究人员可以通过注入噪声来测试目标进程的安全性。
Minderbinder 是一款使用 eBPF 将故障注入正在运行的进程的工具。当前版本的Minderbinder 可以通过将 kprobes 附加到系统调用处理程序来将故障注入系统调用,并通过将流量过滤器附加到 Linux 的流量控制子系统来将故障注入传出网络流量。
Minderbinder 旨在让将故障注入到进程中变得简单。我们可以编写一个 config.yaml 来描述要注入的故障以及要将其注入到的进程,然后启动 minderbinder,看看会发生什么。
当前版本的Minderbinder运行机制如下:
1、用户空间应用程序读取配置文件,附加必要的探测器,并将配置写入syscall_target_configeBPFoutgoing_network_config映射;
2、kprobe execve会捕获新进程的启动。在找到与映射中的目标匹配的进程后_config,它们会将 PID 数据添加到目标配置并更新相应的_target映射。例如,匹配的元素syscall_target_config会导致将 PID+目标配置添加到syscall_targets;
3、然后,负责每个模块的 eBPF 会触发其特定的钩子,并在其映射中找到相关条目后_targets,“中断”相应正在考虑的操作;
Go运行时环境
由于该工具基于Go开发,因此我们首先需要在本地设备上安装并配置好最新版本的Go环境。
接下来,广大研究人员可以直接使用下列命令将该项目源码克隆至本地:
Minderbinder 支持两种不同的干预措施 -syscall和outgoing_network:
agents_of_chaos:
syscall
:
- name: break_curl_openat
syscall: openat
ret_code: -2
targets:
- process_name: curl
delay_ms: 100
failure_rate: 100
outgoing_network:
- name: break_wget_network
targets:
- process_name: wget
delay_ms: 100
failure_rate: 100
要运行 minderbinder,您需要指定配置文件,并且如果您正在使用outgoing_network,还要指定要附加的接口:
sudo ./minderbinder --interface enp67s0 config.yaml
除此之外,我们还可以使用Minderbinder为现有的单元测试框架提供后端,以便我们可以编写组件测试,以有趣的、与混乱相关的方式轻松破坏被测代码:
func TestYourAPIHandler_DownstreamFailure(t *testing.T) {
req := httptest.NewRequest(http.MethodGet, "/your-api-endpoint", nil)
rec := httptest.NewRecorder()
cfg := FailureConfig{
OutgoingNetwork: [] OutgoingNetworkFailure {
{
Protocol: "TCP",
DestPort: 443,
FailureRate: 100
}
}
}
minderbinder := &Minderbinder{}
minderbinder.WithFailures(cfg, func() (*http.Response, error) {
YourAPIHandler(rec, req)
return nil
})
assert.Equal(t, http.StatusBadGateway, rec.Code)
assert.Equal(t, "Downstream service failed\n", rec.Body.String())
}
本项目的开发与发布遵
循Apache-2.0开源许可协议。
Minderbinder
:
https://github.com/scottgerring/minderbinder