本仓库是一个概念验证(PoC),用于在本地环境中复现 Traefik 的 Kubernetes Gateway provider 中存在的高严重性漏洞 CVE-2026-54761。
此漏洞影响 crossProviderNamespaces 的许可列表。在声明多个加权后端引用的 HTTPRoute 规则中,Traefik 对许可列表的验证作用于引用目标的 backendRef.namespace,而不是路由自身的 namespace。结果,即使 HTTPRoute 位于未被许可的 namespace 中,只要后端引用指向已许可的 namespace 并且存在对应的 Gateway API ReferenceGrant,也可能暴露 Traefik 内部服务(如 api@internal)。
报告者: saku0512 (https://github.com/Saku0512), vvvvvvvvvvel (https://github.com/vvvvvvvvvvel)
本项目仅供教育目的和授权的安全测试使用。
请勿针对非您拥有或管理的系统运行此 PoC。本 PoC 设计用于创建一次性本地 kind 集群,并在隔离环境中演示该问题。
api@internalcrossProviderNamespaces 选项用于限制哪些 Gateway API 路由 namespace 可以声明包含 @internal 服务引用的 TraefikService 后端引用。
在存在漏洞的加权后端处理路径中,Traefik 检查 backendRef.namespace 是否在许可列表中。但安全边界应该是声明引用的 HTTPRoute 所在的 namespace,因此此验证对象是错误的。
期望行为:
providers:
kubernetesGateway:
crossProviderNamespaces:
- trusted
只有自身 namespace 为 trusted 的路由才能声明跨 provider 的 TraefikService 后端引用。
漏洞行为:
backendRefs:
- group: traefik.io
kind: TraefikService
name: api@internal
namespace: trusted
当路由有多个后端引用,且 backendRef.namespace 设置为已许可的 trusted namespace 时,位于 attacker namespace 中的 HTTPRoute 可能被接受。
此 PoC 创建一个具有以下配置的一次性本地 kind 集群:
providers.kubernetesGateway.crossProviderNamespaces=trustedtrusted 的普通 Gateway API ReferenceGrantcd external-repro-kind
./run-kind-repro.sh
脚本在结束时自动删除集群。
如需保留集群进行手动调查:
KEEP_CLUSTER=1 ./run-kind-repro.sh
控制路由从 attacker namespace 使用单个被禁止的 api@internal 后端引用。这种情况下 API 不应被暴露。
control status: 404
利用路由使用两个后端引用,迫使 Traefik 构建加权服务。在存在漏洞的版本中,对 /api/http/services 的请求会返回 Traefik API 的 JSON。
exploit returned Traefik API JSON
api@internal status: enabled
weighted members:
api@internal 1000000
attacker-whoami-http-80 1
关键点是两条路由都来自同一个不受信任的 attacker namespace。单后端的控制路由被拒绝,但混合加权后端路由成功解析并暴露了 api@internal。
external-repro-kind/kind-config.yaml - 本地 kind 集群配置,在 127.0.0.1:18080 暴露 Traefikexternal-repro-kind/traefik-v371.yaml - 存在漏洞的 Traefik 部署与 GatewayClassexternal-repro-kind/gateway-exploit.yaml - namespace、Gateway、ReferenceGrant、控制路由、绕过路由external-repro-kind/run-kind-repro.sh - 本地端到端复现脚本请将 Traefik 升级至修复版本。
运营者也应检查现有的 Gateway API ReferenceGrant 资源。除非是明确授权的委托,否则不应允许不受信任的 namespace 访问跨 provider 的 TraefikService 引用。