kuzushi 0.2.0 → 0.9.2

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 (87) hide show
  1. package/README.md +2 -0
  2. package/dist/agent-runtime/claude.js +15 -3
  3. package/dist/agent-runtime/claude.js.map +1 -1
  4. package/dist/agents/tasks/code-config-detect.js +3 -0
  5. package/dist/agents/tasks/code-config-detect.js.map +1 -1
  6. package/dist/agents/tasks/command-injection.js +10 -8
  7. package/dist/agents/tasks/command-injection.js.map +1 -1
  8. package/dist/agents/tasks/context-enricher.js +2 -0
  9. package/dist/agents/tasks/context-enricher.js.map +1 -1
  10. package/dist/agents/tasks/deserialization-detection.js +4 -1
  11. package/dist/agents/tasks/deserialization-detection.js.map +1 -1
  12. package/dist/agents/tasks/graphql-security.js +4 -1
  13. package/dist/agents/tasks/graphql-security.js.map +1 -1
  14. package/dist/agents/tasks/nosql-injection.js +6 -3
  15. package/dist/agents/tasks/nosql-injection.js.map +1 -1
  16. package/dist/agents/tasks/prototype-pollution.js +4 -1
  17. package/dist/agents/tasks/prototype-pollution.js.map +1 -1
  18. package/dist/agents/tasks/race-condition.js +4 -1
  19. package/dist/agents/tasks/race-condition.js.map +1 -1
  20. package/dist/agents/tasks/secrets-crypto-detect.js +3 -0
  21. package/dist/agents/tasks/secrets-crypto-detect.js.map +1 -1
  22. package/dist/agents/tasks/sharp-edges-detect.js +5 -0
  23. package/dist/agents/tasks/sharp-edges-detect.js.map +1 -1
  24. package/dist/agents/tasks/ssrf-detection.js +6 -1
  25. package/dist/agents/tasks/ssrf-detection.js.map +1 -1
  26. package/dist/agents/tasks/supply-chain.js +4 -1
  27. package/dist/agents/tasks/supply-chain.js.map +1 -1
  28. package/dist/agents/tasks/template-injection.js +6 -3
  29. package/dist/agents/tasks/template-injection.js.map +1 -1
  30. package/dist/agents/tasks/threat-modeling/randori-adapter.js +19 -2
  31. package/dist/agents/tasks/threat-modeling/randori-adapter.js.map +1 -1
  32. package/dist/agents/tasks/threat-modeling/randori-artifacts.js +69 -13
  33. package/dist/agents/tasks/threat-modeling/randori-artifacts.js.map +1 -1
  34. package/dist/agents/tasks/threat-modeling/randori.js +70 -30
  35. package/dist/agents/tasks/threat-modeling/randori.js.map +1 -1
  36. package/dist/agents/tasks/xxe-detection.js +4 -1
  37. package/dist/agents/tasks/xxe-detection.js.map +1 -1
  38. package/dist/cli/commands/scan.js +35 -5
  39. package/dist/cli/commands/scan.js.map +1 -1
  40. package/dist/cli.js +2 -1
  41. package/dist/cli.js.map +1 -1
  42. package/dist/migrations/024_rename_scanner_to_task_id.d.ts +13 -0
  43. package/dist/migrations/024_rename_scanner_to_task_id.js +25 -0
  44. package/dist/migrations/024_rename_scanner_to_task_id.js.map +1 -0
  45. package/dist/migrations/index.js +2 -0
  46. package/dist/migrations/index.js.map +1 -1
  47. package/dist/migrations/runner.js +7 -0
  48. package/dist/migrations/runner.js.map +1 -1
  49. package/dist/prompts/language-tuning.d.ts +38 -0
  50. package/dist/prompts/language-tuning.js +225 -0
  51. package/dist/prompts/language-tuning.js.map +1 -0
  52. package/dist/prompts/languages/c-cpp.d.ts +2 -0
  53. package/dist/prompts/languages/c-cpp.js +276 -0
  54. package/dist/prompts/languages/c-cpp.js.map +1 -0
  55. package/dist/prompts/languages/go.d.ts +2 -0
  56. package/dist/prompts/languages/go.js +252 -0
  57. package/dist/prompts/languages/go.js.map +1 -0
  58. package/dist/prompts/languages/index.d.ts +6 -0
  59. package/dist/prompts/languages/index.js +44 -0
  60. package/dist/prompts/languages/index.js.map +1 -0
  61. package/dist/prompts/languages/java-kotlin.d.ts +2 -0
  62. package/dist/prompts/languages/java-kotlin.js +495 -0
  63. package/dist/prompts/languages/java-kotlin.js.map +1 -0
  64. package/dist/prompts/languages/javascript-typescript.d.ts +2 -0
  65. package/dist/prompts/languages/javascript-typescript.js +421 -0
  66. package/dist/prompts/languages/javascript-typescript.js.map +1 -0
  67. package/dist/prompts/languages/php.d.ts +2 -0
  68. package/dist/prompts/languages/php.js +277 -0
  69. package/dist/prompts/languages/php.js.map +1 -0
  70. package/dist/prompts/languages/python.d.ts +2 -0
  71. package/dist/prompts/languages/python.js +283 -0
  72. package/dist/prompts/languages/python.js.map +1 -0
  73. package/dist/prompts/languages/ruby.d.ts +2 -0
  74. package/dist/prompts/languages/ruby.js +219 -0
  75. package/dist/prompts/languages/ruby.js.map +1 -0
  76. package/dist/prompts/languages/rust.d.ts +2 -0
  77. package/dist/prompts/languages/rust.js +149 -0
  78. package/dist/prompts/languages/rust.js.map +1 -0
  79. package/dist/prompts/languages/types.d.ts +79 -0
  80. package/dist/prompts/languages/types.js +9 -0
  81. package/dist/prompts/languages/types.js.map +1 -0
  82. package/dist/scanners/run-agentic.d.ts +2 -2
  83. package/dist/scanners/run-agentic.js +11 -3
  84. package/dist/scanners/run-agentic.js.map +1 -1
  85. package/dist/store.js +4 -0
  86. package/dist/store.js.map +1 -1
  87. package/package.json +1 -1
