{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "9b75c9a1-99f3-42be-913c-2e38e0191a19",
"metadata": {},
"outputs": [],
"source": [
"from attacktree.models import Action, Block, Detect, Discovery, Edge, Root, Goal\n",
"from attacktree.renderer import Renderer\n",
"\n",
"root = Root(\"Signed up to Azure\")\n",
"goal = Goal(\"Access to other tenants data\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "e3e671e0-4f6d-4acf-af95-29bb6029a607",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Goal:4374765040"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Direct path\n",
"whoC = root.add(Action(\"Deploy WhoC container to view runtime\"))\n",
"omgRunC = whoC.discover(\"OLD runc version 1.0.0-r2\")\n",
"exploit = omgRunC.action(\"Deploy exploit container for CVE-2019-5736\")\n",
"shell = Root(\"Reverse shell on worker node\")\n",
"exploit.add(shell)\n",
"creds = shell.discover(\"Read kubelet credentials from disk\")\n",
"\n",
"describePods = creds.action(\"Call KubeAPI describe pods\")\n",
"pods = describePods.discover(\"100+ customer pods on 120 nodes\\nEach customer has their own namespace\")\n",
"versions = describePods.discover(\"OLD Kubernetes versions v1.8.4, v1.9.10, v1.10.9\")\n",
"anonymousAccess = describePods.discover(\"Kubelets run with anonymous access\")\n",
"\n",
"otherKubelet = anonymousAccess.action(\"Access another customer's kubelet\")\n",
"blockedbyFirewall = otherKubelet.block(\"Blocked by firewall\", implemented=True)\n",
"\n",
"cve = versions.discover(\"CVE-2018-1002102 kube-api follows 302 redirect\")\n",
"exploit2 = cve.action(\"Attempt to redirect to kube-api pod\")\n",
"fail = exploit2.block(\"ACI uses a 'bridge' POD which is not impacted by this issue\",implemented=True)\n",
"\n",
"interesting = exploit2.discover(\"ServiceAccount in 'AuthorizationHeader' of Exec requests\")\n",
"bridgeToken = interesting.discover(\"Decoded JWT shows this token belongs to 'bridge' service\")\n",
"\n",
"accessReview = bridgeToken.action(\"Call SelfSubjectAccessReview with 'bridge' token\")\n",
"privs = accessReview.discover(\"Cluster-wide permissions\\npods/exec privilege\")\n",
"\n",
"gameOver = privs.action(\"Exec into shell on kube-API\")\n",
"gameOver.add(goal)\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "34a4cab6-51ec-444e-a286-e979c869e3fb",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Renderer().buildDot22(root)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}