dzdzdzdzdzdz213/k8s-runtime-guard

GitHub: dzdzdzdzdzdz213/k8s-runtime-guard

基于 eBPF 的 Kubernetes 运行时入侵检测系统,通过内核探针与审计日志关联实现容器级别的威胁感知与告警。

Stars: 1 | Forks: 0

# K8s Runtime Guard **基于 eBPF 的容器感知运行时安全** [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Language: C/Go](https://img.shields.io/badge/Language-C%20%7C%20Go-00ADD8.svg)]() [![Stars](https://img.shields.io/github/stars/dzdzdzdzdzdz213/k8s--runtime--guard?style=social)]() [![Status: Active](https://img.shields.io/badge/Status-Active-brightgreen.svg)]()
## 概述 K8s Runtime Guard 通过将 eBPF 探针直接挂载到内核,同时将事件与 Kubernetes 审计日志进行关联,提供容器感知的入侵检测。它内置了十条检测规则,涵盖常见的容器逃逸和提权模式,并集成了 Kubernetes 审计流水线以提供具备完整上下文的告警。Mock 模式无需实时的内核探针即可实现安全的演示和测试。 ## 功能特性 - **9 个 eBPF 内核钩子** -- 对 `execve`、`connect`、`open`、`write`、`mmap`、`clone`、`ptrace`、`mount` 和 `kill` 进行插桩,并支持容器感知的过滤 - **10 条检测规则** -- 预置了针对反弹 shell、挖矿木马、提权、容器逃逸和文件篡改的规则 - **Kubernetes 审计关联** -- 使用 K8s 审计日志中的 Pod、Namespace 和 ServiceAccount 上下文来丰富 eBPF 事件 - **Mock 模式** -- 运行带有合成事件的完整检测流水线,适用于演示、CI 和开发 - **REST API** -- 简洁的 JSON API,用于查询告警、规则和容器遥测数据 - **容器级基线** -- 学习每个容器镜像的正常行为以减少误报 ## 架构 ``` ┌────────────────────────────────────────────────────────────┐ │ Kubernetes Cluster │ │ │ │ ┌──────────────┐ ┌──────────────┐ ┌────────────────┐ │ │ │ DaemonSet │ │ Audit Log │ │ API Server │ │ │ │ (per node) │ │ Webhook │ │ Audit Policy │ │ │ └──────┬───────┘ └──────┬───────┘ └───────┬────────┘ │ │ │ │ │ │ │─────────┼──────────────────┼───────────────────┼───────────│ │ │ │ │ │ │ ┌──────┴───────┐ ┌──────┴───────┐ ┌───────┴────────┐ │ │ │ eBPF Probes │ │ Audit │ │ Go Control │ │ │ │ (C, 9 hooks)│──▶│ Correlator │──▶│ Plane │ │ │ └──────────────┘ └──────────────┘ └───────┬────────┘ │ │ │ │ │ ┌──────┴──────┐ │ │ │ REST API │ │ │ │ :9090 │ │ │ └──────┬──────┘ │ │ │ │ │ ┌─────────────────────────────────────────────┴────────┐ │ │ │ Detection Engine (10 Rules) │ │ │ │ reverse_shell | crypto_miner | privesc | ... │ │ │ └──────────────────────────────────────────────────────┘ │ └────────────────────────────────────────────────────────────┘ ``` ## 快速入门 ``` # Clone 代码仓库 git clone https://github.com/dzdzdzdzdzdz213/k8s-runtime-guard.git cd k8s-runtime-guard # Build 容器镜像 docker build -t k8s-runtime-guard:latest . # 部署到 Kubernetes kubectl apply -f deploy/daemonset.yaml # 验证 agent 是否正在运行 kubectl logs -n kube-system -l app=k8s-runtime-guard -f # 通过 REST API 查询告警 curl http://localhost:9090/api/v1/alerts ``` ## 技术栈 | 组件 | 技术 | 用途 | |------------------|-------------------------|----------------------------------| | Kernel Probes | C / libbpf | eBPF 程序编译 | | Control Plane | Go (cilium/ebpf) | eBPF 加载与生命周期 | | Audit Pipeline | Go | K8s 审计日志关联 | | API Layer | Go net/http | RESTful 告警与规则查询 | | Deployment | Kubernetes DaemonSet | 节点级 Agent 部署 | | Containerization | Docker | 构建与分发 | ## 开源协议 [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 本项目基于 MIT License 授权。
标签:CSV导出, EVTX分析, Go, Ruby工具, Web截图, 子域名变形, 子域名突变, 容器安全, 日志审计, 请求拦截