@arvyx/mcp 0.0.0-stage → 0.4.1

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.
@@ -0,0 +1,393 @@
1
+ # Arvyx SAST rules (Opengrep / Semgrep-compatible syntax). Written by Arvyx; no
2
+ # third-party rule registry content. Focus: the high-impact mistakes common in AI-generated apps.
3
+ # Severity: ERROR = high, WARNING = medium, INFO = low (capped server-side by CODE_INSECURE_PATTERN).
4
+ rules:
5
+ # ------------------------------------------------------------------ SQL injection
6
+ - id: sql-built-from-template-literal
7
+ languages: [javascript, typescript]
8
+ severity: ERROR
9
+ message: >-
10
+ SQL is built by interpolating values into a template string. If any value comes from the request,
11
+ an attacker can change the query. Pass values as parameters ($1 / ?) or use the query builder.
12
+ metadata: {title: "SQL query built with string interpolation", cwe: ["CWE-89"]}
13
+ patterns:
14
+ - pattern-either:
15
+ - pattern: $DB.query(`...${$X}...`, ...)
16
+ - pattern: $DB.execute(`...${$X}...`, ...)
17
+ - pattern: $DB.$queryRawUnsafe(`...${$X}...`, ...)
18
+ - pattern: $DB.$executeRawUnsafe(`...${$X}...`, ...)
19
+ - pattern: $DB.raw(`...${$X}...`, ...)
20
+ - pattern: $DB.unsafe(`...${$X}...`, ...)
21
+ - id: sql-built-by-concatenation
22
+ languages: [javascript, typescript]
23
+ severity: ERROR
24
+ message: >-
25
+ SQL is built by concatenating strings. If any part comes from the request, an attacker can change the
26
+ query. Pass values as parameters ($1 / ?) instead.
27
+ metadata: {title: "SQL query built by string concatenation", cwe: ["CWE-89"]}
28
+ patterns:
29
+ - pattern-either:
30
+ - pattern: $DB.query($Q, ...)
31
+ - pattern: $DB.execute($Q, ...)
32
+ - pattern: $DB.raw($Q, ...)
33
+ - pattern: $DB.$queryRawUnsafe($Q, ...)
34
+ - pattern: $DB.$executeRawUnsafe($Q, ...)
35
+ - metavariable-pattern:
36
+ metavariable: $Q
37
+ patterns:
38
+ - pattern-either:
39
+ - pattern: '"..." + $X'
40
+ - pattern: '$X + "..."'
41
+ - pattern-not: '"..." + "..."'
42
+ - id: python-sql-formatted
43
+ languages: [python]
44
+ severity: ERROR
45
+ message: >-
46
+ SQL is built with an f-string, % or + formatting. If any value comes from the request, an attacker can
47
+ change the query. Use parameters: cursor.execute("... WHERE id = %s", (value,)).
48
+ metadata: {title: "SQL query built with string formatting", cwe: ["CWE-89"]}
49
+ pattern-either:
50
+ - pattern: $C.execute(f"...", ...)
51
+ - pattern: $C.execute("..." % $X, ...)
52
+ - pattern: $C.execute("..." + $X, ...)
53
+ - pattern: $C.execute("...".format(...), ...)
54
+ - pattern: $C.executemany(f"...", ...)
55
+ - pattern: sqlalchemy.text(f"...")
56
+ - pattern: text(f"...")
57
+
58
+ # ------------------------------------------------------------------ command / code injection
59
+ - id: shell-command-from-string
60
+ languages: [javascript, typescript]
61
+ severity: ERROR
62
+ message: >-
63
+ A shell command is built from a string with interpolated values. If a value comes from a user, they can
64
+ run arbitrary commands on your server. Use execFile/spawn with an argument array.
65
+ metadata: {title: "Shell command built from a string", cwe: ["CWE-78"]}
66
+ pattern-either:
67
+ - pattern: $CP.exec(`...${$X}...`, ...)
68
+ - pattern: $CP.execSync(`...${$X}...`, ...)
69
+ - pattern: $CP.exec("..." + $X, ...)
70
+ - pattern: $CP.execSync("..." + $X, ...)
71
+ - pattern: exec(`...${$X}...`, ...)
72
+ - pattern: execSync(`...${$X}...`, ...)
73
+ - id: python-shell-true
74
+ languages: [python]
75
+ severity: ERROR
76
+ message: >-
77
+ subprocess runs with shell=True. If any part of the command comes from a user, they can run arbitrary
78
+ commands. Pass an argument list and drop shell=True.
79
+ metadata: {title: "subprocess with shell=True", cwe: ["CWE-78"]}
80
+ pattern-either:
81
+ - pattern: subprocess.$F(..., shell=True, ...)
82
+ - pattern: os.system($X)
83
+ - id: eval-of-dynamic-code
84
+ languages: [javascript, typescript]
85
+ severity: ERROR
86
+ message: >-
87
+ eval / new Function runs a string as code. If the string can contain user input, an attacker can run
88
+ code in your app. Parse data with JSON.parse or use a lookup table instead.
89
+ metadata: {title: "Dynamic code evaluation", cwe: ["CWE-94"]}
90
+ patterns:
91
+ - pattern-either:
92
+ - pattern: eval($X)
93
+ - pattern: new Function(..., $X)
94
+ - pattern-not: eval("...")
95
+ - pattern-not: new Function("...")
96
+ - id: python-unsafe-deserialization
97
+ languages: [python]
98
+ severity: ERROR
99
+ message: >-
100
+ pickle / yaml.load can execute code while loading. Never load untrusted data with them; use json, or
101
+ yaml.safe_load.
102
+ metadata: {title: "Unsafe deserialization", cwe: ["CWE-502"]}
103
+ pattern-either:
104
+ - pattern: pickle.loads(...)
105
+ - pattern: pickle.load(...)
106
+ - patterns:
107
+ - pattern: yaml.load(...)
108
+ - pattern-not: yaml.load(..., Loader=yaml.SafeLoader, ...)
109
+ - pattern-not: yaml.load(..., Loader=SafeLoader, ...)
110
+
111
+ # ------------------------------------------------------------------ XSS / redirects
112
+ - id: react-dangerously-set-inner-html
113
+ languages: [javascript, typescript]
114
+ severity: WARNING
115
+ message: >-
116
+ HTML from a variable is rendered with dangerouslySetInnerHTML. If it can contain user content, it can
117
+ run scripts in your users' browsers (stealing sessions). Sanitize it (DOMPurify) or render text.
118
+ metadata: {title: "Unsanitized HTML rendered in React", cwe: ["CWE-79"]}
119
+ patterns:
120
+ - pattern: '<$EL dangerouslySetInnerHTML={{__html: $X}} />'
121
+ - pattern-not: '<$EL dangerouslySetInnerHTML={{__html: "..."}} />'
122
+ - pattern-not: '<$EL dangerouslySetInnerHTML={{__html: DOMPurify.sanitize(...)}} />'
123
+ - pattern-not: '<$EL dangerouslySetInnerHTML={{__html: sanitize(...)}} />'
124
+ - id: open-redirect-from-request
125
+ languages: [javascript, typescript]
126
+ severity: WARNING
127
+ message: >-
128
+ The app redirects to a URL taken from the request. Attackers use this to send your users to phishing
129
+ pages under your domain. Only redirect to relative paths or an allow-list.
130
+ metadata: {title: "Open redirect", cwe: ["CWE-601"]}
131
+ pattern-either:
132
+ - pattern: $RES.redirect($REQ.query.$P)
133
+ - pattern: $RES.redirect($REQ.body.$P)
134
+ - pattern: redirect($REQ.nextUrl.searchParams.get(...))
135
+ - pattern: NextResponse.redirect(new URL($REQ.nextUrl.searchParams.get(...), ...))
136
+
137
+ # ------------------------------------------------------------------ auth & secrets in code
138
+ - id: jwt-hardcoded-secret
139
+ languages: [javascript, typescript]
140
+ severity: ERROR
141
+ message: >-
142
+ A JWT is signed or verified with a secret written in the code. Anyone who reads the code can forge
143
+ tokens and log in as any user. Load the secret from an environment variable.
144
+ metadata: {title: "JWT secret hard-coded", cwe: ["CWE-798"]}
145
+ pattern-either:
146
+ - pattern: $JWT.sign($P, "...", ...)
147
+ - pattern: $JWT.verify($T, "...", ...)
148
+ - id: jwt-decode-without-verify
149
+ languages: [javascript, typescript]
150
+ severity: WARNING
151
+ message: >-
152
+ jwt.decode() reads a token without checking its signature, so anyone can craft one. Use jwt.verify()
153
+ (or your auth provider's server helper) before trusting the token's claims.
154
+ metadata: {title: "JWT used without signature verification", cwe: ["CWE-347"]}
155
+ patterns:
156
+ - pattern: $JWT.decode($T, ...)
157
+ - metavariable-regex:
158
+ metavariable: $JWT
159
+ regex: ^(jwt|jws|jsonwebtoken|jose|JWT)$
160
+ - pattern-not-inside: $V.verify(...) && $JWT.decode(...)
161
+ - pattern-not-inside: |
162
+ $V.verify($T, ...);
163
+ ...
164
+ - pattern-not-inside: |
165
+ $X = $V.verify($T, ...);
166
+ ...
167
+ - pattern-not-inside: |
168
+ if (<... $V.verify(...) ...>) { ... }
169
+ - id: supabase-service-role-client-in-browser-code
170
+ languages: [javascript, typescript]
171
+ severity: ERROR
172
+ message: >-
173
+ A Supabase client is created with a service-role key in a file marked "use client". That key bypasses
174
+ Row Level Security and would ship to every visitor. Use the anon key in the browser; keep the service
175
+ key in server-only code.
176
+ metadata: {title: "Supabase service-role key used in client code", cwe: ["CWE-200"]}
177
+ patterns:
178
+ - pattern-inside: |
179
+ "use client";
180
+ ...
181
+ - pattern: createClient($URL, $KEY, ...)
182
+ - metavariable-regex:
183
+ metavariable: $KEY
184
+ regex: (?i).*service.?role.*
185
+ - id: cors-any-origin-with-credentials
186
+ languages: [javascript, typescript]
187
+ severity: WARNING
188
+ message: >-
189
+ CORS allows any origin while also allowing credentials. Browsers combined with origin reflection let any
190
+ website make logged-in requests to your API. List your trusted origins explicitly.
191
+ metadata: {title: "CORS allows any origin with credentials", cwe: ["CWE-942"]}
192
+ pattern-either:
193
+ - pattern: |
194
+ {..., "Access-Control-Allow-Origin": "*", ..., "Access-Control-Allow-Credentials": "true", ...}
195
+ - pattern: |
196
+ cors({..., origin: true, ..., credentials: true, ...})
197
+ - pattern: |
198
+ cors({..., origin: "*", ..., credentials: true, ...})
199
+
200
+ # ------------------------------------------------------------------ crypto
201
+ - id: weak-password-hash
202
+ languages: [javascript, typescript, python]
203
+ severity: WARNING
204
+ message: >-
205
+ MD5 / SHA-1 are fast hashes and unsafe for passwords or tokens. Use bcrypt, scrypt or argon2 for
206
+ passwords, and SHA-256+ elsewhere.
207
+ metadata: {title: "Weak hash algorithm", cwe: ["CWE-328"]}
208
+ pattern-either:
209
+ - pattern: crypto.createHash("md5")
210
+ - pattern: crypto.createHash("sha1")
211
+ - pattern: hashlib.md5(...)
212
+ - pattern: hashlib.sha1(...)
213
+
214
+ # ------------------------------------------------------------------ taint: request input -> dangerous call
215
+ # Follows user input through variables and string building (the usual shape of generated code:
216
+ # build a string first, run it later). Only the dangerous argument counts, so a parameterized
217
+ # query that receives user input as a bound value is not flagged.
218
+ - id: js-sql-injection-from-request
219
+ mode: taint
220
+ languages: [javascript, typescript]
221
+ severity: ERROR
222
+ message: >-
223
+ Request input reaches a SQL query string. An attacker can rewrite the query to read or change any data.
224
+ Pass the value as a bound parameter ($1 / ?) instead of building the SQL string.
225
+ metadata: {title: "SQL injection from request input", cwe: ["CWE-89"]}
226
+ pattern-sources:
227
+ - pattern-either:
228
+ - pattern: $REQ.body
229
+ - pattern: $REQ.query
230
+ - pattern: $REQ.params
231
+ - pattern: $REQ.cookies
232
+ - pattern: $REQ.headers
233
+ - pattern: $REQ.files
234
+ - pattern: await $REQ.json()
235
+ - pattern: $REQ.nextUrl.searchParams.get(...)
236
+ - pattern: $FORM.get(...)
237
+ pattern-sinks:
238
+ - patterns:
239
+ - pattern-either:
240
+ - pattern: $DB.query($Q, ...)
241
+ - pattern: $DB.execute($Q, ...)
242
+ - pattern: $DB.raw($Q, ...)
243
+ - pattern: $DB.unsafe($Q, ...)
244
+ - pattern: $DB.$queryRawUnsafe($Q, ...)
245
+ - pattern: $DB.$executeRawUnsafe($Q, ...)
246
+ - focus-metavariable: $Q
247
+ - id: js-command-injection-from-request
248
+ mode: taint
249
+ languages: [javascript, typescript]
250
+ severity: ERROR
251
+ message: >-
252
+ Request input reaches a shell command. An attacker can run any command on your server. Use
253
+ execFile/spawn with an argument array and validate the input.
254
+ metadata: {title: "Command injection from request input", cwe: ["CWE-78"]}
255
+ pattern-sources:
256
+ - pattern-either:
257
+ - pattern: $REQ.body
258
+ - pattern: $REQ.query
259
+ - pattern: $REQ.params
260
+ - pattern: $REQ.cookies
261
+ - pattern: $REQ.headers
262
+ - pattern: $REQ.files
263
+ - pattern: await $REQ.json()
264
+ - pattern: $REQ.nextUrl.searchParams.get(...)
265
+ - pattern: $FORM.get(...)
266
+ pattern-sinks:
267
+ - patterns:
268
+ - pattern-either:
269
+ - pattern: exec($CMD, ...)
270
+ - pattern: execSync($CMD, ...)
271
+ - pattern: $CP.exec($CMD, ...)
272
+ - pattern: $CP.execSync($CMD, ...)
273
+ - focus-metavariable: $CMD
274
+ - id: js-code-injection-from-request
275
+ mode: taint
276
+ languages: [javascript, typescript]
277
+ severity: ERROR
278
+ message: >-
279
+ Request input is evaluated or deserialized as code (eval, Function, vm, math evaluators,
280
+ node-serialize). An attacker can run code inside your app. Never evaluate user input; parse data with
281
+ JSON.parse.
282
+ metadata: {title: "Code injection from request input", cwe: ["CWE-94"]}
283
+ pattern-sources:
284
+ - pattern-either:
285
+ - pattern: $REQ.body
286
+ - pattern: $REQ.query
287
+ - pattern: $REQ.params
288
+ - pattern: $REQ.cookies
289
+ - pattern: $REQ.headers
290
+ - pattern: $REQ.files
291
+ - pattern: await $REQ.json()
292
+ - pattern: $REQ.nextUrl.searchParams.get(...)
293
+ - pattern: $FORM.get(...)
294
+ pattern-sinks:
295
+ - patterns:
296
+ - pattern-either:
297
+ - pattern: eval($X)
298
+ - pattern: new Function(..., $X)
299
+ - pattern: $M.eval($X, ...)
300
+ - pattern: $M.evaluate($X, ...)
301
+ - pattern: vm.$RUN($X, ...)
302
+ - pattern: $S.unserialize($X, ...)
303
+ - focus-metavariable: $X
304
+ - id: python-sql-injection-from-request
305
+ mode: taint
306
+ languages: [python]
307
+ severity: ERROR
308
+ message: >-
309
+ Request input reaches a SQL query string. An attacker can rewrite the query to read or change any data.
310
+ Use parameters: cursor.execute("... WHERE id = %s", (value,)) or the ORM's filters.
311
+ metadata: {title: "SQL injection from request input", cwe: ["CWE-89"]}
312
+ pattern-sources:
313
+ - pattern-either:
314
+ - pattern: request.GET
315
+ - pattern: request.POST
316
+ - pattern: request.args
317
+ - pattern: request.form
318
+ - pattern: request.values
319
+ - pattern: request.json
320
+ - pattern: request.data
321
+ - pattern: request.body
322
+ - pattern: request.cookies
323
+ - pattern: request.headers
324
+ - pattern: request.get_json(...)
325
+ - pattern: request.query_params
326
+ pattern-sinks:
327
+ - patterns:
328
+ - pattern-either:
329
+ - pattern: $C.execute($Q, ...)
330
+ - pattern: $C.executemany($Q, ...)
331
+ - pattern: $C.executescript($Q, ...)
332
+ - pattern: $M.objects.raw($Q, ...)
333
+ - pattern: $M.extra(where=$Q, ...)
334
+ - pattern: text($Q)
335
+ - focus-metavariable: $Q
336
+ - id: python-command-injection-from-request
337
+ mode: taint
338
+ languages: [python]
339
+ severity: ERROR
340
+ message: >-
341
+ Request input reaches a shell command. An attacker can run any command on your server. Pass an argument
342
+ list without shell=True and validate the input.
343
+ metadata: {title: "Command injection from request input", cwe: ["CWE-78"]}
344
+ pattern-sources:
345
+ - pattern-either:
346
+ - pattern: request.GET
347
+ - pattern: request.POST
348
+ - pattern: request.args
349
+ - pattern: request.form
350
+ - pattern: request.values
351
+ - pattern: request.json
352
+ - pattern: request.data
353
+ - pattern: request.body
354
+ - pattern: request.cookies
355
+ - pattern: request.headers
356
+ - pattern: request.get_json(...)
357
+ - pattern: request.query_params
358
+ pattern-sinks:
359
+ - patterns:
360
+ - pattern-either:
361
+ - pattern: os.system($CMD)
362
+ - pattern: os.popen($CMD, ...)
363
+ - pattern: subprocess.$F($CMD, ..., shell=True, ...)
364
+ - focus-metavariable: $CMD
365
+ - id: python-code-injection-from-request
366
+ mode: taint
367
+ languages: [python]
368
+ severity: ERROR
369
+ message: >-
370
+ Request input is evaluated as Python code or deserialized unsafely. An attacker can run code on your
371
+ server. Never eval user input; use json / ast.literal_eval / yaml.safe_load.
372
+ metadata: {title: "Code injection from request input", cwe: ["CWE-94"]}
373
+ pattern-sources:
374
+ - pattern-either:
375
+ - pattern: request.GET
376
+ - pattern: request.POST
377
+ - pattern: request.args
378
+ - pattern: request.form
379
+ - pattern: request.values
380
+ - pattern: request.json
381
+ - pattern: request.data
382
+ - pattern: request.body
383
+ - pattern: request.cookies
384
+ - pattern: request.headers
385
+ - pattern: request.get_json(...)
386
+ - pattern: request.query_params
387
+ pattern-sinks:
388
+ - patterns:
389
+ - pattern-either:
390
+ - pattern: eval($X, ...)
391
+ - pattern: exec($X, ...)
392
+ - pattern: render_template_string($X, ...)
393
+ - focus-metavariable: $X