circle-ir 3.174.0 → 3.176.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.
@@ -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,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
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * cognium-dev #256 — same-file argument-type resolver.
3
+ *
4
+ * Two sink-shape gates ship in circle-ir today match only the DIRECT/LITERAL
5
+ * argument form and miss argument indirection:
6
+ *
7
+ * 1. `safe_if_class_literal_at` (taint-matcher.ts, #22) — matches
8
+ * `readValue(json, Foo.class)` but not `readValue(json, templateClass)`
9
+ * where `templateClass` is a `Class<T>` parameter.
10
+ * 2. Stage-11 `PROCESS_BUILDER_ARGV_FORM_RE` (sink-filter-pass.ts, #179)
11
+ * matches `new ProcessBuilder(Arrays.asList(...))` but not
12
+ * `new ProcessBuilder(buildCommand(...))` where `buildCommand` returns
13
+ * `List<String>`.
14
+ *
15
+ * This module provides two pure, same-file, `TypeInfo[]`-based helpers to
16
+ * resolve the effective type of an argument that is either:
17
+ * - a bare identifier (parameter or field name), or
18
+ * - a method-call expression (callee name).
19
+ *
20
+ * Same-file only — locals declared inside method bodies and cross-file
21
+ * resolutions are deferred. Both #256 repros (jib, flyingsaucer) are
22
+ * same-method-parameter / same-class-static-callee, so this scope suffices.
23
+ *
24
+ * Design guarantee: both resolvers return null liberally. A null return
25
+ * flows to the existing gate's default-dangerous behavior (sink fires) —
26
+ * so any resolver bug regresses gracefully to current (over-firing)
27
+ * behavior, never to false-negative.
28
+ */
29
+ import type { TypeInfo } from '../types/index.js';
30
+ /**
31
+ * Resolve the declared type of a bare-identifier argument (parameter or
32
+ * field) visible at `callInMethod` scope.
33
+ *
34
+ * Lookup order:
35
+ * 1. Parameters of the enclosing method (matching `callInMethod`).
36
+ * 2. Fields of the enclosing type (any visibility).
37
+ * 3. If enclosing type not found, scan ALL types' method params + fields
38
+ * (best-effort for top-level functions or method-name collisions).
39
+ *
40
+ * Returns the raw type string as extracted (`"Class<T>"`, `"List<String>"`,
41
+ * `"java.util.List<String>"`, `"Class<? extends JsonTemplate>"`, …) or null.
42
+ */
43
+ export declare function resolveIdentifierType(name: string, callInMethod: string | null | undefined, types: TypeInfo[]): string | null;
44
+ /**
45
+ * Resolve the declared return type of a same-file method invoked by
46
+ * `calleeName`. Accepts a bare callee name (as extracted into
47
+ * `ArgumentInfo.variable` for call expressions like `buildCommand(x, y)`).
48
+ *
49
+ * Preference order:
50
+ * 1. Method on the enclosing type matching `callInMethod`.
51
+ * 2. Method on any type in the file (static call `MyClass.foo()` case).
52
+ *
53
+ * Overload handling: if the enclosing type has multiple methods with the
54
+ * same name, returns the first one whose `return_type` is non-null. Full
55
+ * overload resolution would need argument-expression typing that we don't
56
+ * have; ambiguity is rare in practice and biases toward null (which
57
+ * flows to the current default-dangerous behavior).
58
+ */
59
+ export declare function resolveCallReturnType(calleeName: string, callInMethod: string | null | undefined, types: TypeInfo[]): string | null;
60
+ /**
61
+ * true when the raw type string represents a Java `Class` type (any bound):
62
+ * `Class`, `Class<T>`, `Class<? extends X>`, `Class<Foo>`, `java.lang.Class<...>`.
63
+ *
64
+ * NEVER matches:
65
+ * - `Class.forName(x)` — that's a call expression, not a declared type;
66
+ * lookups against `ir.types` won't find it (JDK reflection isn't
67
+ * user code).
68
+ * - `getClass()` return type — for the same reason.
69
+ * - Raw types missing generic bounds are Jackson-safe in the same way
70
+ * as the generic form: a bare `Class` param still has a compile-time
71
+ * type identity, so we accept it.
72
+ */
73
+ export declare function isBoundedClassType(rawType: string | null): boolean;
74
+ /**
75
+ * true when the raw type resolves to a container shape that
76
+ * `ProcessBuilder(argv)` accepts as non-exploitable — the JVM passes the
77
+ * elements to `fork(2)` directly, no shell interpolation:
78
+ *
79
+ * - `List<String>` (any parameterization narrower than `Object`)
80
+ * - `ArrayList<String>`, `LinkedList<String>`
81
+ * - `Collection<String>`, `Iterable<String>`, `Deque<String>`, `Queue<String>`
82
+ * - `String[]`, `String ...` (varargs)
83
+ * - Fully qualified variants: `java.util.List<String>`, etc.
84
+ *
85
+ * Excludes bare `List` / `List<Object>` / `Collection<?>` — those permit
86
+ * arbitrary element types that could carry non-String content the JVM
87
+ * would `.toString()` unsafely.
88
+ */
89
+ export declare function isArgvContainerType(rawType: string | null): boolean;
90
+ //# sourceMappingURL=arg-type-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arg-type-resolver.d.ts","sourceRoot":"","sources":["../../src/analysis/arg-type-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAoBlD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACvC,KAAK,EAAE,QAAQ,EAAE,GAChB,MAAM,GAAG,IAAI,CA8Bf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACvC,KAAK,EAAE,QAAQ,EAAE,GAChB,MAAM,GAAG,IAAI,CAef;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAIlE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAUnE"}
@@ -0,0 +1,174 @@
1
+ /**
2
+ * cognium-dev #256 — same-file argument-type resolver.
3
+ *
4
+ * Two sink-shape gates ship in circle-ir today match only the DIRECT/LITERAL
5
+ * argument form and miss argument indirection:
6
+ *
7
+ * 1. `safe_if_class_literal_at` (taint-matcher.ts, #22) — matches
8
+ * `readValue(json, Foo.class)` but not `readValue(json, templateClass)`
9
+ * where `templateClass` is a `Class<T>` parameter.
10
+ * 2. Stage-11 `PROCESS_BUILDER_ARGV_FORM_RE` (sink-filter-pass.ts, #179)
11
+ * matches `new ProcessBuilder(Arrays.asList(...))` but not
12
+ * `new ProcessBuilder(buildCommand(...))` where `buildCommand` returns
13
+ * `List<String>`.
14
+ *
15
+ * This module provides two pure, same-file, `TypeInfo[]`-based helpers to
16
+ * resolve the effective type of an argument that is either:
17
+ * - a bare identifier (parameter or field name), or
18
+ * - a method-call expression (callee name).
19
+ *
20
+ * Same-file only — locals declared inside method bodies and cross-file
21
+ * resolutions are deferred. Both #256 repros (jib, flyingsaucer) are
22
+ * same-method-parameter / same-class-static-callee, so this scope suffices.
23
+ *
24
+ * Design guarantee: both resolvers return null liberally. A null return
25
+ * flows to the existing gate's default-dangerous behavior (sink fires) —
26
+ * so any resolver bug regresses gracefully to current (over-firing)
27
+ * behavior, never to false-negative.
28
+ */
29
+ /**
30
+ * Locate the TypeInfo whose `methods` list contains a method named
31
+ * `callInMethod`. Falls back to `null` if not found (e.g. top-level
32
+ * function, or method name collision that our best-effort match misses).
33
+ */
34
+ function findEnclosingType(callInMethod, types) {
35
+ if (!callInMethod)
36
+ return null;
37
+ for (const t of types) {
38
+ for (const m of t.methods) {
39
+ if (m.name === callInMethod)
40
+ return t;
41
+ }
42
+ }
43
+ return null;
44
+ }
45
+ /**
46
+ * Resolve the declared type of a bare-identifier argument (parameter or
47
+ * field) visible at `callInMethod` scope.
48
+ *
49
+ * Lookup order:
50
+ * 1. Parameters of the enclosing method (matching `callInMethod`).
51
+ * 2. Fields of the enclosing type (any visibility).
52
+ * 3. If enclosing type not found, scan ALL types' method params + fields
53
+ * (best-effort for top-level functions or method-name collisions).
54
+ *
55
+ * Returns the raw type string as extracted (`"Class<T>"`, `"List<String>"`,
56
+ * `"java.util.List<String>"`, `"Class<? extends JsonTemplate>"`, …) or null.
57
+ */
58
+ export function resolveIdentifierType(name, callInMethod, types) {
59
+ if (!name)
60
+ return null;
61
+ const enclosing = findEnclosingType(callInMethod, types);
62
+ if (enclosing) {
63
+ // Parameter check (preferred — narrower scope, shadows fields).
64
+ for (const m of enclosing.methods) {
65
+ if (m.name !== callInMethod)
66
+ continue;
67
+ for (const p of m.parameters) {
68
+ if (p.name === name && p.type)
69
+ return p.type;
70
+ }
71
+ }
72
+ // Field check on the enclosing type.
73
+ for (const f of enclosing.fields) {
74
+ if (f.name === name && f.type)
75
+ return f.type;
76
+ }
77
+ return null;
78
+ }
79
+ // Fallback: scan all types (top-level function case, or extractor didn't
80
+ // populate `in_method` reliably for this language).
81
+ for (const t of types) {
82
+ for (const m of t.methods) {
83
+ for (const p of m.parameters) {
84
+ if (p.name === name && p.type)
85
+ return p.type;
86
+ }
87
+ }
88
+ for (const f of t.fields) {
89
+ if (f.name === name && f.type)
90
+ return f.type;
91
+ }
92
+ }
93
+ return null;
94
+ }
95
+ /**
96
+ * Resolve the declared return type of a same-file method invoked by
97
+ * `calleeName`. Accepts a bare callee name (as extracted into
98
+ * `ArgumentInfo.variable` for call expressions like `buildCommand(x, y)`).
99
+ *
100
+ * Preference order:
101
+ * 1. Method on the enclosing type matching `callInMethod`.
102
+ * 2. Method on any type in the file (static call `MyClass.foo()` case).
103
+ *
104
+ * Overload handling: if the enclosing type has multiple methods with the
105
+ * same name, returns the first one whose `return_type` is non-null. Full
106
+ * overload resolution would need argument-expression typing that we don't
107
+ * have; ambiguity is rare in practice and biases toward null (which
108
+ * flows to the current default-dangerous behavior).
109
+ */
110
+ export function resolveCallReturnType(calleeName, callInMethod, types) {
111
+ if (!calleeName)
112
+ return null;
113
+ const enclosing = findEnclosingType(callInMethod, types);
114
+ if (enclosing) {
115
+ for (const m of enclosing.methods) {
116
+ if (m.name === calleeName && m.return_type)
117
+ return m.return_type;
118
+ }
119
+ }
120
+ // Fallback: any type in file. Static calls / helper classes.
121
+ for (const t of types) {
122
+ for (const m of t.methods) {
123
+ if (m.name === calleeName && m.return_type)
124
+ return m.return_type;
125
+ }
126
+ }
127
+ return null;
128
+ }
129
+ /**
130
+ * true when the raw type string represents a Java `Class` type (any bound):
131
+ * `Class`, `Class<T>`, `Class<? extends X>`, `Class<Foo>`, `java.lang.Class<...>`.
132
+ *
133
+ * NEVER matches:
134
+ * - `Class.forName(x)` — that's a call expression, not a declared type;
135
+ * lookups against `ir.types` won't find it (JDK reflection isn't
136
+ * user code).
137
+ * - `getClass()` return type — for the same reason.
138
+ * - Raw types missing generic bounds are Jackson-safe in the same way
139
+ * as the generic form: a bare `Class` param still has a compile-time
140
+ * type identity, so we accept it.
141
+ */
142
+ export function isBoundedClassType(rawType) {
143
+ if (!rawType)
144
+ return false;
145
+ const stripped = rawType.trim().replace(/^(?:java\.lang\.)+/, '');
146
+ return /^Class(?:\s*<[\s\S]*>)?$/.test(stripped);
147
+ }
148
+ /**
149
+ * true when the raw type resolves to a container shape that
150
+ * `ProcessBuilder(argv)` accepts as non-exploitable — the JVM passes the
151
+ * elements to `fork(2)` directly, no shell interpolation:
152
+ *
153
+ * - `List<String>` (any parameterization narrower than `Object`)
154
+ * - `ArrayList<String>`, `LinkedList<String>`
155
+ * - `Collection<String>`, `Iterable<String>`, `Deque<String>`, `Queue<String>`
156
+ * - `String[]`, `String ...` (varargs)
157
+ * - Fully qualified variants: `java.util.List<String>`, etc.
158
+ *
159
+ * Excludes bare `List` / `List<Object>` / `Collection<?>` — those permit
160
+ * arbitrary element types that could carry non-String content the JVM
161
+ * would `.toString()` unsafely.
162
+ */
163
+ export function isArgvContainerType(rawType) {
164
+ if (!rawType)
165
+ return false;
166
+ const s = rawType.trim().replace(/^(?:java\.util\.|java\.lang\.)+/, '');
167
+ // String[] or String...
168
+ if (/^String\s*(?:\[\s*\]|\.\.\.)$/.test(s))
169
+ return true;
170
+ // Container<String>-like — permit CharSequence too (String subtype narrower
171
+ // than Object). Reject `<?>`, `<? extends Object>`, bare `<Object>`.
172
+ return /^(?:List|ArrayList|LinkedList|Collection|Iterable|Deque|Queue)\s*<\s*(?:String|CharSequence|java\.lang\.String)\b/.test(s);
173
+ }
174
+ //# sourceMappingURL=arg-type-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arg-type-resolver.js","sourceRoot":"","sources":["../../src/analysis/arg-type-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH;;;;GAIG;AACH,SAAS,iBAAiB,CACxB,YAAuC,EACvC,KAAiB;IAEjB,IAAI,CAAC,YAAY;QAAE,OAAO,IAAI,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY;gBAAE,OAAO,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB,CACnC,IAAY,EACZ,YAAuC,EACvC,KAAiB;IAEjB,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,SAAS,GAAG,iBAAiB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACzD,IAAI,SAAS,EAAE,CAAC;QACd,gEAAgE;QAChE,KAAK,MAAM,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;YAClC,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY;gBAAE,SAAS;YACtC,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;gBAC7B,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,IAAI;oBAAE,OAAO,CAAC,CAAC,IAAI,CAAC;YAC/C,CAAC;QACH,CAAC;QACD,qCAAqC;QACrC,KAAK,MAAM,CAAC,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;YACjC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,IAAI;gBAAE,OAAO,CAAC,CAAC,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AU,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
- { method: 'Redirect', type: 'open_redirect', cwe: 'CWE-601', severity: 'medium', arg_positions: [0] },
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] },
@@ -2198,6 +2290,13 @@ export const DEFAULT_SINKS = [
2198
2290
  { method: 'Call', class: 'LLM', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['go'] },
2199
2291
  { method: 'Generate', class: 'LLM', type: 'prompt_injection', cwe: 'CWE-1427', severity: 'high', arg_positions: [0, 1, 2, 3], languages: ['go'] },
2200
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,
2201
2300
  ];
2202
2301
  export const DEFAULT_SANITIZERS = [
2203
2302
  // SQL Injection - proper parameter binding sanitizes input