ctf-agent 1.2.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 (152) hide show
  1. package/AGENTS.md +131 -0
  2. package/Dockerfile +192 -0
  3. package/README.md +522 -0
  4. package/agents/ctf-analyzer.md +58 -0
  5. package/agents/ctf-controller.md +151 -0
  6. package/agents/ctf-speedrun.md +74 -0
  7. package/bin/ctf-agent.js +119 -0
  8. package/docker-compose.yml +13 -0
  9. package/mcp_config.json +19 -0
  10. package/package.json +44 -0
  11. package/references/ctf-triage-ladder.md +68 -0
  12. package/references/exploit-databases.md +575 -0
  13. package/references/llm-safety-and-policy-compliance.md +173 -0
  14. package/references/multi-agent-orchestration-and-policy-routing.md +278 -0
  15. package/references/security-events-and-intelligence.md +566 -0
  16. package/references/version-matrix.md +59 -0
  17. package/rules/ctf-execution-rules.md +44 -0
  18. package/rules/ctf-safety-framing-rules.md +140 -0
  19. package/rules/flag-validation-rules.md +25 -0
  20. package/scripts/__init__.py +1 -0
  21. package/scripts/ctf-tools.lock +205 -0
  22. package/scripts/ctf_init.py +1026 -0
  23. package/scripts/ctf_update.py +583 -0
  24. package/scripts/ctfd_client.py +81 -0
  25. package/scripts/cve_lookup.py +453 -0
  26. package/scripts/extract_flags.py +155 -0
  27. package/scripts/install_as_agent.py +278 -0
  28. package/scripts/install_ctf_tools.sh +603 -0
  29. package/scripts/parallel_triage.py +395 -0
  30. package/scripts/prompt_policy_sanitizer.py +283 -0
  31. package/scripts/scope_guard.py +444 -0
  32. package/scripts/skill_validator.py +504 -0
  33. package/scripts/workspace_cleaner.py +141 -0
  34. package/skills/ctf-ai-ml/SKILL.md +120 -0
  35. package/skills/ctf-ai-ml/adversarial-ml.md +623 -0
  36. package/skills/ctf-ai-ml/llm-attacks.md +487 -0
  37. package/skills/ctf-ai-ml/model-attacks.md +422 -0
  38. package/skills/ctf-crypto/SKILL.md +320 -0
  39. package/skills/ctf-crypto/advanced-math.md +798 -0
  40. package/skills/ctf-crypto/classic-ciphers.md +651 -0
  41. package/skills/ctf-crypto/ecc-attacks.md +347 -0
  42. package/skills/ctf-crypto/exotic-crypto-2.md +380 -0
  43. package/skills/ctf-crypto/exotic-crypto.md +528 -0
  44. package/skills/ctf-crypto/historical.md +113 -0
  45. package/skills/ctf-crypto/lattice-and-lwe.md +524 -0
  46. package/skills/ctf-crypto/modern-ciphers-2.md +563 -0
  47. package/skills/ctf-crypto/modern-ciphers-3.md +453 -0
  48. package/skills/ctf-crypto/modern-ciphers.md +649 -0
  49. package/skills/ctf-crypto/prng-attacks.md +257 -0
  50. package/skills/ctf-crypto/prng.md +664 -0
  51. package/skills/ctf-crypto/rsa-attacks-2.md +792 -0
  52. package/skills/ctf-crypto/rsa-attacks.md +487 -0
  53. package/skills/ctf-crypto/stream-ciphers.md +390 -0
  54. package/skills/ctf-crypto/zkp-and-advanced.md +456 -0
  55. package/skills/ctf-forensics/3d-printing.md +121 -0
  56. package/skills/ctf-forensics/SKILL.md +379 -0
  57. package/skills/ctf-forensics/disk-advanced.md +497 -0
  58. package/skills/ctf-forensics/disk-and-memory.md +491 -0
  59. package/skills/ctf-forensics/disk-recovery.md +699 -0
  60. package/skills/ctf-forensics/linux-forensics.md +511 -0
  61. package/skills/ctf-forensics/network-advanced.md +583 -0
  62. package/skills/ctf-forensics/network.md +645 -0
  63. package/skills/ctf-forensics/peripheral-capture.md +287 -0
  64. package/skills/ctf-forensics/signals-and-hardware.md +713 -0
  65. package/skills/ctf-forensics/steganography.md +694 -0
  66. package/skills/ctf-forensics/stego-advanced-2.md +475 -0
  67. package/skills/ctf-forensics/stego-advanced.md +481 -0
  68. package/skills/ctf-forensics/stego-image.md +691 -0
  69. package/skills/ctf-forensics/windows.md +625 -0
  70. package/skills/ctf-malware/SKILL.md +181 -0
  71. package/skills/ctf-malware/c2-and-protocols.md +274 -0
  72. package/skills/ctf-malware/pe-and-dotnet.md +108 -0
  73. package/skills/ctf-malware/scripts-and-obfuscation.md +449 -0
  74. package/skills/ctf-misc/SKILL.md +498 -0
  75. package/skills/ctf-misc/bashjails.md +323 -0
  76. package/skills/ctf-misc/ctfd-navigation.md +465 -0
  77. package/skills/ctf-misc/dns.md +255 -0
  78. package/skills/ctf-misc/encodings-advanced.md +504 -0
  79. package/skills/ctf-misc/encodings.md +431 -0
  80. package/skills/ctf-misc/games-and-vms-2.md +254 -0
  81. package/skills/ctf-misc/games-and-vms-3.md +690 -0
  82. package/skills/ctf-misc/games-and-vms-4.md +229 -0
  83. package/skills/ctf-misc/games-and-vms.md +529 -0
  84. package/skills/ctf-misc/linux-privesc.md +333 -0
  85. package/skills/ctf-misc/pyjails.md +671 -0
  86. package/skills/ctf-misc/rf-sdr.md +91 -0
  87. package/skills/ctf-osint/SKILL.md +198 -0
  88. package/skills/ctf-osint/geolocation-and-media.md +464 -0
  89. package/skills/ctf-osint/social-media.md +312 -0
  90. package/skills/ctf-osint/web-and-dns.md +341 -0
  91. package/skills/ctf-pwn/SKILL.md +214 -0
  92. package/skills/ctf-pwn/advanced-exploits-2.md +579 -0
  93. package/skills/ctf-pwn/advanced-exploits-3.md +598 -0
  94. package/skills/ctf-pwn/advanced-exploits-4.md +590 -0
  95. package/skills/ctf-pwn/advanced-exploits-5.md +119 -0
  96. package/skills/ctf-pwn/advanced-exploits.md +773 -0
  97. package/skills/ctf-pwn/advanced.md +326 -0
  98. package/skills/ctf-pwn/field-notes.md +245 -0
  99. package/skills/ctf-pwn/format-string.md +694 -0
  100. package/skills/ctf-pwn/heap-fsop.md +285 -0
  101. package/skills/ctf-pwn/heap-techniques-2.md +333 -0
  102. package/skills/ctf-pwn/heap-techniques.md +513 -0
  103. package/skills/ctf-pwn/kernel-bypass.md +421 -0
  104. package/skills/ctf-pwn/kernel-techniques.md +366 -0
  105. package/skills/ctf-pwn/kernel.md +636 -0
  106. package/skills/ctf-pwn/overflow-basics.md +611 -0
  107. package/skills/ctf-pwn/rop-advanced.md +725 -0
  108. package/skills/ctf-pwn/rop-and-shellcode.md +659 -0
  109. package/skills/ctf-pwn/sandbox-escape.md +313 -0
  110. package/skills/ctf-reverse/SKILL.md +163 -0
  111. package/skills/ctf-reverse/anti-analysis-ctf.md +204 -0
  112. package/skills/ctf-reverse/anti-analysis.md +693 -0
  113. package/skills/ctf-reverse/field-notes.md +376 -0
  114. package/skills/ctf-reverse/languages-compiled.md +666 -0
  115. package/skills/ctf-reverse/languages-platforms.md +592 -0
  116. package/skills/ctf-reverse/languages.md +553 -0
  117. package/skills/ctf-reverse/patterns-ctf-2.md +397 -0
  118. package/skills/ctf-reverse/patterns-ctf-3.md +797 -0
  119. package/skills/ctf-reverse/patterns-ctf.md +670 -0
  120. package/skills/ctf-reverse/patterns-runtime.md +274 -0
  121. package/skills/ctf-reverse/patterns.md +572 -0
  122. package/skills/ctf-reverse/platforms-hardware.md +387 -0
  123. package/skills/ctf-reverse/platforms.md +664 -0
  124. package/skills/ctf-reverse/tools-advanced-2.md +421 -0
  125. package/skills/ctf-reverse/tools-advanced.md +407 -0
  126. package/skills/ctf-reverse/tools-dynamic.md +679 -0
  127. package/skills/ctf-reverse/tools-emulation.md +319 -0
  128. package/skills/ctf-reverse/tools.md +573 -0
  129. package/skills/ctf-web/SKILL.md +153 -0
  130. package/skills/ctf-web/auth-and-access-2.md +82 -0
  131. package/skills/ctf-web/auth-and-access.md +783 -0
  132. package/skills/ctf-web/auth-infra.md +321 -0
  133. package/skills/ctf-web/auth-jwt.md +186 -0
  134. package/skills/ctf-web/client-side-advanced.md +739 -0
  135. package/skills/ctf-web/client-side.md +529 -0
  136. package/skills/ctf-web/cves.md +373 -0
  137. package/skills/ctf-web/field-notes.md +482 -0
  138. package/skills/ctf-web/node-and-prototype.md +200 -0
  139. package/skills/ctf-web/server-side-2.md +337 -0
  140. package/skills/ctf-web/server-side-advanced-2.md +559 -0
  141. package/skills/ctf-web/server-side-advanced-3.md +125 -0
  142. package/skills/ctf-web/server-side-advanced-4.md +480 -0
  143. package/skills/ctf-web/server-side-advanced.md +378 -0
  144. package/skills/ctf-web/server-side-deser.md +443 -0
  145. package/skills/ctf-web/server-side-exec-2.md +799 -0
  146. package/skills/ctf-web/server-side-exec.md +457 -0
  147. package/skills/ctf-web/server-side.md +629 -0
  148. package/skills/ctf-web/sql-injection.md +790 -0
  149. package/skills/ctf-web/web3.md +374 -0
  150. package/skills/ctf-writeup/SKILL.md +90 -0
  151. package/skills/solve-challenge/SKILL.md +269 -0
  152. package/skills.json +16 -0
