mizcausevic-dev/k8s-rbac-overscope-finder

GitHub: mizcausevic-dev/k8s-rbac-overscope-finder

一款离线扫描 Kubernetes YAML manifest 目录中过度授权 RBAC 规则的静态安全审计工具。

Stars: 0 | Forks: 0

# k8s-rbac-overscope-finder 扫描 **Kubernetes YAML manifests** 目录,查找权限过大的 RBAC。纯粹的离线转换——无需集群访问权限,无需 `kubectl`,也无需安装 admission webhook。 捕获安全审查真正关心的情况:通配符 verbs、提权原语、pod-exec、Secret 读取、cluster-admin 绑定以及 `system:masters` 组绑定。 ## 标记内容 | 代码 | 严重性 | 规则 | |---|---|---| | `all-three-wildcards` | 🔴 | 单个规则授予了 `verbs=*` + `resources=*` + `apiGroups=*`(在其范围内等同于 cluster-admin)。 | | `wildcard-verbs` | 🔴 | 规则授予了 `verbs: ["*"]`。 | | `escalation-verb` | 🔴 | 规则授予了 `escalate`、`bind` 或 `impersonate`。 | | `pod-exec` | 🔴 | 规则授予了 `pods/exec` / `pods/portforward` / `pods/attach`。 | | `system-masters-binding` | 🔴 | 绑定指向了 `system:masters` 组(集群上的 root)。 | | `cluster-admin-binding` | 🔴 (ClusterRoleBinding) / 🟠 (system 命名空间之外的 RoleBinding) | 绑定授予了 `cluster-admin` ClusterRole。 | | `wildcard-resources` | 🟠 | `resources: ["*"]`。 | | `wildcard-api-groups` | 🟠 | `apiGroups: ["*"]`。 | | `secret-read` | 🟠 | 规则允许读取 Secrets。 | | `wildcard-nonresource-urls` | 🟠 | `nonResourceURLs: ["*"]`。 | ## CLI ``` npx k8s-rbac-overscope-finder [--format json|markdown|summary] [--skip path-substring,path-substring] [--system-namespaces kube-system,kube-public,kube-node-lease] [--fail-on-high] [--out FILE] ``` 递归遍历目录,解析每个 `*.yaml` / `*.yml`(支持多文档),并输出发现的问题。 退出代码: - `0` — 无高危发现(或未设置 `--fail-on-high`) - `1` — 存在高危发现且设置了 `--fail-on-high` - `2` — 用法 / I/O 错误 将其集成到 CI 中,以便在 Helm chart 或 manifest PR 发布前进行拦截。 ## 库 ``` import { scan, toMarkdown, ESCALATION_VERBS } from "k8s-rbac-overscope-finder"; const report = scan("./manifests"); console.log(report.findings); // [{ code, severity, kind, name, ruleIndex, … }] console.log(toMarkdown(report)); ``` ## 组合使用 - [**`k8s-deprecated-api-scanner`**](https://github.com/mizcausevic-dev/k8s-deprecated-api-scanner) — 用于扫描已弃用的 `apiVersion` 用法的同类扫描器。在 K8s 升级或 chart 发布之前运行这两个工具。 - [**`governance-disclosure-operator`**](https://github.com/mizcausevic-dev/governance-disclosure-operator)、[**`scheduled-audit-operator`**](https://github.com/mizcausevic-dev/scheduled-audit-operator)、[**`llm-cost-budget-operator`**](https://github.com/mizcausevic-dev/llm-cost-budget-operator) — operator 暴露的接口。在发布之前,针对它们的 Helm `templates/` 运行此扫描器。 ## 开发 ``` npm install npm run lint && npm run typecheck && npm run coverage && npm run build npm run demo ``` ## 许可证 [AGPL-3.0-or-later](LICENSE)
标签:DevSecOps, MITM代理, RBAC, 上游代理, 文档结构分析, 暗色界面, 聊天机器人, 自动化攻击, 错误基检测, 静态代码分析