Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
ssbd-tools — 利用 x86 处理器的推测存储绕过禁用(SSBD)功能,测试 Linux 内核针对 CVE-2018-3639(又称 Variant 4)缓解措施的工具 | Kitploit
工具/GitHubGitHub/tyhicks/ssbd-tools
漏洞分析漏洞利用硬件安全
GitHubtyhicks/ssbd-tools

ssbd-tools

利用 x86 处理器的推测存储绕过禁用(SSBD)功能,测试 Linux 内核针对 CVE-2018-3639(又称 Variant 4)缓解措施的工具

查看仓库
928年前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

用于实践 Speculative Store Bypass Disable 的工具

ssbd-tools 项目是一个程序集合,用于利用 x86 处理器中提供的 Speculative Store Bypass Disable (SSBD) 功能。SSBD 是一种基于处理器的缓解措施,针对被称为 Variant 4 并分配了 CVE-2018-3639 的 Speculative Store Bypass 攻击。Linux 内核引入了用于使用 SSBD 的每进程控制,这些工具可用于利用这些控制并帮助验证其正确性。

每进程 SSBD 控制

Linux 内核提供了几种不同的操作模式,可以在启动时通过 spec_store_bypass_disable 内核参数为 x86 系统上的 SSBD 进行选择。内核参数文档 对此有很好的描述。以下是该文档中描述这些选项的片段:

root@kitploit:~
  on      - Unconditionally disable Speculative Store Bypass
  off     - Unconditionally enable Speculative Store Bypass
  auto    - Kernel detects whether the CPU model contains an
            implementation of Speculative Store Bypass and
            picks the most appropriate mitigation. If the
            CPU is not vulnerable, "off" is selected. If the
            CPU is vulnerable the default mitigation is
            architecture and Kconfig dependent. See below.
  prctl   - Control Speculative Store Bypass per thread
            via prctl. Speculative Store Bypass is enabled
            for a process by default. The state of the control
            is inherited on fork.
  seccomp - Same as "prctl" above, but all seccomp threads
            will disable SSB unless they explicitly opt out.

  Not specifying this option is equivalent to
  spec_store_bypass_disable=auto.

  Default mitigations:
  X86:    If CONFIG_SECCOMP=y "seccomp", otherwise "prctl"

CPU 特定细节

SSBD 功能通过设置处理器的一个特定型号寄存器(MSR)中的单个位来启用/禁用。确切的 MSR 以及 MSR 内的位位置因 CPU 厂商、同一厂商的不同 CPU 系列以及内核是否在虚拟机监视器(hypervisor)下运行而不同。这些工具遵循 Intel 和 AMD 发布的指南,以确定 SSBD 位在当前执行环境中的位置。

为什么 SSBD 可能不可用

某些系统可能没有可用的 SSBD 支持。这可能是由于多种原因:

  • 你的处理器需要更新微码。Intel 处理器就是这种情况。你可以通过固件更新或安装 Linux 发行版的微码软件包(Debian/Ubuntu 上的 intel-microcode 和 amd64-microcode)来获取更新后的微码。AMD 15h、16h 和 17h 系列处理器不需要更新微码。
  • 你的内核尚未更新以支持 SSBD。许多 Linux 操作系统厂商已经发布了更新,请前往 CERT 的 Variant 4 页面 查看关于你所用厂商的详细信息。
  • 你正在使用虚拟机,且你的虚拟机监视器尚未更新以支持 SSBD。如果你能控制宿主机环境,请参阅上面的 CERT 页面,了解如何更新相关的虚拟机监视器软件。

ssbd-tools 中的程序概要

ssbd-exec

ssbd-exec 程序在执行另一个程序之前使用每进程 SSBD 控制。它可以使用 PR_SET_SPECULATION_CTRL prctl 来允许推测执行(-p enable 使用 PR_SPEC_ENABLE)、通过 SSBD 禁止推测执行(-p disable 使用 PR_SPEC_DISABLE)、或通过 SSBD 永久禁止所有未来子进程中的推测执行(-p force-disable 使用 PR_SPEC_FORCE_DISABLE)。