@@ -0,0 +1,277 @@
1
+ // NOTE: This file contains DETECTION PATTERNS for a security scanner.
2
+ // References to shell functions, SQL queries, etc. are DETECTION TARGETS
3
+ // describing what the scanner looks for, not code this file runs.
4
+ export const phpProfile = {
5
+ languageId: "PHP",
6
+ aliases: ["php"],
7
+ generalHints: {
8
+ grepPatterns: [
9
+ "\\$_GET",
10
+ "\\$_POST",
11
+ "\\$_REQUEST",
12
+ "\\$_SERVER",
13
+ "\\$_COOKIE",
14
+ "include\\s*\\(",
15
+ "require\\s*\\(",
16
+ ],
17
+ fileHints: [
18
+ "php.ini / .user.ini for security settings",
19
+ "composer.json for dependencies",
20
+ ".env for configuration secrets",
21
+ "routes/ or web.php for Laravel route definitions",
22
+ "config/ for framework configuration",
23
+ ],
24
+ instructions: [
25
+ "Check php.ini settings: display_errors, allow_url_include, register_globals",
26
+ "Look for direct superglobal usage ($_GET, $_POST) vs. framework request objects",
27
+ "Check for disabled functions in php.ini — are dangerous functions still enabled?",
28
+ "Review composer.json for outdated packages with known CVEs",
29
+ ],
30
+ },
31
+ generalAntiHallucination: [
32
+ "Laravel Eloquent with parameter binding is SAFE against SQL injection — do NOT flag Model::where('field', $val)",
33
+ "Laravel Blade templates auto-escape with {{ }} — only flag {!! !!} (raw output)",
34
+ "PDO prepared statements with parameter binding are SAFE against SQL injection",
35
+ ],
36
+ vulnClasses: {
37
+ "type-juggling": {
38
+ sinks: [
39
+ { api: "== loose comparison", risk: "PHP loose comparison: '0e123' == '0e456' evaluates true (scientific notation to 0)", cwes: ["CWE-697"] },
40
+ { api: "strcmp() with non-string input", risk: "strcmp(array, string) returns NULL which == 0 in loose comparison", cwes: ["CWE-697"] },
41
+ { api: "switch/case (loose comparison)", risk: "PHP switch uses loose comparison by default", cwes: ["CWE-697"] },
42
+ { api: "in_array without strict flag", risk: "in_array('0', ['password']) is true due to loose comparison", cwes: ["CWE-697"] },
43
+ ],
44
+ safePatterns: [
45
+ { api: "=== strict comparison", why: "Compares type AND value — no type juggling" },
46
+ { api: "hash_equals() for timing-safe comparison", why: "Constant-time and strict" },
47
+ { api: "in_array($val, $arr, true)", why: "Third arg true enables strict comparison" },
48
+ ],
49
+ investigationHints: {
50
+ grepPatterns: [
51
+ "\\s==\\s",
52
+ "strcmp\\(",
53
+ "in_array\\(",
54
+ "array_search\\(",
55
+ "switch\\s*\\(",
56
+ "hash_equals\\(",
57
+ ],
58
+ fileHints: [
59
+ "Authentication/login handlers",
60
+ "Token verification code",
61
+ "API key validation",
62
+ "Password reset handlers",
63
+ ],
64
+ instructions: [
65
+ "Check authentication code for == instead of === in password/token comparisons",
66
+ "Look for hash comparisons: md5($input) == $stored with == can be bypassed with magic hashes (0e...)",
67
+ "Check in_array and array_search calls — missing strict flag enables type juggling",
68
+ ],
69
+ },
70
+ fewShots: [
71
+ {
72
+ scenario: "Magic hash authentication bypass",
73
+ vulnerableCode: '$hash = md5($user_password);\nif ($hash == $stored_hash) {\n authenticate($user);\n}',
74
+ explanation: "If $stored_hash is '0e123...' (starts with 0e, rest is digits), PHP interprets it as 0 in scientific notation. Attacker finds a password whose MD5 also starts with '0e' followed by digits — both equal 0.",
75
+ },
76
+ ],
77
+ antiHallucinationExtra: [
78
+ "=== strict comparison is SAFE against type juggling — do NOT flag it",
79
+ "Loose == comparison with hardcoded integer literals (not user input) is low risk",
80
+ ],
81
+ },
82
+ deserialization: {
83
+ sinks: [
84
+ { api: "unserialize($user_input)", risk: "Triggers magic methods (__wakeup, __destruct) enabling RCE via POP chains", cwes: ["CWE-502"] },
85
+ { api: "unserialize with allowed_classes=true (default)", risk: "All classes allowed — POP gadgets available", cwes: ["CWE-502"] },
86
+ ],
87
+ safePatterns: [
88
+ { api: "json_decode($data)", why: "JSON parsing does not trigger code" },
89
+ { api: "unserialize($data, ['allowed_classes' => false])", why: "Blocks POP chains — converts objects to __PHP_Incomplete_Class" },
90
+ ],
91
+ investigationHints: {
92
+ grepPatterns: [
93
+ "unserialize\\(",
94
+ "allowed_classes",
95
+ "serialize\\(",
96
+ "__wakeup",
97
+ "__destruct",
98
+ ],
99
+ fileHints: [
100
+ "Session handling code",
101
+ "Cache implementations",
102
+ "Cookie processing",
103
+ ],
104
+ instructions: [
105
+ "Check if unserialize processes data from cookies, database, or HTTP input",
106
+ "Look for classes with __wakeup or __destruct methods — POP gadget candidates",
107
+ "Check if allowed_classes option is set in unserialize calls (PHP 7.0+)",
108
+ ],
109
+ },
110
+ fewShots: [
111
+ {
112
+ scenario: "Cookie-based deserialization attack",
113
+ vulnerableCode: '$prefs = unserialize(base64_decode($_COOKIE["user_prefs"]));',
114
+ explanation: "User controls cookie value. unserialize instantiates arbitrary classes and triggers __wakeup/__destruct. If a gadget chain exists, attacker achieves RCE.",
115
+ },
116
+ ],
117
+ antiHallucinationExtra: [
118
+ "json_decode() is SAFE — it does not instantiate objects or trigger magic methods",
119
+ ],
120
+ },
121
+ "command-injection": {
122
+ sinks: [
123
+ { api: "system($cmd)", risk: "Shell interpretation of command string", shellInvoking: true, cwes: ["CWE-78"] },
124
+ { api: "passthru($cmd)", risk: "Shell interpretation with raw output", shellInvoking: true, cwes: ["CWE-78"] },
125
+ { api: "shell_exec($cmd) / backtick operator", risk: "Shell interpretation", shellInvoking: true, cwes: ["CWE-78"] },
126
+ { api: "popen($cmd, $mode)", risk: "Shell interpretation", shellInvoking: true, cwes: ["CWE-78"] },
127
+ { api: "proc_open($cmd, ...)", risk: "Shell interpretation if cmd is string", shellInvoking: true, cwes: ["CWE-78"] },
128
+ ],
129
+ safePatterns: [
130
+ { api: "escapeshellarg() wrapping each argument", why: "Escapes shell metacharacters in arguments" },
131
+ { api: "proc_open with array command (PHP 7.4+)", why: "Array form bypasses shell interpretation" },
132
+ ],
133
+ investigationHints: {
134
+ grepPatterns: [
135
+ "\\bsystem\\(",
136
+ "passthru\\(",
137
+ "shell_exec\\(",
138
+ "popen\\(",
139
+ "proc_open\\(",
140
+ "escapeshellarg",
141
+ ],
142
+ fileHints: [
143
+ "Image/file processing handlers",
144
+ "Admin/utility scripts",
145
+ "Cron job handlers",
146
+ ],
147
+ instructions: [
148
+ "PHP has many shell functions — check all of them (system, passthru, shell_exec, popen, proc_open, backticks)",
149
+ "Look for string concatenation with $_GET/$_POST values into command strings",
150
+ "Check if escapeshellarg is applied to EVERY user-controlled part of the command",
151
+ ],
152
+ },
153
+ fewShots: [
154
+ {
155
+ scenario: "Image conversion with user-controlled filename",
156
+ vulnerableCode: '$file = $_POST["filename"];\nsystem("convert " . $file . " output.png");',
157
+ explanation: "$_POST['filename'] is user-controlled. Attacker sends 'img.png; cat /etc/passwd' — shell interprets semicolon.",
158
+ },
159
+ ],
160
+ antiHallucinationExtra: [
161
+ "escapeshellarg() properly applied to all user inputs in a command is sufficient protection",
162
+ "Do NOT flag shell functions with fully hardcoded command strings and no user input",
163
+ ],
164
+ },
165
+ ssrf: {
166
+ sinks: [
167
+ { api: "file_get_contents($url)", risk: "Fetches URL — can reach internal services and use file:// protocol", cwes: ["CWE-918"] },
168
+ { api: "curl with user-controlled CURLOPT_URL", risk: "User-controlled URL in cURL request", cwes: ["CWE-918"] },
169
+ { api: "fopen($url)", risk: "PHP fopen supports URL wrappers when allow_url_fopen is enabled", cwes: ["CWE-918"] },
170
+ ],
171
+ safePatterns: [
172
+ { api: "URL validated against domain allowlist", why: "Restricts reachable hosts" },
173
+ { api: "CURLOPT_PROTOCOLS set to CURLPROTO_HTTPS only", why: "Blocks file:// and other dangerous protocols" },
174
+ ],
175
+ investigationHints: {
176
+ grepPatterns: [
177
+ "file_get_contents\\(",
178
+ "curl_setopt.*CURLOPT_URL",
179
+ "curl_exec\\(",
180
+ "fopen\\(",
181
+ "CURLOPT_FOLLOWLOCATION",
182
+ ],
183
+ fileHints: ["Webhook handlers", "URL preview features", "File import features"],
184
+ instructions: [
185
+ "Check php.ini allow_url_fopen — when enabled, fopen/file_get_contents accept URLs",
186
+ "file_get_contents supports php:// and other wrappers — check if user controls the scheme",
187
+ ],
188
+ },
189
+ fewShots: [
190
+ {
191
+ scenario: "URL preview with SSRF",
192
+ vulnerableCode: '$url = $_GET["url"];\n$content = file_get_contents($url);\necho extractTitle($content);',
193
+ explanation: "User-controlled URL to file_get_contents. Attacker sends url=file:///etc/passwd for local file read or url=http://169.254.169.254/ for cloud metadata.",
194
+ },
195
+ ],
196
+ antiHallucinationExtra: [
197
+ "file_get_contents with a hardcoded file path (not user-controlled) is NOT SSRF",
198
+ ],
199
+ },
200
+ "include-injection": {
201
+ sinks: [
202
+ { api: "include($user_path)", risk: "Runs PHP code from attacker-controlled file path", cwes: ["CWE-98"] },
203
+ { api: "require($user_path)", risk: "Same as include — runs PHP from controlled path", cwes: ["CWE-98"] },
204
+ { api: "include_once/require_once($user_path)", risk: "Same risk — path is still attacker-controlled", cwes: ["CWE-98"] },
205
+ ],
206
+ safePatterns: [
207
+ { api: "include with hardcoded path", why: "Path is constant — no user control" },
208
+ { api: "Allowlist mapping user input to fixed paths", why: "User selects from safe options" },
209
+ { api: "basename() + directory prefix", why: "Strips directory traversal" },
210
+ ],
211
+ investigationHints: {
212
+ grepPatterns: [
213
+ "include\\s*\\(",
214
+ "require\\s*\\(",
215
+ "include_once",
216
+ "require_once",
217
+ ],
218
+ fileHints: ["Routing/dispatcher code", "Template loaders", "Plugin systems"],
219
+ instructions: [
220
+ "Check if include/require paths contain user input",
221
+ "Look for directory traversal: can user input contain ../ ?",
222
+ "With allow_url_include=On, include can fetch remote URLs",
223
+ ],
224
+ },
225
+ fewShots: [
226
+ {
227
+ scenario: "Local file inclusion via page parameter",
228
+ vulnerableCode: '$page = $_GET["page"];\ninclude("templates/" . $page . ".php");',
229
+ explanation: "Attacker sends page=../../config to read sensitive files. With allow_url_include, attacker can include remote PHP code.",
230
+ },
231
+ ],
232
+ antiHallucinationExtra: [
233
+ "include/require with fully hardcoded paths and no user input are SAFE",
234
+ ],
235
+ },
236
+ sqli: {
237
+ sinks: [
238
+ { api: "mysql_query with string concat", risk: "Direct SQL concatenation — classic injection", cwes: ["CWE-89"] },
239
+ { api: "mysqli_query with string interpolation", risk: "User input in SQL string", cwes: ["CWE-89"] },
240
+ { api: "PDO::query with concat", risk: "PDO query without prepared statements", cwes: ["CWE-89"] },
241
+ { api: "DB::raw($user_input) in Laravel", risk: "Raw SQL expression with user input", cwes: ["CWE-89"] },
242
+ ],
243
+ safePatterns: [
244
+ { api: "PDO prepared statements with placeholders", why: "Parameterized query — safe" },
245
+ { api: "mysqli_prepare + bind_param", why: "Parameterized query" },
246
+ { api: "Laravel Eloquent parameter binding", why: "Model::where('field', $val) is parameterized" },
247
+ ],
248
+ investigationHints: {
249
+ grepPatterns: [
250
+ "mysql_query\\(",
251
+ "mysqli_query\\(",
252
+ "->query\\(",
253
+ "DB::raw\\(",
254
+ "->whereRaw\\(",
255
+ "prepare\\(",
256
+ ],
257
+ fileHints: ["Database access layer", "Search implementations", "Report queries"],
258
+ instructions: [
259
+ "Check for string concatenation or interpolation in SQL queries",
260
+ "In Laravel: look for DB::raw(), whereRaw(), selectRaw() with user input",
261
+ ],
262
+ },
263
+ fewShots: [
264
+ {
265
+ scenario: "Search with SQL injection",
266
+ vulnerableCode: '$search = $_GET["q"];\n$result = $db->query("SELECT * FROM products WHERE name LIKE \'%" . $search . "%\'");',
267
+ explanation: "User-controlled $search concatenated into SQL. Attacker sends q=' UNION SELECT password FROM users -- to extract data.",
268
+ },
269
+ ],
270
+ antiHallucinationExtra: [
271
+ "PDO prepared statements with placeholders are SAFE",
272
+ "Laravel Eloquent Model::where('field', $val) is SAFE — only flag raw SQL methods",
273
+ ],
274
+ },
275
+ },
276
+ };
277
+ //# sourceMappingURL=php.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"php.js","sourceRoot":"","sources":["../../../src/prompts/languages/php.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,yEAAyE;AACzE,kEAAkE;AAIlE,MAAM,CAAC,MAAM,UAAU,GAAoB;IACzC,UAAU,EAAE,KAAK;IACjB,OAAO,EAAE,CAAC,KAAK,CAAC;IAChB,YAAY,EAAE;QACZ,YAAY,EAAE;YACZ,SAAS;YACT,UAAU;YACV,aAAa;YACb,YAAY;YACZ,YAAY;YACZ,gBAAgB;YAChB,gBAAgB;SACjB;QACD,SAAS,EAAE;YACT,2CAA2C;YAC3C,gCAAgC;YAChC,gCAAgC;YAChC,kDAAkD;YAClD,qCAAqC;SACtC;QACD,YAAY,EAAE;YACZ,6EAA6E;YAC7E,iFAAiF;YACjF,kFAAkF;YAClF,4DAA4D;SAC7D;KACF;IACD,wBAAwB,EAAE;QACxB,iHAAiH;QACjH,iFAAiF;QACjF,+EAA+E;KAChF;IACD,WAAW,EAAE;QACX,eAAe,EAAE;YACf,KAAK,EAAE;gBACL,EAAE,GAAG,EAAE,qBAAqB,EAAE,IAAI,EAAE,oFAAoF,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE;gBAC7I,EAAE,GAAG,EAAE,gCAAgC,EAAE,IAAI,EAAE,mEAAmE,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE;gBACvI,EAAE,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NOTE: This file contains DETECTION PATTERNS for a security scanner.
2
+ // The API references (subprocess, pickle, etc.) are DETECTION TARGETS
3
+ // describing what the scanner looks for in scanned codebases,
4
+ // not code this file executes.
5
+ export const pythonProfile = {
6
+ languageId: "Python",
7
+ aliases: ["python", "py", "python3"],
8
+ generalHints: {
9
+ grepPatterns: [
10
+ "import\\s+subprocess",
11
+ "import\\s+os",
12
+ "from\\s+flask",
13
+ "from\\s+django",
14
+ "from\\s+fastapi",
15
+ "@app\\.route",
16
+ "def\\s+\\w+.*request",
17
+ ],
18
+ fileHints: [
19
+ "settings.py / config.py for Django/Flask configuration",
20
+ "requirements.txt / pyproject.toml for dependency versions",
21
+ "urls.py for Django route definitions",
22
+ "views.py / routes.py for request handlers",
23
+ "manage.py and management/commands/ for Django management commands",
24
+ "celery tasks (tasks.py) for background job handlers",
25
+ ],
26
+ instructions: [
27
+ "Check Django settings for DEBUG, ALLOWED_HOSTS, SECRET_KEY, SECURE_* flags",
28
+ "Look for Flask routes with methods=['POST'] and raw request.data access",
29
+ "Check FastAPI Depends() chains for missing auth dependencies",
30
+ "Inspect Celery task arguments — are they user-controlled?",
31
+ ],
32
+ },
33
+ generalAntiHallucination: [
34
+ "Django ORM parameterized queries are SAFE against SQL injection — do NOT flag Model.objects.filter(field=value)",
35
+ "Flask/Django built-in template rendering auto-escapes by default — only flag |safe or Markup() usage",
36
+ "Python json.loads() is SAFE — it does not run code during deserialization",
37
+ ],
38
+ vulnClasses: {
39
+ "command-injection": {
40
+ sinks: [
41
+ { api: "os.system(cmd)", risk: "Full shell interpretation of cmd string", shellInvoking: true, cwes: ["CWE-78"] },
42
+ { api: "os.popen(cmd)", risk: "Shell interpretation, returns pipe", shellInvoking: true, cwes: ["CWE-78"] },
43
+ { api: "subprocess with shell=True", risk: "Shell interpretation when shell=True", shellInvoking: true, cwes: ["CWE-78"] },
44
+ { api: "subprocess with list args, shell=False", risk: "SAFE against metachar injection when passed as list", shellInvoking: false, cwes: ["CWE-78"] },
45
+ ],
46
+ safePatterns: [
47
+ { api: "subprocess.run([cmd, arg1, arg2])", why: "List args with shell=False (default) prevents metachar injection" },
48
+ { api: "shlex.quote() wrapping user input", why: "Proper shell escaping before insertion into command string" },
49
+ { api: "subprocess with all hardcoded arguments", why: "No attacker-controlled data in arguments" },
50
+ ],
51
+ investigationHints: {
52
+ grepPatterns: [
53
+ "os\\.system\\(",
54
+ "os\\.popen\\(",
55
+ "subprocess\\.",
56
+ "shell=True",
57
+ "shlex\\.quote",
58
+ ],
59
+ fileHints: [
60
+ "Django management commands (management/commands/)",
61
+ "Celery tasks (tasks.py)",
62
+ "Scripts that invoke external tools (ffmpeg, imagemagick, git)",
63
+ ],
64
+ instructions: [
65
+ "Check if subprocess calls use shell=True — this is the critical distinction in Python",
66
+ "Look for f-strings or .format() constructing shell command strings with user data",
67
+ "Check Django management commands for subprocess calls with user-influenced arguments",
68
+ "Inspect Celery task definitions — their arguments may come from untrusted web requests",
69
+ ],
70
+ },
71
+ fewShots: [
72
+ {
73
+ scenario: "Django management command with shell injection",
74
+ vulnerableCode: 'def handle(self, *args, **options):\n db_name = options["database"]\n subprocess.call(f"pg_dump {db_name}", shell=True)',
75
+ explanation: "db_name from command options flows to shell via f-string with shell=True. If db_name is user-influenced, attacker injects shell commands.",
76
+ },
77
+ ],
78
+ frameworkGuidance: [
79
+ {
80
+ framework: "Django",
81
+ defaults: ["Django ORM avoids most need for shell commands"],
82
+ pitfalls: ["Management commands often use subprocess for database/migration tools", "Settings values (DB name, paths) may flow to subprocess calls"],
83
+ configChecks: ["Check DATABASES config for names flowing to shell commands"],
84
+ },
85
+ ],
86
+ antiHallucinationExtra: [
87
+ "subprocess.run() with a list argument and shell=False (the default) is SAFE against metachar injection — do NOT flag it",
88
+ "Do NOT flag subprocess calls where all arguments are hardcoded strings with no user data",
89
+ ],
90
+ },
91
+ deserialization: {
92
+ sinks: [
93
+ { api: "pickle.loads/load", risk: "Runs arbitrary Python code during deserialization via __reduce__", cwes: ["CWE-502"] },
94
+ { api: "yaml.load() without SafeLoader", risk: "YAML !!python/object tags run arbitrary code", cwes: ["CWE-502"] },
95
+ { api: "shelve.open()", risk: "Uses pickle internally — same code-exec risk", cwes: ["CWE-502"] },
96
+ { api: "marshal.loads()", risk: "Can run code via crafted bytecode objects", cwes: ["CWE-502"] },
97
+ { api: "dill.loads()", risk: "Extended pickle — same arbitrary code execution", cwes: ["CWE-502"] },
98
+ { api: "jsonpickle.decode()", risk: "Deserializes Python objects from JSON — code-exec via crafted payloads", cwes: ["CWE-502"] },
99
+ ],
100
+ safePatterns: [
101
+ { api: "json.loads(data)", why: "JSON parsing does NOT run code — safe for untrusted input" },
102
+ { api: "yaml.safe_load(data)", why: "SafeLoader rejects dangerous YAML tags" },
103
+ { api: "yaml.load(data, Loader=SafeLoader)", why: "Explicitly safe loader" },
104
+ ],
105
+ investigationHints: {
106
+ grepPatterns: [
107
+ "pickle\\.",
108
+ "yaml\\.load\\(",
109
+ "yaml\\.unsafe_load",
110
+ "shelve\\.",
111
+ "marshal\\.",
112
+ "dill\\.",
113
+ "jsonpickle\\.",
114
+ "SafeLoader",
115
+ ],
116
+ fileHints: [
117
+ "Cache backends (Redis/Memcached serialization)",
118
+ "Celery result backends and message serializers",
119
+ "Session storage implementations",
120
+ "ML model loading code (joblib, torch.load)",
121
+ ],
122
+ instructions: [
123
+ "Check if pickle/yaml.load processes data from HTTP requests, message queues, or uploaded files",
124
+ "Look at Celery configuration — CELERY_ACCEPT_CONTENT and CELERY_RESULT_SERIALIZER settings control serialization format",
125
+ "Check ML model loading — torch.load and joblib.load use pickle internally",
126
+ "Inspect cache get/set operations — some cache backends serialize with pickle by default",
127
+ ],
128
+ },
129
+ fewShots: [
130
+ {
131
+ scenario: "Flask endpoint deserializing uploaded data unsafely",
132
+ vulnerableCode: '@app.route("/import", methods=["POST"])\ndef import_data():\n data = pickle.loads(request.data)\n return process(data)',
133
+ explanation: "request.data is attacker-controlled. Unsafe deserialization runs arbitrary code via __reduce__ method in crafted payloads.",
134
+ },
135
+ ],
136
+ frameworkGuidance: [
137
+ {
138
+ framework: "Django",
139
+ defaults: ["Django sessions use JSON serializer by default since 1.6"],
140
+ pitfalls: ["SESSION_SERIALIZER can be changed to PickleSerializer", "Cache backends may use pickle"],
141
+ configChecks: ["Check SESSION_SERIALIZER in settings.py", "Check CACHES backend configuration"],
142
+ },
143
+ {
144
+ framework: "Flask",
145
+ defaults: ["Flask session cookies are signed and use JSON by default"],
146
+ pitfalls: ["Flask-Caching with certain backends may use pickle", "Custom session stores may use pickle"],
147
+ configChecks: ["Check CACHE_TYPE configuration"],
148
+ },
149
+ ],
150
+ antiHallucinationExtra: [
151
+ "json.loads() is SAFE — it does NOT run code. Never flag JSON deserialization as unsafe",
152
+ "yaml.safe_load() is SAFE — only flag yaml.load() without SafeLoader or yaml.unsafe_load()",
153
+ "torch.load with weights_only=True is safe (PyTorch 2.6+)",
154
+ ],
155
+ },
156
+ "template-injection": {
157
+ sinks: [
158
+ { api: "jinja2.Template(user_str).render()", risk: "User-controlled Jinja2 template — SSTI enables RCE via __class__.__mro__ chain", cwes: ["CWE-1336"] },
159
+ { api: "render_template_string(user_str)", risk: "Flask helper that compiles user string as Jinja2 template", cwes: ["CWE-1336"] },
160
+ { api: "mako.template.Template(user_str)", risk: "Mako templates allow Python code execution", cwes: ["CWE-1336"] },
161
+ ],
162
+ safePatterns: [
163
+ { api: "render_template('file.html', var=user_data)", why: "User data passed as variable, not as template source — Jinja2 auto-escapes" },
164
+ { api: "Jinja2 SandboxedEnvironment", why: "Restricts template capabilities (but can be bypassed — verify version)" },
165
+ ],
166
+ investigationHints: {
167
+ grepPatterns: [
168
+ "render_template_string",
169
+ "Template\\(",
170
+ "from_string\\(",
171
+ "Environment\\(",
172
+ ],
173
+ fileHints: [
174
+ "View functions that render templates",
175
+ "Email template generation code",
176
+ "Report/PDF generation code",
177
+ ],
178
+ instructions: [
179
+ "Check if user input is passed as the template string (first arg) vs. as a template variable",
180
+ "render_template('file.html', name=user_input) is SAFE — render_template_string(user_input) is DANGEROUS",
181
+ "Look for custom template rendering in email/notification systems",
182
+ ],
183
+ },
184
+ fewShots: [
185
+ {
186
+ scenario: "Flask SSTI via render_template_string",
187
+ vulnerableCode: '@app.route("/greet")\ndef greet():\n name = request.args.get("name")\n return render_template_string(f"Hello {name}!")',
188
+ explanation: "User-controlled name is interpolated into the template string before Jinja2 compiles it. Attacker sends {{config.items()}} to extract secrets or chain to RCE.",
189
+ },
190
+ ],
191
+ antiHallucinationExtra: [
192
+ "render_template('template.html', var=user_input) is SAFE — user data is a variable, not the template",
193
+ "Jinja2 auto-escapes HTML by default — this prevents XSS but NOT SSTI (different vulnerability class)",
194
+ ],
195
+ },
196
+ ssrf: {
197
+ sinks: [
198
+ { api: "requests.get/post(url)", risk: "URL from user input can target internal services", cwes: ["CWE-918"] },
199
+ { api: "urllib.request.urlopen(url)", risk: "No URL validation — can reach internal endpoints", cwes: ["CWE-918"] },
200
+ { api: "httpx.get/post(url)", risk: "Same risk as requests — user-controlled URL", cwes: ["CWE-918"] },
201
+ { api: "aiohttp.ClientSession.get(url)", risk: "Async HTTP client with user-controlled URL", cwes: ["CWE-918"] },
202
+ ],
203
+ safePatterns: [
204
+ { api: "URL validated against allowlist of domains", why: "Only permitted domains are reachable" },
205
+ { api: "Requests to hardcoded URLs with user data in body/params", why: "URL is fixed, user controls only payload" },
206
+ ],
207
+ investigationHints: {
208
+ grepPatterns: [
209
+ "requests\\.(get|post|put|delete|head)\\(",
210
+ "urlopen\\(",
211
+ "httpx\\.",
212
+ "aiohttp",
213
+ ],
214
+ fileHints: [
215
+ "Webhook handlers",
216
+ "URL preview/unfurl features",
217
+ "Proxy or redirect endpoints",
218
+ "File download/import from URL features",
219
+ ],
220
+ instructions: [
221
+ "Check if the URL parameter comes from user input (request args, form data, database record from user)",
222
+ "Look for URL parsing that can be bypassed (checking startswith('http') does not prevent http://internal)",
223
+ "Check for redirect following — requests follows redirects by default, which can bypass URL checks",
224
+ "Cloud metadata: can the URL reach 169.254.169.254 (AWS), metadata.google.internal, etc.?",
225
+ ],
226
+ },
227
+ fewShots: [
228
+ {
229
+ scenario: "Webhook URL validation bypass",
230
+ vulnerableCode: '@app.route("/webhook", methods=["POST"])\ndef register_webhook():\n url = request.json["callback_url"]\n if not url.startswith("https://"):\n abort(400)\n requests.get(url)',
231
+ explanation: "startswith check is insufficient — attacker sends https://169.254.169.254/latest/meta-data/ to reach AWS metadata endpoint.",
232
+ },
233
+ ],
234
+ antiHallucinationExtra: [
235
+ "Requests to hardcoded URLs with only user-controlled query params or body data are NOT SSRF",
236
+ "Internal service-to-service calls with no user-controlled URL component are NOT SSRF",
237
+ ],
238
+ },
239
+ "race-condition": {
240
+ sinks: [
241
+ { api: "Shared mutable state without locks", risk: "Concurrent access to shared dict/list/object from multiple threads or async tasks", cwes: ["CWE-362"] },
242
+ { api: "TOCTOU on filesystem", risk: "Check-then-act on file existence/permissions with race window", cwes: ["CWE-367"] },
243
+ { api: "Django get_or_create without select_for_update", risk: "Race between check and create in concurrent requests", cwes: ["CWE-362"] },
244
+ ],
245
+ safePatterns: [
246
+ { api: "threading.Lock / asyncio.Lock around shared state", why: "Proper synchronization" },
247
+ { api: "Django select_for_update()", why: "Database-level row locking prevents concurrent modification" },
248
+ { api: "Atomic database operations (F() expressions, update())", why: "Single SQL statement is atomic" },
249
+ ],
250
+ investigationHints: {
251
+ grepPatterns: [
252
+ "threading\\.Thread",
253
+ "asyncio\\.gather",
254
+ "concurrent\\.futures",
255
+ "get_or_create",
256
+ "select_for_update",
257
+ ],
258
+ fileHints: [
259
+ "Background task/worker code",
260
+ "Payment or balance-modifying endpoints",
261
+ "User registration or resource allocation code",
262
+ ],
263
+ instructions: [
264
+ "Look for read-modify-write patterns on shared state without locking",
265
+ "Check Django views that modify balances/counters — are they using F() expressions or select_for_update?",
266
+ "In async code, check if shared state is modified across await points without asyncio.Lock",
267
+ ],
268
+ },
269
+ fewShots: [
270
+ {
271
+ scenario: "Double-spend via Django balance update race",
272
+ vulnerableCode: 'def withdraw(request):\n account = Account.objects.get(user=request.user)\n if account.balance >= amount:\n account.balance -= amount\n account.save()',
273
+ explanation: "Two concurrent requests both read the same balance, both pass the check, both subtract — double withdrawal. Fix: use select_for_update() or F() expressions.",
274
+ },
275
+ ],
276
+ antiHallucinationExtra: [
277
+ "Single-threaded Python code (no threading/asyncio) is NOT vulnerable to race conditions via the GIL (but IO-bound async code CAN race)",
278
+ "Django ORM operations that use F() expressions are atomic at the database level",
279
+ ],
280
+ },
281
+ },
282
+ };
283
+ //# sourceMappingURL=python.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"python.js","sourceRoot":"","sources":["../../../src/prompts/languages/python.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,8DAA8D;AAC9D,+BAA+B;AAI/B,MAAM,CAAC,MAAM,aAAa,GAAoB;IAC5C,UAAU,EAAE,QAAQ;IACpB,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC;IACpC,YAAY,EAAE;QACZ,YAAY,EAAE;YACZ,sBAAsB;YACtB,cAAc;YACd,eAAe;YACf,gBAAgB;YAChB,iBAAiB;YACjB,cAAc;YACd,sBAAsB;SACvB;QACD,SAAS,EAAE;YACT,wDAAwD;YACxD,2DAA2D;YAC3D,sCAAsC;YACtC,2CAA2C;YAC3C,mEAAmE;YACnE,qDAAqD;SACtD;QACD,YAAY,EAAE;YACZ,4EAA4E;YAC5E,yEAAyE;YACzE,8DAA8D;YAC9D,2DAA2D;SAC5D;KACF;IACD,wBAAwB,EAAE;QACxB,iHAAiH;QACjH,sGAAsG;QACtG,2EAA2E;KAC5E;IACD,WAAW,EAAE;QACX,mBAAmB,EAAE;YACnB,KAAK,EAAE;gBACL,EAAE,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,yCAAyC,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE;gBACjH,EAAE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