circle-ir 3.173.0 → 3.175.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.
- package/configs/sinks/open_redirect.yaml +21 -0
- package/configs/sinks/prompt_injection.yaml +50 -0
- package/configs/sinks/trust_boundary.yaml +18 -0
- package/dist/analysis/config-loader.d.ts.map +1 -1
- package/dist/analysis/config-loader.js +178 -1
- package/dist/analysis/config-loader.js.map +1 -1
- package/dist/analysis/rules.d.ts.map +1 -1
- package/dist/analysis/rules.js +9 -0
- package/dist/analysis/rules.js.map +1 -1
- package/dist/browser/circle-ir.js +150 -2
- package/dist/core/circle-ir-core.cjs +150 -2
- package/dist/core/circle-ir-core.js +150 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Reference-only. Runtime uses OPEN_REDIRECT_FRAMEWORK_SINKS + classless `redirect` + net/http.Redirect + Java sendRedirect in src/analysis/config-loader.ts. See cognium-dev#240.",
|
|
3
|
+
"sinks": [
|
|
4
|
+
{ "method": "HttpResponseRedirect", "type": "open_redirect", "cwe": "CWE-601", "severity": "medium", "arg_positions": [0], "languages": ["python"] },
|
|
5
|
+
{ "method": "HttpResponsePermanentRedirect", "type": "open_redirect", "cwe": "CWE-601", "severity": "medium", "arg_positions": [0], "languages": ["python"] },
|
|
6
|
+
{ "method": "RedirectResponse", "type": "open_redirect", "cwe": "CWE-601", "severity": "medium", "arg_positions": [0], "languages": ["python"] },
|
|
7
|
+
|
|
8
|
+
{ "method": "redirect", "class": "Context", "type": "open_redirect", "cwe": "CWE-601", "severity": "medium", "arg_positions": [0], "languages": ["javascript", "typescript"] },
|
|
9
|
+
{ "method": "redirect", "class": "FastifyReply", "type": "open_redirect", "cwe": "CWE-601", "severity": "medium", "arg_positions": [0], "languages": ["javascript", "typescript"] },
|
|
10
|
+
{ "method": "location", "class": "Response", "type": "open_redirect", "cwe": "CWE-601", "severity": "medium", "arg_positions": [0], "languages": ["javascript", "typescript"] },
|
|
11
|
+
{ "method": "redirect", "class": "NextResponse", "type": "open_redirect", "cwe": "CWE-601", "severity": "medium", "arg_positions": [0], "languages": ["javascript", "typescript"] },
|
|
12
|
+
|
|
13
|
+
{ "method": "RedirectView", "class": "RedirectView", "type": "open_redirect", "cwe": "CWE-601", "severity": "high", "arg_positions": [0], "languages": ["java"] },
|
|
14
|
+
{ "method": "setUrl", "class": "RedirectView", "type": "open_redirect", "cwe": "CWE-601", "severity": "high", "arg_positions": [0], "languages": ["java"] },
|
|
15
|
+
{ "method": "seeOther", "class": "Response", "type": "open_redirect", "cwe": "CWE-601", "severity": "high", "arg_positions": [0], "languages": ["java"] },
|
|
16
|
+
{ "method": "temporaryRedirect", "class": "Response", "type": "open_redirect", "cwe": "CWE-601", "severity": "high", "arg_positions": [0], "languages": ["java"] },
|
|
17
|
+
|
|
18
|
+
{ "method": "Redirect", "class": "Context", "type": "open_redirect", "cwe": "CWE-601", "severity": "medium", "arg_positions": [1], "languages": ["go"] },
|
|
19
|
+
{ "method": "Redirect", "class": "Ctx", "type": "open_redirect", "cwe": "CWE-601", "severity": "medium", "arg_positions": [0], "languages": ["go"] }
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Reference-only. Runtime uses DEFAULT_SINKS in src/analysis/config-loader.ts. See cognium-dev#248.",
|
|
3
|
+
"sinks": [
|
|
4
|
+
{ "method": "create", "class": "Completions", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
5
|
+
{ "method": "create", "class": "Responses", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
6
|
+
{ "method": "create", "class": "ChatCompletion", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
7
|
+
{ "method": "create", "class": "Completion", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
8
|
+
{ "method": "create", "class": "Messages", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
9
|
+
{ "method": "stream", "class": "Messages", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
10
|
+
{ "method": "completion", "class": "litellm", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
11
|
+
{ "method": "acompletion", "class": "litellm", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
12
|
+
{ "method": "invoke", "class": "ChatOpenAI", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
13
|
+
{ "method": "predict", "class": "ChatOpenAI", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
14
|
+
{ "method": "stream", "class": "ChatOpenAI", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
15
|
+
{ "method": "generate", "class": "ChatOpenAI", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
16
|
+
{ "method": "invoke", "class": "ChatAnthropic", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
17
|
+
{ "method": "invoke", "class": "ChatGoogleGenerativeAI", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
18
|
+
{ "method": "run", "class": "LLMChain", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
19
|
+
{ "method": "invoke", "class": "LLMChain", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["python"] },
|
|
20
|
+
|
|
21
|
+
{ "method": "create", "class": "Completions", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["javascript", "typescript"] },
|
|
22
|
+
{ "method": "create", "class": "Responses", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["javascript", "typescript"] },
|
|
23
|
+
{ "method": "create", "class": "Messages", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["javascript", "typescript"] },
|
|
24
|
+
{ "method": "stream", "class": "Messages", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["javascript", "typescript"] },
|
|
25
|
+
{ "method": "generateText", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0], "languages": ["javascript", "typescript"] },
|
|
26
|
+
{ "method": "streamText", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0], "languages": ["javascript", "typescript"] },
|
|
27
|
+
{ "method": "generateObject", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0], "languages": ["javascript", "typescript"] },
|
|
28
|
+
{ "method": "streamObject", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0], "languages": ["javascript", "typescript"] },
|
|
29
|
+
{ "method": "invoke", "class": "ChatOpenAI", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["javascript", "typescript"] },
|
|
30
|
+
{ "method": "invoke", "class": "ChatAnthropic", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["javascript", "typescript"] },
|
|
31
|
+
{ "method": "stream", "class": "ChatOpenAI", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["javascript", "typescript"] },
|
|
32
|
+
|
|
33
|
+
{ "method": "generate", "class": "ChatLanguageModel", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["java"] },
|
|
34
|
+
{ "method": "chat", "class": "ChatLanguageModel", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["java"] },
|
|
35
|
+
{ "method": "generate", "class": "StreamingChatLanguageModel", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["java"] },
|
|
36
|
+
{ "method": "chat", "class": "StreamingChatLanguageModel", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["java"] },
|
|
37
|
+
{ "method": "prompt", "class": "ChatClient", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["java"] },
|
|
38
|
+
{ "method": "call", "class": "ChatClient", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["java"] },
|
|
39
|
+
{ "method": "call", "class": "ChatModel", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["java"] },
|
|
40
|
+
{ "method": "createChatCompletion", "class": "OpenAiService", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["java"] },
|
|
41
|
+
{ "method": "createCompletion", "class": "OpenAiService", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["java"] },
|
|
42
|
+
|
|
43
|
+
{ "method": "CreateChatCompletion", "class": "Client", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["go"] },
|
|
44
|
+
{ "method": "CreateCompletion", "class": "Client", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["go"] },
|
|
45
|
+
{ "method": "CreateChatCompletionStream", "class": "Client", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["go"] },
|
|
46
|
+
{ "method": "Call", "class": "LLM", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["go"] },
|
|
47
|
+
{ "method": "Generate", "class": "LLM", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["go"] },
|
|
48
|
+
{ "method": "GenerateContent", "class": "Model", "type": "prompt_injection", "cwe": "CWE-1427", "severity": "high", "arg_positions": [0, 1, 2, 3], "languages": ["go"] }
|
|
49
|
+
]
|
|
50
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Reference-only. Runtime uses TRUST_BOUNDARY_FRAMEWORK_SINKS plus existing HttpSession/ServletContext/HttpServletRequest setAttribute entries in src/analysis/config-loader.ts. See cognium-dev#240 (extends #117).",
|
|
3
|
+
"sinks": [
|
|
4
|
+
{ "method": "set", "class": "cache", "type": "trust_boundary", "cwe": "CWE-501", "severity": "medium", "arg_positions": [1], "languages": ["python"] },
|
|
5
|
+
{ "method": "set_many", "class": "cache", "type": "trust_boundary", "cwe": "CWE-501", "severity": "medium", "arg_positions": [0], "languages": ["python"] },
|
|
6
|
+
|
|
7
|
+
{ "method": "setItem", "class": "Storage", "type": "trust_boundary", "cwe": "CWE-501", "severity": "medium", "arg_positions": [1], "languages": ["javascript", "typescript"] },
|
|
8
|
+
{ "method": "cookie", "class": "Response", "type": "trust_boundary", "cwe": "CWE-501", "severity": "medium", "arg_positions": [1], "languages": ["javascript", "typescript"] },
|
|
9
|
+
|
|
10
|
+
{ "method": "Cookie", "class": "Cookie", "type": "trust_boundary", "cwe": "CWE-501", "severity": "medium", "arg_positions": [1], "languages": ["java"] },
|
|
11
|
+
{ "method": "setValue", "class": "Cookie", "type": "trust_boundary", "cwe": "CWE-501", "severity": "medium", "arg_positions": [0], "languages": ["java"] },
|
|
12
|
+
{ "method": "setAuthentication", "class": "SecurityContext", "type": "trust_boundary", "cwe": "CWE-501", "severity": "high", "arg_positions": [0], "languages": ["java"] },
|
|
13
|
+
{ "method": "setProperty", "class": "System", "type": "trust_boundary", "cwe": "CWE-501", "severity": "high", "arg_positions": [1], "languages": ["java"] },
|
|
14
|
+
|
|
15
|
+
{ "method": "SetCookie", "class": "http", "type": "trust_boundary", "cwe": "CWE-501", "severity": "medium", "arg_positions": [1], "languages": ["go"] },
|
|
16
|
+
{ "method": "SetCookie", "class": "Context", "type": "trust_boundary", "cwe": "CWE-501", "severity": "medium", "arg_positions": [1], "languages": ["go"] }
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/analysis/config-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,UAAU,EACX,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAEjD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,aAAa,EAAE,CAiB1E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG;IACtD,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,UAAU,EAAE,gBAAgB,EAAE,CAAC;CAChC,CAcA;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,mBAAmB,EAAE,GAC7B,kBAAkB,EAAE,CAQtB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,MAAM,EAAE,EACxB,YAAY,EAAE,MAAM,EAAE,EACtB,qBAAqB,GAAE,MAAM,EAAO,GACnC,WAAW,CAYb;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,EA6hB1C,CAAC;
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/analysis/config-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,UAAU,EACX,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAEjD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,aAAa,EAAE,CAiB1E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG;IACtD,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,UAAU,EAAE,gBAAgB,EAAE,CAAC;CAChC,CAcA;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,mBAAmB,EAAE,GAC7B,kBAAkB,EAAE,CAQtB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,MAAM,EAAE,EACxB,YAAY,EAAE,MAAM,EAAE,EACtB,qBAAqB,GAAE,MAAM,EAAO,GACnC,WAAW,CAYb;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,EA6hB1C,CAAC;AAmGF,eAAO,MAAM,aAAa,EAAE,WAAW,EAwuDtC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,EAwThD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,EAiDtD,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,WAAW,CAO9C;AAMD;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,EAAE,UAAU,EA8F5C,CAAC"}
|
|
@@ -555,6 +555,95 @@ export const DEFAULT_SOURCES = [
|
|
|
555
555
|
{ method: 'decode', class: 'JWT', type: 'http_header', severity: 'high', return_tainted: true, languages: ['java'] },
|
|
556
556
|
{ method: 'ParseUnverified', class: 'jwt', type: 'http_header', severity: 'high', return_tainted: true, languages: ['go'] },
|
|
557
557
|
];
|
|
558
|
+
// =========================================================================
|
|
559
|
+
// cognium-dev #240 ship 1 — extend open_redirect (CWE-601) framework coverage
|
|
560
|
+
//
|
|
561
|
+
// Extracted from DEFAULT_SINKS to keep the main-array literal within the
|
|
562
|
+
// TypeScript union-type inference complexity limit (TS2590). Spread into
|
|
563
|
+
// DEFAULT_SINKS below.
|
|
564
|
+
//
|
|
565
|
+
// Baseline (variant-coverage.md): 11 probes, 1 fires, 10 FN. Existing
|
|
566
|
+
// coverage: Java HttpServletResponse.sendRedirect, Node classless
|
|
567
|
+
// `redirect`, Go net/http.Redirect, Rust actix Redirect/HttpResponse.
|
|
568
|
+
// Adds Python (django/starlette/fastapi), JS/TS (koa/fastify/express
|
|
569
|
+
// location + next.js), Java (RedirectView + JAX-RS Response), Go
|
|
570
|
+
// (gin/echo/fiber).
|
|
571
|
+
// =========================================================================
|
|
572
|
+
const OPEN_REDIRECT_FRAMEWORK_SINKS = [
|
|
573
|
+
// --- Python: django / starlette / fastapi -------------------------------
|
|
574
|
+
{ method: 'HttpResponseRedirect', type: 'open_redirect', cwe: 'CWE-601', severity: 'medium', arg_positions: [0], languages: ['python'] },
|
|
575
|
+
{ method: 'HttpResponsePermanentRedirect', type: 'open_redirect', cwe: 'CWE-601', severity: 'medium', arg_positions: [0], languages: ['python'] },
|
|
576
|
+
{ method: 'RedirectResponse', type: 'open_redirect', cwe: 'CWE-601', severity: 'medium', arg_positions: [0], languages: ['python'] },
|
|
577
|
+
// --- JS/TS: koa / fastify / express / next.js ---------------------------
|
|
578
|
+
{ method: 'redirect', class: 'Context', type: 'open_redirect', cwe: 'CWE-601', severity: 'medium', arg_positions: [0], languages: ['javascript', 'typescript'] },
|
|
579
|
+
{ method: 'redirect', class: 'FastifyReply', type: 'open_redirect', cwe: 'CWE-601', severity: 'medium', arg_positions: [0], languages: ['javascript', 'typescript'] },
|
|
580
|
+
// Express: res.location(url) sets Location header without redirect status,
|
|
581
|
+
// still an open-redirect vector when combined with a downstream redirect.
|
|
582
|
+
{ method: 'location', class: 'Response', type: 'open_redirect', cwe: 'CWE-601', severity: 'medium', arg_positions: [0], languages: ['javascript', 'typescript'] },
|
|
583
|
+
// Next.js App Router: NextResponse.redirect(url) — static method matched
|
|
584
|
+
// by receiver-class name.
|
|
585
|
+
{ method: 'redirect', class: 'NextResponse', type: 'open_redirect', cwe: 'CWE-601', severity: 'medium', arg_positions: [0], languages: ['javascript', 'typescript'] },
|
|
586
|
+
// --- Java: Spring MVC RedirectView + JAX-RS Response --------------------
|
|
587
|
+
{ method: 'RedirectView', class: 'RedirectView', type: 'open_redirect', cwe: 'CWE-601', severity: 'high', arg_positions: [0], languages: ['java'] },
|
|
588
|
+
{ method: 'setUrl', class: 'RedirectView', type: 'open_redirect', cwe: 'CWE-601', severity: 'high', arg_positions: [0], languages: ['java'] },
|
|
589
|
+
// JAX-RS Response builder — static factory methods that take a target URI.
|
|
590
|
+
{ method: 'seeOther', class: 'Response', type: 'open_redirect', cwe: 'CWE-601', severity: 'high', arg_positions: [0], languages: ['java'] },
|
|
591
|
+
{ method: 'temporaryRedirect', class: 'Response', type: 'open_redirect', cwe: 'CWE-601', severity: 'high', arg_positions: [0], languages: ['java'] },
|
|
592
|
+
// --- Go: gin / echo / fiber ---------------------------------------------
|
|
593
|
+
// gin/echo: c.Redirect(302, url) — status at arg[0], url at arg[1].
|
|
594
|
+
// fiber: c.Redirect(url) — url at arg[0].
|
|
595
|
+
// These entries fire once Go local-receiver type resolution lands
|
|
596
|
+
// (see taint-matcher.ts:2137 receiverMightBeClass — currently returns
|
|
597
|
+
// false for `c` against 'Context'/'Ctx'). Until then, the
|
|
598
|
+
// external_taint_escape fallback preserves recall on these call sites.
|
|
599
|
+
// net/http.Redirect (class 'http') is unaffected — declares class 'http'
|
|
600
|
+
// and matches via package receiver.
|
|
601
|
+
{ method: 'Redirect', class: 'Context', type: 'open_redirect', cwe: 'CWE-601', severity: 'medium', arg_positions: [1], languages: ['go'] },
|
|
602
|
+
{ method: 'Redirect', class: 'Ctx', type: 'open_redirect', cwe: 'CWE-601', severity: 'medium', arg_positions: [0], languages: ['go'] },
|
|
603
|
+
];
|
|
604
|
+
// =========================================================================
|
|
605
|
+
// cognium-dev #240 ship 1 — extend trust_boundary (CWE-501) framework coverage
|
|
606
|
+
//
|
|
607
|
+
// Extracted from DEFAULT_SINKS (see note above). Spread into DEFAULT_SINKS
|
|
608
|
+
// below.
|
|
609
|
+
//
|
|
610
|
+
// Baseline (variant-coverage.md): 16 probes, 0 fires, 16 FN. Existing
|
|
611
|
+
// coverage: Java HttpSession / ServletContext / HttpServletRequest
|
|
612
|
+
// setAttribute (issue #117), Python session.__setitem__. Adds Django
|
|
613
|
+
// cache, JS Storage.setItem, Express res.cookie, Java Cookie /
|
|
614
|
+
// SecurityContext / System.setProperty, Go http.SetCookie / gin.SetCookie.
|
|
615
|
+
//
|
|
616
|
+
// Severity `medium` unless the sink pollutes a process-wide store
|
|
617
|
+
// (System.setProperty → high).
|
|
618
|
+
// =========================================================================
|
|
619
|
+
const TRUST_BOUNDARY_FRAMEWORK_SINKS = [
|
|
620
|
+
// --- Python: Django cache write -----------------------------------------
|
|
621
|
+
{ method: 'set', class: 'cache', type: 'trust_boundary', cwe: 'CWE-501', severity: 'medium', arg_positions: [1], languages: ['python'] },
|
|
622
|
+
{ method: 'set_many', class: 'cache', type: 'trust_boundary', cwe: 'CWE-501', severity: 'medium', arg_positions: [0], languages: ['python'] },
|
|
623
|
+
// --- JS/TS: client-side Storage + Express cookie ------------------------
|
|
624
|
+
// localStorage / sessionStorage — browser Storage.setItem(key, value).
|
|
625
|
+
{ method: 'setItem', class: 'Storage', type: 'trust_boundary', cwe: 'CWE-501', severity: 'medium', arg_positions: [1], languages: ['javascript', 'typescript'] },
|
|
626
|
+
// Express: res.cookie(name, value, opts) — cookie-jar write.
|
|
627
|
+
{ method: 'cookie', class: 'Response', type: 'trust_boundary', cwe: 'CWE-501', severity: 'medium', arg_positions: [1], languages: ['javascript', 'typescript'] },
|
|
628
|
+
// --- Java: Cookie / SecurityContext / System.setProperty ----------------
|
|
629
|
+
// `new Cookie(name, value)` — constructor with tainted value crosses the
|
|
630
|
+
// client-server trust boundary via Set-Cookie.
|
|
631
|
+
{ method: 'Cookie', class: 'Cookie', type: 'trust_boundary', cwe: 'CWE-501', severity: 'medium', arg_positions: [1], languages: ['java'] },
|
|
632
|
+
{ method: 'setValue', class: 'Cookie', type: 'trust_boundary', cwe: 'CWE-501', severity: 'medium', arg_positions: [0], languages: ['java'] },
|
|
633
|
+
// Spring Security: SecurityContext.setAuthentication(userSuppliedAuth) —
|
|
634
|
+
// installs an untrusted principal into the request-scoped security
|
|
635
|
+
// context; downstream authz decisions become attacker-controlled.
|
|
636
|
+
{ method: 'setAuthentication', class: 'SecurityContext', type: 'trust_boundary', cwe: 'CWE-501', severity: 'high', arg_positions: [0], languages: ['java'] },
|
|
637
|
+
// JVM-wide System property write with tainted value pollutes process
|
|
638
|
+
// state observable to every thread.
|
|
639
|
+
{ method: 'setProperty', class: 'System', type: 'trust_boundary', cwe: 'CWE-501', severity: 'high', arg_positions: [1], languages: ['java'] },
|
|
640
|
+
// --- Go: http.SetCookie / gin.SetCookie ---------------------------------
|
|
641
|
+
// Package-level `http.SetCookie(w, &http.Cookie{Value: tainted})` — sink
|
|
642
|
+
// on arg[1] (the *Cookie) catches struct-literal composite tainting.
|
|
643
|
+
{ method: 'SetCookie', class: 'http', type: 'trust_boundary', cwe: 'CWE-501', severity: 'medium', arg_positions: [1], languages: ['go'] },
|
|
644
|
+
// gin: c.SetCookie(name, value, maxAge, path, domain, secure, httpOnly).
|
|
645
|
+
{ method: 'SetCookie', class: 'Context', type: 'trust_boundary', cwe: 'CWE-501', severity: 'medium', arg_positions: [1], languages: ['go'] },
|
|
646
|
+
];
|
|
558
647
|
export const DEFAULT_SINKS = [
|
|
559
648
|
// SQL Injection (CWE-89)
|
|
560
649
|
{ method: 'executeQuery', class: 'Statement', type: 'sql_injection', cwe: 'CWE-89', severity: 'critical', arg_positions: [0] },
|
|
@@ -1915,7 +2004,10 @@ export const DEFAULT_SINKS = [
|
|
|
1915
2004
|
{ method: 'parse', class: 'Uri', type: 'ssrf', cwe: 'CWE-918', severity: 'high', arg_positions: [0] },
|
|
1916
2005
|
// Rust Open Redirect
|
|
1917
2006
|
{ method: 'redirect', class: 'HttpResponse', type: 'open_redirect', cwe: 'CWE-601', severity: 'medium', arg_positions: [0] },
|
|
1918
|
-
|
|
2007
|
+
// Actix/warp `Redirect::to(url)` — scoped to Rust to avoid collision with
|
|
2008
|
+
// Go's `c.Redirect(status, url)` on gin/echo, which lives further down in
|
|
2009
|
+
// the OPEN_REDIRECT_FRAMEWORK_SINKS block with `arg_positions: [0, 1]`.
|
|
2010
|
+
{ method: 'Redirect', type: 'open_redirect', cwe: 'CWE-601', severity: 'medium', arg_positions: [0], languages: ['rust'] },
|
|
1919
2011
|
{ method: 'see_other', class: 'Redirect', type: 'open_redirect', cwe: 'CWE-601', severity: 'high', arg_positions: [0] },
|
|
1920
2012
|
{ method: 'to', class: 'Redirect', type: 'open_redirect', cwe: 'CWE-601', severity: 'high', arg_positions: [0] },
|
|
1921
2013
|
{ method: 'temporary', class: 'Redirect', type: 'open_redirect', cwe: 'CWE-601', severity: 'high', arg_positions: [0] },
|
|
@@ -2120,6 +2212,91 @@ export const DEFAULT_SINKS = [
|
|
|
2120
2212
|
// they iterate after net/http entries and don't hijack `http.Get`.
|
|
2121
2213
|
{ method: 'Do', class: 'Client', type: 'ssrf', cwe: 'CWE-918', severity: 'high', arg_positions: [0], languages: ['go'] }, // *fasthttp.Client.Do(req)
|
|
2122
2214
|
{ method: 'DoTimeout', class: 'Client', type: 'ssrf', cwe: 'CWE-918', severity: 'high', arg_positions: [0], languages: ['go'] },
|
|
2215
|
+
// =========================================================================
|
|
2216
|
+
// cognium-dev #248 — prompt-injection sinks (CWE-1427)
|
|
2217
|
+
//
|
|
2218
|
+
// Tainted data reaching a generative-model prompt-construction API is
|
|
2219
|
+
// classified as `prompt_injection`. v1 uses broad positional matching
|
|
2220
|
+
// (arg_positions [0..3]) because these APIs are kwarg-heavy: Python
|
|
2221
|
+
// `openai.chat.completions.create(model=..., messages=...)` may pass the
|
|
2222
|
+
// messages arg at position 0 or 1 depending on caller order, and JS/TS
|
|
2223
|
+
// object-literal `{ messages: [...], model: '...' }` is a single
|
|
2224
|
+
// positional arg whose taint is inherited from any tainted property.
|
|
2225
|
+
// Argname-precise matching (messages=/prompt=/content=) and
|
|
2226
|
+
// sanitizer credit for prompt-template libraries (PromptTemplate,
|
|
2227
|
+
// ChatPromptTemplate) are follow-ups.
|
|
2228
|
+
//
|
|
2229
|
+
// Class-qualified entries prevent bare `create()` / `generate()` calls
|
|
2230
|
+
// with no receiver from matching (per taint-matcher.ts:1696 guard).
|
|
2231
|
+
// =========================================================================
|
|
2232
|
+
// --- Python: openai (v1 SDK) --------------------------------------------
|
|
2233
|
+
{ method: 'create', class: 'Completions', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2234
|
+
{ method: 'create', class: 'Responses', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2235
|
+
// openai <1.0 legacy top-level API — `openai.ChatCompletion.create(...)` / `openai.Completion.create(...)`
|
|
2236
|
+
{ method: 'create', class: 'ChatCompletion', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2237
|
+
{ method: 'create', class: 'Completion', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2238
|
+
// --- Python: anthropic ---------------------------------------------------
|
|
2239
|
+
{ method: 'create', class: 'Messages', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2240
|
+
{ method: 'stream', class: 'Messages', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2241
|
+
// --- Python: litellm (bare functions from the litellm module) -----------
|
|
2242
|
+
{ method: 'completion', class: 'litellm', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2243
|
+
{ method: 'acompletion', class: 'litellm', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2244
|
+
// --- Python: langchain chat/llm models ----------------------------------
|
|
2245
|
+
// Common concrete classes; matching the class name catches typical usage
|
|
2246
|
+
// `ChatOpenAI().invoke(prompt)` where the receiver-type resolver identifies
|
|
2247
|
+
// the class from the constructor.
|
|
2248
|
+
{ method: 'invoke', class: 'ChatOpenAI', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2249
|
+
{ method: 'predict', class: 'ChatOpenAI', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2250
|
+
{ method: 'stream', class: 'ChatOpenAI', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2251
|
+
{ method: 'generate', class: 'ChatOpenAI', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2252
|
+
{ method: 'invoke', class: 'ChatAnthropic', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2253
|
+
{ method: 'invoke', class: 'ChatGoogleGenerativeAI', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2254
|
+
{ method: 'run', class: 'LLMChain', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2255
|
+
{ method: 'invoke', class: 'LLMChain', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['python'] },
|
|
2256
|
+
// --- JS/TS: openai node SDK ---------------------------------------------
|
|
2257
|
+
{ method: 'create', class: 'Completions', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['javascript', 'typescript'] },
|
|
2258
|
+
{ method: 'create', class: 'Responses', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['javascript', 'typescript'] },
|
|
2259
|
+
// --- JS/TS: @anthropic-ai/sdk -------------------------------------------
|
|
2260
|
+
{ method: 'create', class: 'Messages', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['javascript', 'typescript'] },
|
|
2261
|
+
{ method: 'stream', class: 'Messages', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['javascript', 'typescript'] },
|
|
2262
|
+
// --- JS/TS: Vercel AI SDK (bare functions from the `ai` package) --------
|
|
2263
|
+
// generateText/streamText/generateObject take a single options object;
|
|
2264
|
+
// taint reaches the sink when a tainted variable flows into any property.
|
|
2265
|
+
{ method: 'generateText', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0], languages: ['javascript', 'typescript'] },
|
|
2266
|
+
{ method: 'streamText', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0], languages: ['javascript', 'typescript'] },
|
|
2267
|
+
{ method: 'generateObject', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0], languages: ['javascript', 'typescript'] },
|
|
2268
|
+
{ method: 'streamObject', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0], languages: ['javascript', 'typescript'] },
|
|
2269
|
+
// --- JS/TS: langchain.js ------------------------------------------------
|
|
2270
|
+
{ method: 'invoke', class: 'ChatOpenAI', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['javascript', 'typescript'] },
|
|
2271
|
+
{ method: 'invoke', class: 'ChatAnthropic', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['javascript', 'typescript'] },
|
|
2272
|
+
{ method: 'stream', class: 'ChatOpenAI', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['javascript', 'typescript'] },
|
|
2273
|
+
// --- Java: LangChain4j --------------------------------------------------
|
|
2274
|
+
{ method: 'generate', class: 'ChatLanguageModel', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['java'] },
|
|
2275
|
+
{ method: 'chat', class: 'ChatLanguageModel', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['java'] },
|
|
2276
|
+
{ method: 'generate', class: 'StreamingChatLanguageModel', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['java'] },
|
|
2277
|
+
{ method: 'chat', class: 'StreamingChatLanguageModel', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['java'] },
|
|
2278
|
+
// --- Java: Spring AI ----------------------------------------------------
|
|
2279
|
+
{ method: 'prompt', class: 'ChatClient', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['java'] },
|
|
2280
|
+
{ method: 'call', class: 'ChatClient', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['java'] },
|
|
2281
|
+
{ method: 'call', class: 'ChatModel', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['java'] },
|
|
2282
|
+
// --- Java: OpenAI Java SDK (theokanning) --------------------------------
|
|
2283
|
+
{ method: 'createChatCompletion', class: 'OpenAiService', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['java'] },
|
|
2284
|
+
{ method: 'createCompletion', class: 'OpenAiService', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['java'] },
|
|
2285
|
+
// --- Go: go-openai (sashabaranov/go-openai) -----------------------------
|
|
2286
|
+
{ method: 'CreateChatCompletion', class: 'Client', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['go'] },
|
|
2287
|
+
{ method: 'CreateCompletion', class: 'Client', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['go'] },
|
|
2288
|
+
{ method: 'CreateChatCompletionStream', class: 'Client', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['go'] },
|
|
2289
|
+
// --- Go: langchaingo ----------------------------------------------------
|
|
2290
|
+
{ method: 'Call', class: 'LLM', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['go'] },
|
|
2291
|
+
{ method: 'Generate', class: 'LLM', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['go'] },
|
|
2292
|
+
{ method: 'GenerateContent', class: 'Model', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['go'] },
|
|
2293
|
+
// cognium-dev #240 ship 1 — extended framework sinks for open_redirect
|
|
2294
|
+
// (CWE-601) and trust_boundary (CWE-501). Definitions extracted above
|
|
2295
|
+
// as OPEN_REDIRECT_FRAMEWORK_SINKS / TRUST_BOUNDARY_FRAMEWORK_SINKS to
|
|
2296
|
+
// keep the DEFAULT_SINKS literal within TypeScript's union-type
|
|
2297
|
+
// inference complexity limit (TS2590). See ~lines 661-752.
|
|
2298
|
+
...OPEN_REDIRECT_FRAMEWORK_SINKS,
|
|
2299
|
+
...TRUST_BOUNDARY_FRAMEWORK_SINKS,
|
|
2123
2300
|
];
|
|
2124
2301
|
export const DEFAULT_SANITIZERS = [
|
|
2125
2302
|
// SQL Injection - proper parameter binding sanitizes input
|