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

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

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

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

工具目录

分类

查看所有分类
Loading categories
block-copyfail — BPF LSM 拦截器,用于 CVE-2026-31431(Copy Fail)——OpenShift 4 的零重启修复方案 | Kitploit
工具/GitHubGitHub/mrunalp/block-copyfail
防御工具容器安全漏洞分析安全虚拟化云安全
GitHubmrunalp/block-copyfail

block-copyfail

BPF LSM 拦截器,用于 CVE-2026-31431(Copy Fail)——OpenShift 4 的零重启修复方案

查看仓库
123个月前尚未审核

最受欢迎

查看全部 →

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

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

摘要

CVE-2026-31431(“Copy Fail”)是 Linux 内核 algif_aead 加密接口中的一个权限提升漏洞。攻击者利用 AF_ALG 套接字配合 authencesn 算法和 splice() 来破坏内核页缓存中的任意文件——包括 /usr/bin/su 等 setuid 二进制文件。

本文档提供了一种零重启修复方案,使用 BPF LSM DaemonSet 阻止所有 AF_ALG AEAD 绑定——即 Copy Fail 所利用的子系统。这可以防止通过加密模板嵌套(例如 pcrypt(authencesn(...)))进行绕过。其他 AF_ALG 用法(hash、skcipher)不受影响。已在三个独立的 OCP 4.22 集群上完成端到端测试。

快速开始

root@kitploit:~
# 1. 验证 BPF LSM 已启用(RHEL CoreOS 9.8 默认启用)
oc debug node/<any-node> -- chroot /host cat /sys/kernel/security/lsm
# 必须包含 "bpf"

# 2. 部署命名空间并授予特权 SCC
oc apply -f daemonset.yaml

# 3. DaemonSet Pod 将自动在所有节点上启动

# 4. 验证
oc get pods -n block-copyfail     # 所有节点应显示 Running
oc logs -n block-copyfail -l app=block-copyfail
# 预期输出: "block-copyfail: blocker active — all AF_ALG AEAD binds blocked"

无需重启。无需节点排空。无需重启 Pod。防护即时生效,覆盖所有节点上的所有进程(100% 覆盖)。

目录

  1. 漏洞利用原理
  2. 确认集群是否存在漏洞
  3. BPF LSM DaemonSet 部署
  4. 部署后验证
  5. 从源码构建镜像
  6. 移除

漏洞利用原理

该漏洞利用链涉及三个内核特性:

  1. AF_ALG 套接字 — 通过 socket(AF_ALG, SOCK_SEQPACKET, 0) 创建用户空间到内核加密功能的句柄
  2. AEAD 绑定 — 绑定到 authencesn(hmac(sha256),cbc(aes)),一种特定的认证加密算法
  3. splice() + sendmsg() — 内核错误地执行了“就地”操作,其中源和目标页映射不同,从而破坏只读文件的页缓存

攻击者在页缓存中破坏 /usr/bin/su(无需对文件具有写权限),然后执行它以获取 root 权限。


确认集群是否存在漏洞

在集群上创建一个新的 cve-2026-31431-test 命名空间,并通过应用 test 目录中的清单来运行测试脚本:

root@kitploit:~
oc apply -f test

检查结果:

root@kitploit:~
oc wait pod/cve-test -n cve-2026-31431-test \
  --for=jsonpath='{.status.phase}'=Succeeded --timeout=120s
oc -n cve-2026-31431-test logs -l app=cve-2026-31431-test

在存在漏洞的集群上,您将看到:

root@kitploit:~
=== CVE-2026-31431 Vulnerability Test ===
Target: /usr/bin/su

Original SHA256: 8969560ae8e6e21c6184c1451f59418822ee69dd5d946d71987b55236bbc0feb
Attempting splice + AF_ALG page-cache corruption (160 bytes in 40 chunks)...
After SHA256:    30b0f5b5a054c4df65b48ca792863bf7054b4d793f15f57163792ba6c2b151ae

PAGE CACHE CORRUPTION: YES - /usr/bin/su was modified in the page cache

Attempting to execute corrupted /usr/bin/su ...
  exit code: 0

RESULT: PARTIALLY MITIGATED
  Page-cache corruption succeeded (kernel is vulnerable)
  Privilege escalation blocked (allowPrivilegeEscalation=false)

步骤 4:清理

root@kitploit:~
oc delete namespace cve-2026-31431-test

BPF LSM DaemonSet 部署

BPF LSM 方法在内核层面挂钩 socket_bind,无论模板嵌套如何,都会阻止所有 AF_ALG AEAD 绑定。它基于 block-copyfail,使用 C 语言和 libbpf 重写,用于 OCP 部署。

前提条件

必须启用 BPF LSM。RHEL CoreOS 9.8(OCP 4.22)默认已启用。验证方法:

root@kitploit:~
oc debug node/<any-node> -- chroot /host cat /sys/kernel/security/lsm

预期输出包含 bpf:

root@kitploit:~
lockdown,capability,landlock,yama,selinux,bpf

如果 不 存在 bpf,则需要一次性 MachineConfig(这是唯一需要重启的场景):