它还可以加载一个宽松的 seccomp 过滤器(-s empty),在 x86 上默认会使进程选择加入 SSBD 缓解。还有一个选项(-s spec-allow)用于加载不会使进程选择加入 SSBD 的宽松过滤器。

使用 ssbd-exec

  • 查看 /proc/PID/status 以显示任务默认不使用 SSBD
root@kitploit:~
 $ ./ssbd-exec -- grep Spec /proc/self/status
 Speculation_Store_Bypass:	thread vulnerable
  • 使用 prctl 启用 SSBD 时查看 /proc/PID/status
root@kitploit:~
 $ ./ssbd-exec -p disable -- grep -e Spec -e Seccomp /proc/self/status
 Seccomp:        0
 Speculation_Store_Bypass:       thread mitigated
  • 在运行宽松的 seccomp 过滤器并使进程选择加入 SSBD 时查看 /proc/PID/status
root@kitploit:~
 $ ./ssbd-exec -s empty -- grep -e Spec -e Seccomp /proc/self/status
 Seccomp:        2
 Speculation_Store_Bypass:       thread force mitigated

ssbd-verify

ssbd-verify 程序验证实际 SSBD 位(位于特定于你的处理器的 MSR 和位偏移中)是否为预期值。0 表示未使用 SSBD,而 1 表示正在使用。

该程序还可用于验证任务的 PR_GET_SPECULATION_CTRL prctl 值是否设置为允许推测执行(-p enable 验证 PR_SPEC_ENABLE)、通过 SSBD 禁止推测执行(-p disable 验证 PR_SPEC_DISABLE)、或通过 SSBD 永久禁止所有未来子进程中的推测执行(-p force-disable 验证 PR_SPEC_FORCE_DISABLE)。

该程序可以配置为使用 -t SECONDS 选项重复验证 SSBD 位的值。如果 SECONDS 为 0,程序将在验证 SSBD 位的同时无限循环。SECONDS 为非零值时,程序将在指定的时间内验证 SSBD 位。

该程序要求加载 msr 内核模块,并且用户具有 root 权限才能从相应的 MSR 读取 SSBD 位。

使用 ssbd-verify

  • 验证默认情况下未设置 SSBD
root@kitploit:~
 $ sudo ./ssbd-verify 0
 $ sudo ./ssbd-verify 1
 FAIL: SSBD bit verification failed (expected 1, got 0)
  • 使用 prctl 禁用推测执行时验证已设置 SSBD
root@kitploit:~
 $ ./ssbd-exec -p disable -- sudo ./ssbd-verify 1
  • 加载 seccomp 过滤器时验证已设置 SSBD
root@kitploit:~
 $ sudo ./ssbd-exec -s empty -- ./ssbd-verify 1

注意:上面的命令需要对 ssbd-exec 使用 sudo,因为在加载 seccomp 过滤器之前使用了 NO_NEW_PRIVS。如果在设置 NO_NEW_PRIVS 之后使用 sudo,则无法提升权限。

ssbd-toggle

ssbd-toggle 程序只是在一个无限循环中反复切换 SSBD 位的开和关,直到程序被终止。它可以与 ssbd-verify 结合使用,以确保内核切换到其任务时,ssbd-verify 进程始终具有预期的 SSBD 位值。

该程序要求加载 msr 内核模块,并且用户具有 root 权限才能读写相应的 MSR。

使用 ssbd-toggle

  • 切换处理器 0 的 SSBD 位,直到进程被中断
root@kitploit:~
 $ sudo ./ssbd-toggle
 ^C

构建工具

要构建这些工具,请运行 make:

root@kitploit:~
 $ make

测试你的系统

要运行一些基本的自动化测试以确保 SSBD 在你的系统上按预期工作,请以 root 身份运行 check 目标:

root@kitploit:~
 $ sudo make check
 PASS
下载工具