aptu-core 0.8.5

Core library for Aptu - OSS issue triage with AI assistance
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
[
  {
    "id": "hardcoded-api-key",
    "description": "Hardcoded API key or secret token detected",
    "pattern": "(?i)(api[_-]?key|secret[_-]?key|access[_-]?token)\\s*[=:]\\s*[\"'][a-zA-Z0-9_-]{20,}[\"']",
    "severity": "critical",
    "confidence": "high",
    "cwe": "CWE-798",
    "remediation": "Use environment variables or a secrets manager; never embed credentials in source code.",
    "authority_url": "https://cwe.mitre.org/data/definitions/798.html",
    "file_extensions": []
  },
  {
    "id": "hardcoded-password",
    "description": "Hardcoded password detected",
    "pattern": "(?i)(password|passwd|pwd)\\s*[=:]\\s*[\"'][^\"']{8,}[\"']",
    "severity": "critical",
    "confidence": "medium",
    "cwe": "CWE-798",
    "remediation": "Use environment variables or a secrets manager; never embed credentials in source code.",
    "authority_url": "https://cwe.mitre.org/data/definitions/798.html",
    "file_extensions": []
  },
  {
    "id": "sql-injection-concat",
    "description": "Potential SQL injection via string concatenation",
    "pattern": "(?i)(execute|query|exec)\\s*\\([^)]*(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE)[^)]*\\+[^)]*\\)",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-89",
    "remediation": "Use parameterized queries or prepared statements; never concatenate user input into SQL strings.",
    "authority_url": "https://cwe.mitre.org/data/definitions/89.html",
    "file_extensions": [
      ".rs",
      ".py",
      ".js",
      ".ts",
      ".java",
      ".php"
    ]
  },
  {
    "id": "sql-injection-format",
    "description": "Potential SQL injection via string formatting",
    "pattern": "(?i)(execute|query|exec)\\s*\\([^)]*format[^)]*\\)",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-89",
    "remediation": "Use parameterized queries or prepared statements; never concatenate user input into SQL strings.",
    "authority_url": "https://cwe.mitre.org/data/definitions/89.html",
    "file_extensions": [
      ".rs",
      ".py",
      ".js",
      ".ts",
      ".java",
      ".php"
    ]
  },
  {
    "id": "path-traversal",
    "description": "Potential path traversal vulnerability",
    "pattern": "(?i)(open|read|write|include|require)\\s*\\([^)]*\\.\\.[/\\\\]",
    "severity": "high",
    "confidence": "high",
    "cwe": "CWE-22",
    "remediation": "Validate and canonicalize file paths; restrict access to an allowlisted base directory.",
    "authority_url": "https://cwe.mitre.org/data/definitions/22.html",
    "file_extensions": []
  },
  {
    "id": "command-injection",
    "description": "Potential command injection via shell execution",
    "pattern": "(?i)(exec|system|shell|popen|spawn)\\s*\\([^)]*\\+[^)]*\\)",
    "severity": "critical",
    "confidence": "medium",
    "cwe": "CWE-78",
    "remediation": "Avoid shell invocation; pass arguments as arrays to process APIs without shell interpolation.",
    "authority_url": "https://cwe.mitre.org/data/definitions/78.html",
    "file_extensions": []
  },
  {
    "id": "xss-innerhtml",
    "description": "Potential XSS via innerHTML assignment",
    "pattern": "(?i)innerHTML\\s*[=]\\s*[^;]*\\+",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-79",
    "remediation": "Encode output contextually (HTML, JS, URL); apply a Content-Security-Policy header.",
    "authority_url": "https://cwe.mitre.org/data/definitions/79.html",
    "file_extensions": [
      ".js",
      ".ts",
      ".jsx",
      ".tsx"
    ]
  },
  {
    "id": "insecure-random",
    "description": "Use of insecure random number generator",
    "pattern": "(?i)(Math\\.random|rand\\(\\)|random\\.randint)",
    "severity": "medium",
    "confidence": "low",
    "cwe": "CWE-338",
    "remediation": "Replace with a cryptographically secure RNG (e.g. OsRng, crypto/rand); never use math.random for security decisions.",
    "authority_url": "https://cwe.mitre.org/data/definitions/338.html",
    "file_extensions": [
      ".js",
      ".ts",
      ".py",
      ".java"
    ]
  },
  {
    "id": "weak-crypto-md5",
    "description": "Use of weak cryptographic hash MD5",
    "pattern": "(?i)(md5|MD5)\\s*\\(",
    "severity": "medium",
    "confidence": "high",
    "cwe": "CWE-327",
    "remediation": "Replace MD5 with a modern algorithm (AES-256-GCM, ChaCha20-Poly1305, or SHA-256+).",
    "authority_url": "https://cwe.mitre.org/data/definitions/327.html",
    "file_extensions": []
  },
  {
    "id": "weak-crypto-sha1",
    "description": "Use of weak cryptographic hash SHA1",
    "pattern": "(?i)(sha1|SHA1)\\s*\\(",
    "severity": "medium",
    "confidence": "high",
    "cwe": "CWE-327",
    "remediation": "Replace SHA-1 with a modern algorithm (AES-256-GCM, ChaCha20-Poly1305, or SHA-256+).",
    "authority_url": "https://cwe.mitre.org/data/definitions/327.html",
    "file_extensions": []
  },
  {
    "id": "unsafe-deserialization",
    "description": "Unsafe deserialization of untrusted data",
    "pattern": "(?i)(pickle\\.loads|yaml\\.load|unserialize)\\s*\\(",
    "severity": "critical",
    "confidence": "high",
    "cwe": "CWE-502",
    "remediation": "Validate and sanitize input before deserializing; use type-safe deserializers and avoid pickle/yaml.load on untrusted data.",
    "authority_url": "https://cwe.mitre.org/data/definitions/502.html",
    "file_extensions": [
      ".py",
      ".php",
      ".java"
    ]
  },
  {
    "id": "xxe-vulnerability",
    "description": "Potential XML External Entity (XXE) vulnerability",
    "pattern": "(?i)(XMLReader|DocumentBuilder|SAXParser).*setFeature.*false",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-611",
    "remediation": "Disable external entity and DTD processing in the XML parser configuration.",
    "authority_url": "https://cwe.mitre.org/data/definitions/611.html",
    "file_extensions": [
      ".java",
      ".xml"
    ]
  },
  {
    "id": "insecure-tls",
    "description": "Insecure TLS/SSL configuration",
    "pattern": "(?i)(SSLv2|SSLv3|TLSv1\\.0|verify[_-]?mode.*NONE)",
    "severity": "high",
    "confidence": "high",
    "cwe": "CWE-327",
    "remediation": "Replace MD5/SHA-1/DES/SSLv2/SSLv3/TLSv1.0 with modern algorithms (AES-256-GCM, ChaCha20-Poly1305, TLSv1.2+).",
    "authority_url": "https://cwe.mitre.org/data/definitions/327.html",
    "file_extensions": []
  },
  {
    "id": "debug-enabled",
    "description": "Debug mode enabled in production code",
    "pattern": "(?i)(debug\\s*[=:]\\s*true|DEBUG\\s*[=:]\\s*True)",
    "severity": "low",
    "confidence": "low",
    "cwe": "CWE-489",
    "remediation": "Remove or gate debug endpoints and verbose logging behind a compile-time or runtime feature flag.",
    "authority_url": "https://cwe.mitre.org/data/definitions/489.html",
    "file_extensions": []
  },
  {
    "id": "prompt-injection-ignore-instructions",
    "description": "Detects attempts to override AI instructions via ignore directives",
    "pattern": "(?i)ignore (all |previous |above )*(instructions|rules|guidelines)",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-1336",
    "remediation": "Sanitize and validate all user-supplied content before including it in AI prompts; apply input allowlists.",
    "authority_url": "https://cwe.mitre.org/data/definitions/1336.html",
    "file_extensions": []
  },
  {
    "id": "prompt-injection-system-marker",
    "description": "Detects SYSTEM: role marker injection attempts",
    "pattern": "(?i)\\bSYSTEM\\b\\s*:",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-1336",
    "remediation": "Sanitize and validate all user-supplied content before including it in AI prompts; apply input allowlists.",
    "authority_url": "https://cwe.mitre.org/data/definitions/1336.html",
    "file_extensions": []
  },
  {
    "id": "prompt-injection-newline-system",
    "description": "Detects `system:` at the start of a line in a diff, a common prompt injection vector.",
    "pattern": "(?m)^\\s*(?i)system\\s*:",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-1336",
    "remediation": "Sanitize and validate all user-supplied content before including it in AI prompts; apply input allowlists.",
    "authority_url": "https://cwe.mitre.org/data/definitions/1336.html",
    "file_extensions": []
  },
  {
    "id": "prompt-injection-closing-tag",
    "description": "Detects XML closing tag injection to escape pull_request context",
    "pattern": "(?i)</pull_request>",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-1336",
    "remediation": "Escape or strip XML delimiters in user-supplied content before embedding it in structured AI prompts.",
    "authority_url": "https://cwe.mitre.org/data/definitions/1336.html",
    "file_extensions": [
      ".md",
      ".mdx",
      ".txt",
      ".html",
      ".htm",
      ".yaml",
      ".yml",
      ".json",
      ".toml",
      ".rst",
      ".org"
    ]
  },
  {
    "id": "prompt-injection-jailbreak-preamble",
    "description": "Detects jailbreak preamble patterns that attempt to redefine AI persona",
    "pattern": "(?i)you are now (a |an )?(malicious|evil|unrestricted|unfiltered|jailbroken|hacker|attacker)",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-1336",
    "remediation": "Sanitize and validate all user-supplied content before including it in AI prompts; apply input allowlists.",
    "authority_url": "https://cwe.mitre.org/data/definitions/1336.html",
    "file_extensions": []
  },
  {
    "id": "prompt-injection-closing-tag-issue",
    "description": "Attempt to escape issue_content XML delimiter boundary",
    "pattern": "(?i)</issue_content>",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-1336",
    "remediation": "Escape or strip XML delimiters in user-supplied content before embedding it in structured AI prompts.",
    "authority_url": "https://cwe.mitre.org/data/definitions/1336.html",
    "file_extensions": [
      ".md",
      ".mdx",
      ".txt",
      ".html",
      ".htm",
      ".yaml",
      ".yml",
      ".json",
      ".toml",
      ".rst",
      ".org"
    ]
  },
  {
    "id": "prompt-injection-closing-tag-issue-body",
    "description": "Attempt to escape issue_body XML delimiter boundary",
    "pattern": "(?i)</issue_body>",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-1336",
    "remediation": "Escape or strip XML delimiters in user-supplied content before embedding it in structured AI prompts.",
    "authority_url": "https://cwe.mitre.org/data/definitions/1336.html",
    "file_extensions": [
      ".md",
      ".mdx",
      ".txt",
      ".html",
      ".htm",
      ".yaml",
      ".yml",
      ".json",
      ".toml",
      ".rst",
      ".org"
    ]
  },
  {
    "id": "prompt-injection-closing-tag-pr-diff",
    "description": "Attempt to escape pr_diff XML delimiter boundary",
    "pattern": "(?i)</pr_diff>",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-1336",
    "remediation": "Escape or strip XML delimiters in user-supplied content before embedding it in structured AI prompts.",
    "authority_url": "https://cwe.mitre.org/data/definitions/1336.html",
    "file_extensions": [
      ".md",
      ".mdx",
      ".txt",
      ".html",
      ".htm",
      ".yaml",
      ".yml",
      ".json",
      ".toml",
      ".rst",
      ".org"
    ]
  },
  {
    "id": "prompt-injection-closing-tag-commit-message",
    "description": "Attempt to escape commit_message XML delimiter boundary",
    "pattern": "(?i)</commit_message>",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-1336",
    "remediation": "Escape or strip XML delimiters in user-supplied content before embedding it in structured AI prompts.",
    "authority_url": "https://cwe.mitre.org/data/definitions/1336.html",
    "file_extensions": [
      ".md",
      ".mdx",
      ".txt",
      ".html",
      ".htm",
      ".yaml",
      ".yml",
      ".json",
      ".toml",
      ".rst",
      ".org"
    ]
  },
  {
    "id": "prompt-injection-closing-tag-pr-comment",
    "description": "Attempt to escape pr_comment XML delimiter boundary",
    "pattern": "(?i)</pr_comment>",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-1336",
    "remediation": "Escape or strip XML delimiters in user-supplied content before embedding it in structured AI prompts.",
    "authority_url": "https://cwe.mitre.org/data/definitions/1336.html",
    "file_extensions": [
      ".md",
      ".mdx",
      ".txt",
      ".html",
      ".htm",
      ".yaml",
      ".yml",
      ".json",
      ".toml",
      ".rst",
      ".org"
    ]
  },
  {
    "id": "prompt-injection-closing-tag-file-content",
    "description": "Attempt to escape file_content XML delimiter boundary",
    "pattern": "(?i)</file_content>",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-1336",
    "remediation": "Escape or strip XML delimiters in user-supplied content before embedding it in structured AI prompts.",
    "authority_url": "https://cwe.mitre.org/data/definitions/1336.html",
    "file_extensions": [
      ".md",
      ".mdx",
      ".txt",
      ".html",
      ".htm",
      ".yaml",
      ".yml",
      ".json",
      ".toml",
      ".rst",
      ".org"
    ]
  },
  {
    "id": "ssrf-http-request",
    "description": "Potential SSRF: HTTP client called with variable URL. Verify the URL is validated against an allowlist before use.",
    "pattern": "(?i)(reqwest::get|reqwest::Client|urllib\\.request\\.urlopen|axios\\.(get|post|put|delete)|http\\.get|http\\.post|curl_exec|wget)\\s*[\\(\\[](?:[^\\\"'\\)]*[a-z_][a-z0-9_]*(?:\\.[a-z_][a-z0-9_]*)*)",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-918",
    "remediation": "Validate and restrict outbound URLs to an allowlist; block requests to private IP ranges and metadata endpoints.",
    "authority_url": "https://cwe.mitre.org/data/definitions/918.html",
    "file_extensions": []
  },
  {
    "id": "open-redirect",
    "description": "Potential open redirect: redirect target may be controlled by user input. Validate and restrict redirect URLs.",
    "pattern": "(?i)(location\\.href|location\\.replace|location\\.assign|response\\.redirect|res\\.redirect|header\\s*\\(\\s*['\"]Location)\\s*[=:(]\\s*[^;]*?(req\\.|request\\.|params\\.|query\\.|args\\.)",
    "severity": "high",
    "confidence": "medium",
    "cwe": "CWE-601",
    "remediation": "Validate redirect targets against an allowlist of permitted domains; reject or encode external URLs.",
    "authority_url": "https://cwe.mitre.org/data/definitions/601.html",
    "file_extensions": []
  },
  {
    "id": "leaked-github-token",
    "description": "Hardcoded GitHub App installation token (ghs_) detected",
    "pattern": "ghs_[A-Za-z0-9._-]{36,}",
    "severity": "critical",
    "confidence": "high",
    "cwe": "CWE-798",
    "remediation": "Rotate the token immediately via GitHub App settings. Store credentials in environment variables or a secrets manager; never embed tokens in source code.",
    "authority_url": "https://cwe.mitre.org/data/definitions/798.html",
    "file_extensions": []
  }
]