root@kitploit:~
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
  labels:
    machineconfiguration.openshift.io/role: worker
  name: 99-enable-bpf-lsm
spec:
  kernelArguments:
    - lsm=lockdown,capability,selinux,bpf

步骤 1:创建命名空间、授予 SCC 并部署

通过应用 daemonset.yaml 清单创建新的 block-copyfail 命名空间、授予 SCC 并部署 DaemonSet。 必须在创建 DaemonSet Pod 之前授予特权 SCC,否则 Pod 创建将因 SCC 验证错误而失败。

root@kitploit:~
oc apply -f daemonset.yaml

步骤 2:等待 Pod 在所有节点上启动

root@kitploit:~
oc get pods -n block-copyfail -o wide

预期:每个节点一个 Pod,全部 Running:

root@kitploit:~
NAME                   READY   STATUS    AGE   NODE
block-copyfail-2jhzf   1/1     Running   34s   ci-...-master-2
block-copyfail-4dfq7   1/1     Running   34s   ci-...-master-1
block-copyfail-c2ts8   1/1     Running   34s   ci-...-worker-c
block-copyfail-ctblk   1/1     Running   34s   ci-...-worker-a
block-copyfail-m26sx   1/1     Running   34s   ci-...-worker-b
block-copyfail-xsh6d   1/1     Running   34s   ci-...-master-0

步骤 3:验证阻止器已激活

root@kitploit:~
oc logs -n block-copyfail -l app=block-copyfail

预期:

root@kitploit:~
block-copyfail: blocker active — all AF_ALG AEAD binds blocked

部署后验证

重新运行确认漏洞部分中的相同漏洞测试。

部署 BPF LSM DaemonSet 后,输出将为:

root@kitploit:~
=== CVE-2026-31431 Vulnerability Test ===
Target: /usr/bin/su

Original SHA256: 30b0f5b5a054c4df65b48ca792863bf7054b4d793f15f57163792ba6c2b151ae
Attempting splice + AF_ALG page-cache corruption (160 bytes in 40 chunks)...
  AF_ALG bind failed: [Errno 1] Operation not permitted

RESULT: CANNOT TEST - AF_ALG or splice not available/permitted

DaemonSet 日志将显示被阻止的尝试:

root@kitploit:~
oc logs -n block-copyfail -l app=block-copyfail
root@kitploit:~
block-copyfail: blocker active — all AF_ALG AEAD binds blocked
block-copyfail: BLOCKED pid=16777    comm=python3 time=2026-05-01 16:37:23

验证其他算法不受影响

在节点上运行 verify-algos.py,确认所有 AEAD 算法均被阻止,而其他 AF_ALG 类型(hash、skcipher)继续正常工作:

root@kitploit:~
oc debug node/<any-node> -- chroot /host python3 -c "
import socket
tests = [
    ('aead',     'gcm(aes)'),
    ('aead',     'ccm(aes)'),
    ('aead',     'rfc4106(gcm(aes))'),
    ('hash',     'sha256'),
    ('skcipher', 'cbc(aes)'),
    ('aead',     'authencesn(hmac(sha256),cbc(aes))'),
]
for t, n in tests:
    s = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0)
    try:
        s.bind((t, n))
        print(f'  ALLOWED  {t}/{n}')
    except OSError as e:
        print(f'  BLOCKED  {t}/{n} -- {e}')
    finally:
        s.close()
"

预期输出:

root@kitploit:~
  BLOCKED  aead/gcm(aes) -- [Errno 1] Operation not permitted
  BLOCKED  aead/ccm(aes) -- [Errno 1] Operation not permitted
  BLOCKED  aead/rfc4106(gcm(aes)) -- [Errno 1] Operation not permitted
  ALLOWED  hash/sha256
  ALLOWED  skcipher/cbc(aes)
  BLOCKED  aead/authencesn(hmac(sha256),cbc(aes)) -- [Errno 1] Operation not permitted

这确认了 BPF LSM 阻止所有 AEAD 绑定,同时保持其他 AF_ALG 类型可用。


从源码构建镜像

BPF LSM 阻止器源码位于 block-copyfail/:

root@kitploit:~
block-copyfail/
  block_copyfail.bpf.c     # BPF 内核程序(LSM 钩子)
  block_copyfail.c          # 用户空间加载器(libbpf 骨架)
  block_copyfail.h          # 共享事件结构体
  Makefile                  # 构建流水线
  Dockerfile                # 多阶段构建
  daemonset.yaml            # 命名空间 + DaemonSet 清单
  trigger-test.py           # 快速验证脚本

构建并推送:

root@kitploit:~
cd block-copyfail/
podman build -t quay.io/<org>/block-copyfail:latest .
podman push quay.io/<org>/block-copyfail:latest

Dockerfile 使用多阶段构建:Fedora(含 clang/bpftool/libbpf-devel)用于编译,UBI 9 minimal 作为运行时镜像(约 122 MB)。


移除

删除 DaemonSet 将立即移除所有节点上的缓解措施:

root@kitploit:~
oc delete -f daemonset.yaml
# 或
oc delete namespace block-copyfail

BPF 程序会在加载器进程退出时自动分离。无需重启或重启 Pod。

下载工具