Bastion: Kubernetes RBAC & Attack-Path Analyzer

Reads your Kubernetes manifests and tells you who can become cluster-admin, and how — treating privilege escalation as the graph problem it actually is.

Bastion is an offline Kubernetes RBAC and pod-security attack-path analyzer. It reads a manifest directory, `helm template` output, or a `kubectl get -o yaml` export — never a kubeconfig, never an API server, no network at scan time — and answers the question nobody's linter can: which identity can reach cluster-admin, and through what chain? Escalation in Kubernetes is a graph problem, not a checklist, so Bastion builds the privilege graph and reports the connected path instead of a pile of disconnected warnings. Packaged as production-ready open-source software (PyPI-ready src-layout, MkDocs docs site, CodeQL CI, citable via CITATION.cff), and every escalation finding now ships a least-privilege remediation suggestion — a narrowed-rule YAML snippet synthesised from the offending rule.

`create pods` in a namespace is not 'can start a pod' — it is 'can become any ServiceAccount in that namespace', because a pod spec names the account it runs as. Chain a few individually-defensible grants (CI runs test pods, on-call execs into pods, a controller provisions RBAC) and you have a route from a build token to the whole cluster that no per-resource linter will ever flag. Bastion finds those routes with a deterministic breadth-first search over the privilege graph, explains each hop in prose, cites a file and a line for every edge, tells you which rule to delete, and marks its own confidence when an escalation depends on an assumption it can't verify statically.

Key metrics

  • Escalation paths found (9 real charts): 47 across 68 findings
  • RBAC/escalation findings from a popular linter (same input): 0 of 408
  • Manifests calibrated against: 368 (9 charts)
  • Escalation rules (E-series): E1–E14
  • Automated tests: 590+
  • Runtime dependencies: 1 (ruamel.yaml, for line numbers)

Engineering rigor

  • 590+ tests
  • 1 runtime dep
  • 9 charts calibrated on
  • 47 real paths found
  • Apache-2.0 license

Tech stack

Python 3.11+, ruamel.yaml (line numbers), Standard-library graph (deterministic BFS), SARIF 2.1.0, Self-contained HTML + inline SVG, Kubernetes RBAC / PSA, Helm, pytest / ruff / mypy

Roadmap

  • Research manuscript in preparation: “Bastion: Offline Attack-Path Analysis of Kubernetes RBAC and Pod Security” — targeting arXiv (cs.CR / cs.SE).
  • Deeper container-escape taxonomy, informed by KubeHound's edge types.
  • Optional least-privilege Role suggestions (not just 'which rule to delete').
  • Broader admission-policy awareness for enforced-but-external webhooks.

View on GitHub

← All projects