@@ -0,0 +1,153 @@
1
+ ---
2
+ name: ctf-web
3
+ description: Provides web vulnerability assessment and proof-of-concept verification for CTF challenges and educational labs. Use when evaluating HTTP applications, APIs, client scripts, template engines, authentication flows, or smart-contract interfaces, including XSS, SQLi, SSTI, SSRF, XXE, JWT verification, access control evaluation, upload validation, request smuggling, and prototype pollution in sandboxed environments. Do not use it for native binary memory corruption, reverse engineering of standalone executables, or disk forensics.
4
+ license: MIT
5
+ compatibility: Requires filesystem-based agent (Claude Code or similar) with bash, Python 3, and internet access for tool installation.
6
+ allowed-tools: Bash Read Write Edit Glob Grep Task WebFetch WebSearch
7
+ metadata:
8
+ user-invocable: "false"
9
+ ---
10
+
11
+ # CTF Web Exploitation
12
+
13
+ Use this skill as a routing and execution guide for web-heavy challenges. Keep the first pass short: map the app, confirm the trust boundary, and only then dive into the detailed technique notes.
14
+
15
+ ## Prerequisites & Tooling
16
+
17
+ Pre-installed via [scripts/install_ctf_tools.sh](../../scripts/install_ctf_tools.sh):
18
+ - **Python packages**: `sqlmap`, `flask-unsign`, `requests` (in `~/.ctf-tools/venv`)
19
+ - **System tools**: `curl`, `jq`, `hashcat`, `ffuf`
20
+ - **Manual tools**: `ysoserial` (Java deserialization payloads)
21
+
22
+ ## Execution Environment & Tool Invocation
23
+
24
+ - **On Windows (WSL Kali Linux)**:
25
+ - Run Linux tools and virtualenv-installed Python modules directly inside WSL:
26
+ ```bash
27
+ wsl -d kali-linux bash -c "source ~/.ctf-tools/venv/bin/activate && <command>"
28
+ ```
29
+ - For web fuzzing and SQL injection:
30
+ ```bash
31
+ wsl -d kali-linux bash -c "ffuf -u http://target/FUZZ -w wordlist.txt"
32
+ wsl -d kali-linux bash -c "source ~/.ctf-tools/venv/bin/activate && sqlmap -u 'http://target/page?id=1' --batch"
33
+ ```
34
+ - **On Native Linux / WSL**:
35
+ - Activate the CTF virtualenv before executing Python exploits:
36
+ ```bash
37
+ source ~/.ctf-tools/venv/bin/activate
38
+ ```
39
+ - System binaries (`curl`, `ffuf`, `jq`, `sqlmap`, `hashcat`) are directly available in PATH.
40
+
41
+ ## Additional Resources
42
+
43
+ - [sql-injection.md](sql-injection.md) - SQL injection techniques: auth bypass, UNION extraction, filter bypasses, second-order SQLi, truncation, race-assisted leaks, INSERT ON DUPLICATE KEY UPDATE password overwrite, innodb_table_stats WAF bypass
44
+ - [server-side.md](server-side.md) - PHP type juggling, php://filter LFI, Python str.format traversal, SSTI (Jinja2, Twig, ERB, Mako, EJS, Vue.js, Smarty), SSRF (Host header, DNS rebinding, curl redirect, unescaped-dot regex, SNI FTP smuggling, mod_vhost_alias), PHP hash_hmac NULL
45
+ - [server-side-2.md](server-side-2.md) - XXE (basic, OOB, DOCX upload), XML injection via X-Forwarded-For, PHP variable variables, PHP uniqid predictable filename, sequential regex replacement bypass, command injection (newline, blocklist, sendmail CGI, multi-barcode, git CLI), GraphQL injection (introspection, batching, interpolation)
46
+ - [server-side-exec.md](server-side-exec.md) - Direct code execution paths, upload-to-RCE, deserialization-adjacent execution, LaTeX injection, header and API abuses
47
+ - [server-side-exec-2.md](server-side-exec-2.md) - More execution chains: SQLi fragmentation, path parser tricks, polyglot uploads, wrapper abuse, filename injection, BMP pixel webshell with filename truncation
48
+ - [server-side-deser.md](server-side-deser.md) - Java/Python/PHP deserialization and race-condition playbooks, PHP SoapClient CRLF SSRF via deserialization
49
+ - [server-side-advanced.md](server-side-advanced.md) - Advanced SSRF, traversal, archive, parser, framework, and modern app-server issues, Nginx alias traversal
50
+ - [server-side-advanced-2.md](server-side-advanced-2.md) - Docker API SSRF, Castor/XML, Apache expression reads, parser discrepancies, Windows path tricks, rogue MySQL server file read
51
+ - [server-side-advanced-3.md](server-side-advanced-3.md) - Part 3 (CSAW/35C3/ASIS/PlaidCTF 2018): WAV polyglot upload, multi-slash URL `path.startswith` bypass, Xalan XSLT `math:random()` seed guess, SoapClient `_user_agent` CRLF method smuggling, `gopher:///` no-host URL scheme bypass, SSRF credential leak via attacker-specified outbound URL
52
+ - [server-side-advanced-4.md](server-side-advanced-4.md) - Part 4: WeasyPrint SSRF/file read (CVE-2024-28184), MongoDB regex/$where blind oracle, Pongo2 Go template injection, ZIP PHP webshell, basename() bypass, wget CRLF SSRF→SMTP, Gopher SSRF to MySQL blind SQLi, React Server Components Flight RCE (CVE-2025-55182), AMQP/TLS interception via sslsplit+arpspoof, CairoSVG XXE, Bazaar repo reconstruction
53
+ - [client-side.md](client-side.md) - XSS, CSRF, cache poisoning, DOM tricks, admin bot abuse, request smuggling, paywall bypass
54
+ - [client-side-advanced.md](client-side-advanced.md) - CSP bypasses, Unicode tricks, XSSI, CSS exfiltration, browser normalization quirks, postMessage null origin bypass
55
+ - [auth-and-access.md](auth-and-access.md) - Auth/authz bypasses, hidden endpoints, IDOR, redirect chains, subdomain takeover, AI chatbot jailbreaks
56
+ - [auth-and-access-2.md](auth-and-access-2.md) - Part 2 (2018-era): `std::unordered_set` bucket collision auth bypass, `nodeprep.prepare` Unicode homograph username collision, SRP A=0/A=N auth bypass, ArangoDB AQL MERGE privilege escalation
57
+ - [auth-jwt.md](auth-jwt.md) - JWT/JWE manipulation, weak secrets, header injection, key confusion, replay
58
+ - [auth-infra.md](auth-infra.md) - OAuth/OIDC, SAML, CORS, CI/CD secrets, IdP abuse, login poisoning
59
+ - [node-and-prototype.md](node-and-prototype.md) - Prototype pollution, JS sandbox escape, Node.js attack chains
60
+ - [web3.md](web3.md) - Solidity and Web3 challenge notes
61
+ - [cves.md](cves.md) - CVE-driven techniques you can match against challenge banners, headers, dependency leaks, or version strings
62
+ - [field-notes.md](field-notes.md) - Long-form exploit notes: quick references for SQLi, XSS, LFI, JWT, SSTI, SSRF, command injection, XXE, deserialization, race conditions, auth bypass, and multi-stage chains
63
+
64
+ ## When to Pivot
65
+
66
+ - If the target is a native binary, custom VM, or firmware image, switch to `/ctf-reverse` first.
67
+ - If the HTTP bug only gives you code execution and the hard part becomes memory corruption or seccomp escape, switch to `/ctf-pwn`.
68
+ - If the "web" challenge really turns on JWT math, custom MACs, or crypto primitives, switch to `/ctf-crypto`.
69
+ - If the web challenge involves analyzing logs, PCAPs, or recovering artifacts from a web server, switch to `/ctf-forensics`.
70
+ - If the challenge requires gathering intelligence from public web sources, DNS records, or social media before exploitation, switch to `/ctf-osint`.
71
+
72
+ ## First-Pass Workflow
73
+
74
+ 1. Identify the real boundary: browser only, backend only, mixed app, or auth flow.
75
+ 2. Capture one normal request/response pair for every major feature before fuzzing.
76
+ 3. Enumerate hidden functionality from JS bundles, response headers, routes, and alternate methods.
77
+ 4. Classify the likely bug family: injection, authz, parser mismatch, upload, trust proxy, state machine, or client-side execution.
78
+ 5. Build the smallest proof first: leak, bypass, or primitive. Save full exploit chaining for later.
79
+
80
+ ## Quick Start Commands
81
+
82
+ ```bash
83
+ # Recon
84
+ curl -sI https://target.com
85
+ ffuf -u https://target.com/FUZZ -w wordlist.txt
86
+ curl -s https://target.com/robots.txt
87
+
88
+ # SQLi quick test
89
+ sqlmap -u "https://target.com/page?id=1" --batch --dbs
90
+
91
+ # JWT decode (no verification)
92
+ echo '<token>' | cut -d. -f2 | base64 -d 2>/dev/null | jq .
93
+
94
+ # Cookie decode (Flask)
95
+ flask-unsign --decode --cookie '<cookie>'
96
+ flask-unsign --unsign --cookie '<cookie>' --wordlist rockyou.txt
97
+
98
+ # SSTI probes
99
+ curl "https://target.com/page?name={{7*7}}"
100
+ curl "https://target.com/page?name={{config}}"
101
+
102
+ # Request inspection
103
+ curl -v -X POST https://target.com/api -H "Content-Type: application/json" -d '{}'
104
+ ```
105
+
106
+ ## First Questions to Answer
107
+
108
+ - Is the flag likely in the browser, an API response, a local file, a database row, or an internal service?
109
+ - Does the app trust user-controlled data in templates, redirects, file paths, headers, serialized objects, or background jobs?
110
+ - Are there multiple parsers disagreeing with each other: proxy vs app, URL parser vs fetcher, sanitizer vs browser, serializer vs filter?
111
+ - Can you turn the bug into a smaller primitive first: read one file, forge one token, call one internal endpoint, trigger one bot visit?
112
+
113
+ ## High-Value Recon Checks
114
+
115
+ - Read the HTML, inline scripts, and bundled JS before guessing the API surface.
116
+ - Compare what the UI submits with what the backend accepts; optional JSON fields often unlock hidden paths.
117
+ - Check obvious metadata and helper paths early: `/robots.txt`, `/sitemap.xml`, `/.well-known/`, `/admin`, `/debug`, `/.git/`, `/.env`.
118
+ - Try alternate verbs and content types on interesting routes: `GET`, `POST`, `PUT`, `PATCH`, `TRACE`, JSON, form, multipart, XML.
119
+ - Treat file upload, PDF/export, webhook, OAuth callback, and admin bot features as likely exploit multipliers.
120
+
121
+ ## Fast Pattern Map
122
+
123
+ - SQL errors, odd filtering, or state-dependent DB behavior: start with [sql-injection.md](sql-injection.md).
124
+ - Templating, file reads, SSRF, command execution, XML, or parser bugs: start with [server-side.md](server-side.md) and [server-side-exec.md](server-side-exec.md).
125
+ - XSS, CSP bypass, admin bot, client routing, DOM issues, or scriptless exfiltration: start with [client-side.md](client-side.md).
126
+ - Session forgery, hidden admin routes, JWT, OAuth, SAML, or weak trust boundaries: start with [auth-and-access.md](auth-and-access.md), [auth-jwt.md](auth-jwt.md), and [auth-infra.md](auth-infra.md).
127
+ - Node.js apps, prototype pollution, VM sandboxes, or SSRF into internal services: add [node-and-prototype.md](node-and-prototype.md).
128
+ - Smart contract frontends or blockchain-integrated apps: add [web3.md](web3.md).
129
+
130
+ ## Common Chain Shapes
131
+
132
+ - Recon -> hidden route -> auth bypass -> internal file read -> token or flag
133
+ - XSS or HTML injection -> admin bot -> privileged action -> secret leak
134
+ - Traversal or upload -> config/source leak -> secret recovery -> session forgery
135
+ - SSRF -> metadata or internal API -> credential leak -> code execution
136
+ - SQLi or NoSQL injection -> credential bypass -> second-stage template or upload abuse
137
+
138
+ ## Deep-Dive Notes
139
+
140
+ Use [field-notes.md](field-notes.md) once you have confirmed the challenge is truly web-heavy and you need the long exploit catalog.
141
+
142
+ - Recon, SQLi, XSS, traversal, JWT, SSTI, SSRF, XXE, and command injection quick notes
143
+ - Deserialization, race conditions, file upload to RCE, and multi-stage chain examples
144
+ - Node, OAuth/SAML, CI/CD, Web3, bot abuse, CSP bypasses, and modern browser tricks
145
+ - CVE-shaped playbooks and older challenge patterns that still show up in modern CTFs
146
+
147
+ ## Common Flag Locations
148
+
149
+ - Files: `/flag.txt`, `/flag`, `/app/flag.txt`, `/home/*/flag*`
150
+ - Environment: `/proc/self/environ`, process command line, debug config dumps
151
+ - Database: tables named `flag`, `flags`, `secret`, or seeded challenge content
152
+ - HTTP: custom headers, archived responses, hidden routes, admin exports
153
+ - Browser: hidden DOM nodes, `data-*` attributes, inline state objects, source maps
@@ -0,0 +1,82 @@
1
+ # CTF Web - Auth & Access Control Attacks (Part 2)
2
+
3
+ 2018-era additions: bucket-collision hash auth bypass, Unicode username homograph collision, SRP A=0/A=N bypass, ArangoDB AQL MERGE privilege escalation. For foundational auth/access techniques see [auth-and-access.md](auth-and-access.md). For JWT attacks see [auth-jwt.md](auth-jwt.md). For OAuth/OIDC/SAML/CI-CD, see [auth-infra.md](auth-infra.md).
4
+
5
+ ## Table of Contents
6
+ - [std::unordered_set Bucket Collision Auth Bypass (Hackover 2018)](#stdunordered_set-bucket-collision-auth-bypass-hackover-2018)
7
+ - [nodeprep.prepare Homograph Username Collision (HCTF 2018)](#nodeprepprepare-homograph-username-collision-hctf-2018)
8
+ - [SRP A=0, A=N Auth Bypass (OTW Advent 2018)](#srp-a0-an-auth-bypass-otw-advent-2018)
9
+ - [ArangoDB AQL MERGE Injection for Privilege Escalation (P.W.N. CTF 2018)](#arangodb-aql-merge-injection-for-privilege-escalation-pwn-ctf-2018)
10
+
11
+ ---
12
+
13
+ ## std::unordered_set Bucket Collision Auth Bypass (Hackover 2018)
14
+
15
+ **Pattern:** A C++ backend stores credential hashes in `std::unordered_set<std::string>`. The set's bucket index is derived from only the first bytes of a SHA-512 digest (truncated `size_t` hash). The lookup loop aborts early after a bounded number of bucket probes (`MAX_LOOKUPS = 1000`). Flood the set with 1000+ entries that all collide in the same bucket as the `root` account — the compare for the correct entry never executes and the call returns "found" on an attacker-chosen password.
16
+
17
+ ```cpp
18
+ // Vulnerable shape
19
+ std::unordered_set<std::string> users;
20
+ auto it = users.find(login_key); // probes at most MAX_LOOKUPS
21
+ if (it != users.end()) { /* accepted */ }
22
+ ```
23
+
24
+ ```python
25
+ # Flood registration: every entry collides in root's bucket
26
+ import requests
27
+ for i in range(1100):
28
+ requests.post("http://target/register",
29
+ data={"name": f"ro{i:04d}", "password": "ot1"})
30
+ # Log in as root with an arbitrary password — loop gives up before compare
31
+ requests.post("http://target/login", data={"name": "root", "password": "anything"})
32
+ ```
33
+
34
+ **Key insight:** Hash-table implementations that truncate digests into bucket indices expose a second-preimage surface: the attacker only has to match the bucket, not the full hash. When the data structure also has a bounded probe count (DoS guard), flooding the bucket turns an authentication check into an unconditional accept. Any `unordered_map`/`unordered_set` keyed on low-entropy derivations of user input is suspect — watch for `std::hash<std::string>` implementations that reduce to `size_t` via XOR-folding.
35
+
36
+ **References:** Hackover CTF 2018 — secure-hash, writeup 11502
37
+
38
+ ---
39
+
40
+ ## nodeprep.prepare Homograph Username Collision (HCTF 2018)
41
+
42
+ **Pattern:** Registration calls Node's `node-xmpp-server` `nodeprep.prepare(username)` which runs RFC-3491/Stringprep normalization. Unicode characters like `ᴬ` (U+1D2C Modifier Letter Capital A) normalize to ASCII `A`, then the existing user lookup finds the already-registered `admin`. Register `ᴬdmin` with any password, and the lookup returns the real admin row — set a new password via a password-reset flow.
43
+
44
+ ```text
45
+ username: \u1D2Cdmin # ᴬdmin
46
+ nodeprep.prepare("ᴬdmin") == "admin"
47
+ ```
48
+
49
+ **Key insight:** Any pipeline that (1) normalizes usernames before lookup but (2) stores the pre-normalized form separately is vulnerable. Normalize once at write-time and never accept users whose pre-normalized form collides with an existing row. Libraries to audit: `nodeprep`, `icu.normalize`, `unicodedata.normalize`, `golang.org/x/text/secure/precis`.
50
+
51
+ **References:** HCTF 2018 — admin, writeup 12132
52
+
53
+ ---
54
+
55
+ ## SRP A=0, A=N Auth Bypass (OTW Advent 2018)
56
+
57
+ **Pattern:** SRP (Secure Remote Password) implementations that do not validate `A % N != 0` allow the client to send `A = 0` (or `A = k*N`). The server computes `S = (A * v^u)^b mod N = 0`, so the session key is `H(0)` — known to the attacker. Bypass login without knowing the password.
58
+
59
+ ```text
60
+ Client: sends A = 0
61
+ Server: computes S = 0
62
+ Session key: K = H(0) # attacker knows this
63
+ ```
64
+
65
+ **Key insight:** SRP, DH, and similar group-based protocols need explicit validation that public values are nontrivial. Spec-compliant SRP rejects `A % N == 0`; buggy implementations don't. Same attack works for `A = N, 2N, ...`.
66
+
67
+ **References:** OverTheWire Advent Bonanza 2018 — writeup 12750
68
+
69
+ ---
70
+
71
+ ## ArangoDB AQL MERGE Injection for Privilege Escalation (P.W.N. CTF 2018)
72
+
73
+ **Pattern:** ArangoDB's AQL query language accepts user-supplied fragments that are concatenated into `FILTER` clauses. Inject `' || 1 == 1 LET newitem = MERGE(u, {'role':'admin'}) RETURN newitem //` to turn a login check into an in-memory role upgrade — the server returns the modified user object without touching the real record.
74
+
75
+ ```text
76
+ username: x' || 1 == 1 LET newitem = MERGE(u, {'role':'admin'}) RETURN newitem //
77
+ password: anything
78
+ ```
79
+
80
+ **Key insight:** NoSQL databases each have their own injection grammar. AQL's `MERGE` creates a new document inheriting the found record's fields, bypassing any ACL that only checks persistent storage. Always use parameterised bind variables.
81
+
82
+ **References:** P.W.N. CTF 2018 — H!pster Startup, writeup 12067