oauthlint-rules 0.3.0 → 0.4.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.
Files changed (39) hide show
  1. package/dist/loader.d.ts +1 -1
  2. package/dist/schema.d.ts +79 -19
  3. package/dist/schema.d.ts.map +1 -1
  4. package/dist/schema.js +13 -4
  5. package/dist/schema.js.map +1 -1
  6. package/package.json +1 -1
  7. package/rules/cookie/no-samesite.yml +1 -1
  8. package/rules/cookie/samesite-none-insecure.yml +23 -1
  9. package/rules/cors/null-origin.yml +1 -1
  10. package/rules/cors/reflect-origin.yml +1 -1
  11. package/rules/flow/basic-auth-in-log.yml +99 -0
  12. package/rules/flow/open-redirect.yml +53 -21
  13. package/rules/flow/ssrf.yml +61 -21
  14. package/rules/flow/timing-unsafe-compare.yml +19 -0
  15. package/rules/go/cookie/insecure.yml +1 -1
  16. package/rules/go/cors/allow-all.yml +1 -1
  17. package/rules/go/flow/open-redirect.yml +16 -6
  18. package/rules/go/flow/ssrf.yml +16 -7
  19. package/rules/go/oauth/ropc-grant.yml +15 -0
  20. package/rules/java/cookie/insecure.yml +1 -1
  21. package/rules/java/cors/allow-all.yml +1 -1
  22. package/rules/java/cors/credentialed-wildcard.yml +1 -1
  23. package/rules/java/flow/ssrf.yml +113 -0
  24. package/rules/java/session/fixation-disabled.yml +1 -1
  25. package/rules/java/tls/trust-all-certs.yml +18 -7
  26. package/rules/oauth/no-state.yml +9 -8
  27. package/rules/oauth/open-redirect-callback.yml +18 -3
  28. package/rules/oauth/ropc-grant.yml +8 -3
  29. package/rules/oauth/static-state.yml +8 -7
  30. package/rules/py/cookie/insecure-flags.yml +1 -1
  31. package/rules/py/cors/allow-all.yml +1 -1
  32. package/rules/py/flow/requests-verify-disabled.yml +1 -1
  33. package/rules/py/oauth/ropc-grant.yml +12 -4
  34. package/rules/rust/cookie/insecure.yml +1 -1
  35. package/rules/rust/cors/permissive.yml +1 -1
  36. package/rules/rust/flow/ssrf.yml +90 -0
  37. package/rules/rust/oauth/ropc-grant.yml +17 -0
  38. package/rules/rust/oauth/static-state.yml +25 -5
  39. package/rules/tls/reject-unauthorized.yml +1 -1
@@ -4,6 +4,25 @@ rules:
4
4
  - javascript
5
5
  - typescript
6
6
  severity: ERROR
7
+ # Non-production code (example apps, demos, docs, vendored copies, tests)
8
+ # is not the library surface users ship, so findings there are noise for a
9
+ # low-FP linter. Globs intentionally omit `**/tests/**` / `**/fixtures/**`
10
+ # so the rule still fires on its own fixtures under rules/tests/fixtures/.
11
+ paths:
12
+ exclude:
13
+ - "**/test/**"
14
+ - "**/__tests__/**"
15
+ - "**/*.test.*"
16
+ - "**/*.spec.*"
17
+ - "**/example/**"
18
+ - "**/examples/**"
19
+ - "**/demo/**"
20
+ - "**/docs/**"
21
+ - "**/__mocks__/**"
22
+ - "**/mocks/**"
23
+ - "**/vendored/**"
24
+ - "**/node_modules/**"
25
+ - "**/*.stories.*"
7
26
  message: |
8
27
  Untrusted request input flows into the URL of an outbound HTTP request.
9
28
  Because the destination is attacker-controlled, this is a Server-Side
@@ -23,34 +42,55 @@ rules:
23
42
  # (isAllowedUrl, allowlist.includes, Set.has) clears the taint, so a
24
43
  # genuinely vetted outbound request does not fire.
25
44
  mode: taint
45
+ # `$REQ` is constrained to conventional request-object names so that
46
+ # unrelated receivers (`db.query`, `config.headers`, `someObj.body`) are not
47
+ # treated as untrusted request input.
26
48
  pattern-sources:
27
- - pattern: $REQ.query
28
- - pattern: $REQ.params
29
- - pattern: $REQ.body
30
- - pattern: $REQ.cookies
31
- - pattern: $REQ.headers
32
- - pattern: $REQ.query.$X
33
- - pattern: $REQ.params.$X
34
- - pattern: $REQ.body.$X
35
- - pattern: $REQ.cookies.$X
36
- - pattern: $REQ.headers.$X
37
- - pattern: $REQ.query[$K]
38
- - pattern: $REQ.params[$K]
39
- - pattern: $REQ.body[$K]
40
- - pattern: $REQ.cookies[$K]
41
- - pattern: $REQ.headers[$K]
49
+ - patterns:
50
+ - pattern-either:
51
+ - pattern: $REQ.query
52
+ - pattern: $REQ.params
53
+ - pattern: $REQ.body
54
+ - pattern: $REQ.cookies
55
+ - pattern: $REQ.headers
56
+ - pattern: $REQ.query.$X
57
+ - pattern: $REQ.params.$X
58
+ - pattern: $REQ.body.$X
59
+ - pattern: $REQ.cookies.$X
60
+ - pattern: $REQ.headers.$X
61
+ - pattern: $REQ.query[$K]
62
+ - pattern: $REQ.params[$K]
63
+ - pattern: $REQ.body[$K]
64
+ - pattern: $REQ.cookies[$K]
65
+ - pattern: $REQ.headers[$K]
66
+ - metavariable-regex:
67
+ metavariable: $REQ
68
+ regex: ^(req|request|ctx|context|c|event|r)$
42
69
  pattern-sanitizers:
43
70
  # Routing the value through a host allow-list / validation helper clears
44
71
  # the taint: only the vetted destination (not the raw request input)
45
- # reaches the request. Matched by a conventional validation-helper call,
46
- # or by an allow-list membership test (`Set.has` / `Array.includes`) that
47
- # the value is passed through.
72
+ # reaches the request.
48
73
  - pattern: isAllowedUrl(...)
49
74
  - pattern: validateUrl(...)
50
75
  - pattern: assertAllowedHost(...)
51
- - pattern: $ALLOW.includes(...)
52
- - pattern: $ALLOW.has(...)
53
- - pattern: $ALLOW.indexOf(...)
76
+ # An inline allow-list membership guard vets the value: a value used inside
77
+ # `if (allow.has(x)) { ... }` / `if (allow.includes(x)) { ... }` /
78
+ # `if (allow.indexOf(x) ...) { ... }` is treated as validated. The
79
+ # boolean-returning membership call itself does NOT sanitize its argument
80
+ # (that would only clear the boolean, not the value), so we clear taint by
81
+ # the if-guard, mirroring the Python rule's `if is_allowed_url(v): ...`.
82
+ - patterns:
83
+ - pattern: $X
84
+ - pattern-inside: |
85
+ if (<... $ALLOW.has($X) ...>) { ... }
86
+ - patterns:
87
+ - pattern: $X
88
+ - pattern-inside: |
89
+ if (<... $ALLOW.includes($X) ...>) { ... }
90
+ - patterns:
91
+ - pattern: $X
92
+ - pattern-inside: |
93
+ if (<... $ALLOW.indexOf($X) ...>) { ... }
54
94
  pattern-sinks:
55
95
  - patterns:
56
96
  - pattern-either:
@@ -4,6 +4,25 @@ rules:
4
4
  - javascript
5
5
  - typescript
6
6
  severity: WARNING
7
+ # Non-production code (example apps, demos, docs, vendored copies, tests)
8
+ # is not the library surface users ship, so findings there are noise for a
9
+ # low-FP linter. Globs intentionally omit `**/tests/**` / `**/fixtures/**`
10
+ # so the rule still fires on its own fixtures under rules/tests/fixtures/.
11
+ paths:
12
+ exclude:
13
+ - "**/test/**"
14
+ - "**/__tests__/**"
15
+ - "**/*.test.*"
16
+ - "**/*.spec.*"
17
+ - "**/example/**"
18
+ - "**/examples/**"
19
+ - "**/demo/**"
20
+ - "**/docs/**"
21
+ - "**/__mocks__/**"
22
+ - "**/mocks/**"
23
+ - "**/vendored/**"
24
+ - "**/node_modules/**"
25
+ - "**/*.stories.*"
7
26
  message: |
8
27
  A secret-shaped value (`password`, `token`, `secret`, `apiKey`,
9
28
  `csrf`, `hmac`) is being compared with `===` / `!==` /
@@ -35,7 +35,7 @@ rules:
35
35
  oauthlint-doc-url: https://oauthlint.dev/rules/go-cookie-insecure
36
36
  category: security
37
37
  cwe: CWE-614
38
- owasp: A05:2021
38
+ owasp: API8:2023
39
39
  llm-prevalence: HIGH
40
40
  technology:
41
41
  - net/http
@@ -32,7 +32,7 @@ rules:
32
32
  oauthlint-doc-url: https://oauthlint.dev/rules/go-cors-allow-all
33
33
  category: security
34
34
  cwe: CWE-942
35
- owasp: A05:2021
35
+ owasp: API8:2023
36
36
  llm-prevalence: HIGH
37
37
  technology:
38
38
  - gin
@@ -18,9 +18,11 @@ rules:
18
18
  redirecting. See CWE-601.
19
19
  # Taint mode so indirection (dest := r.FormValue("url"); http.Redirect(w,
20
20
  # r, dest, ...)) is caught, not just the inline form. The taint is cleared
21
- # by an allow-list / validation helper that vets the destination, or by a
22
- # url.Parse(...)-then-checked flow where the parsed value is inspected
23
- # before use.
21
+ # by an allow-list / validation helper that vets the destination, or inside
22
+ # an `if`-guard that checks the parsed host against an allow-list. A bare
23
+ # `url.Parse(...)` is NOT a sanitizer: the parsed struct's Host/Path/Scheme
24
+ # are still attacker-controlled, so parse-then-reflect without a host check
25
+ # is a real open redirect and must still fire.
24
26
  mode: taint
25
27
  pattern-sources:
26
28
  # $R is the *http.Request. Cover the common net/http input shapes.
@@ -35,9 +37,17 @@ rules:
35
37
  - pattern: validateRedirect(...)
36
38
  - pattern: isAllowedRedirect(...)
37
39
  - pattern: $ALLOW.MatchString(...)
38
- # url.Parse-then-checked: a parsed URL that has been inspected is treated
39
- # as cleared (the result is rebuilt/validated rather than reflected raw).
40
- - pattern: url.Parse(...)
40
+ # parse-then-host-checked: a value used inside an `if`-guard that looks the
41
+ # parsed host up in an allow-list map is treated as vetted, mirroring the
42
+ # Python rule's `if is_safe_url(...):` guard. A bare `url.Parse(...)` is
43
+ # deliberately NOT listed — it returns an attacker-controlled struct and
44
+ # does not validate anything, so parse-then-reflect still fires.
45
+ - patterns:
46
+ - pattern: $V
47
+ - pattern-inside: |
48
+ if $ALLOW[$U.Host] {
49
+ ...
50
+ }
41
51
  pattern-sinks:
42
52
  - patterns:
43
53
  - pattern-either:
@@ -20,9 +20,11 @@ rules:
20
20
  link-local address ranges before dialing. See CWE-918.
21
21
  # Taint mode so indirection (target := r.FormValue("endpoint");
22
22
  # http.Get(target)) is caught, not just the inline form. The taint is
23
- # cleared by an allow-list / host-validation helper, or by a
24
- # url.Parse(...)-then-checked flow where the parsed host is vetted before
25
- # the request is made.
23
+ # cleared by an allow-list / host-validation helper, or inside an
24
+ # `if`-guard that checks the parsed host against an allow-list. A bare
25
+ # `url.Parse(...)` is NOT a sanitizer: the parsed struct's Host/Path/Scheme
26
+ # are still attacker-controlled, so parse-then-use without a host check is a
27
+ # real SSRF and must still fire.
26
28
  mode: taint
27
29
  pattern-sources:
28
30
  # $R is the *http.Request. Cover the common net/http input shapes.
@@ -37,10 +39,17 @@ rules:
37
39
  - pattern: validateURL(...)
38
40
  - pattern: isAllowedHost(...)
39
41
  - pattern: $ALLOW.MatchString(...)
40
- # url.Parse-then-checked: a parsed URL whose host has been inspected is
41
- # treated as cleared (the request is built from a vetted destination
42
- # rather than the raw untrusted string).
43
- - pattern: url.Parse(...)
42
+ # parse-then-host-checked: a value used inside an `if`-guard that looks the
43
+ # parsed host up in an allow-list map is treated as vetted, mirroring the
44
+ # Python rule's `if is_allowed_url(...):` guard. A bare `url.Parse(...)` is
45
+ # deliberately NOT listed — it returns an attacker-controlled struct and
46
+ # does not validate anything, so parse-then-use still fires.
47
+ - patterns:
48
+ - pattern: $V
49
+ - pattern-inside: |
50
+ if $ALLOW[$U.Host] {
51
+ ...
52
+ }
44
53
  pattern-sinks:
45
54
  # Focus the URL argument so the finding lands on the tainted destination,
46
55
  # not the whole call. The plain call form is used (no aliasing) because
@@ -34,6 +34,21 @@ rules:
34
34
  # value so only the password grant matches.
35
35
  - pattern-regex: |-
36
36
  [?&"`]grant_type=password(?:[&"`\s\\]|$)
37
+ # We flag an application sending ROPC, not the example/test code or vendored
38
+ # client libraries that legitimately implement the grant. Excluding these
39
+ # trees keeps the signal on first-party application code; a vendored copy of
40
+ # `golang.org/x/oauth2`, for instance, must not trip this rule.
41
+ paths:
42
+ exclude:
43
+ - "**/test/**"
44
+ - "**/*_test.go"
45
+ - "**/*_test.*"
46
+ - "**/example/**"
47
+ - "**/examples/**"
48
+ - "**/mock*/**"
49
+ - "**/testdata/**"
50
+ - "**/vendor/**"
51
+ - "**/node_modules/**"
37
52
  metadata:
38
53
  oauthlint-rule-id: AUTH-GO-OAUTH-001
39
54
  oauthlint-doc-url: https://oauthlint.dev/rules/go-oauth-ropc-grant
@@ -22,7 +22,7 @@ rules:
22
22
  oauthlint-doc-url: https://oauthlint.dev/rules/java-cookie-insecure
23
23
  category: security
24
24
  cwe: CWE-614
25
- owasp: A05:2021
25
+ owasp: API8:2023
26
26
  llm-prevalence: HIGH
27
27
  technology:
28
28
  - servlet
@@ -38,7 +38,7 @@ rules:
38
38
  oauthlint-doc-url: https://oauthlint.dev/rules/java-cors-allow-all
39
39
  category: security
40
40
  cwe: CWE-942
41
- owasp: A05:2021
41
+ owasp: API8:2023
42
42
  llm-prevalence: HIGH
43
43
  technology:
44
44
  - spring-web
@@ -34,7 +34,7 @@ rules:
34
34
  oauthlint-doc-url: https://oauthlint.dev/rules/java-cors-credentialed-wildcard
35
35
  category: security
36
36
  cwe: CWE-942
37
- owasp: A05:2021
37
+ owasp: API8:2023
38
38
  llm-prevalence: MEDIUM
39
39
  technology:
40
40
  - spring-web
@@ -0,0 +1,113 @@
1
+ rules:
2
+ - id: auth.java.flow.ssrf
3
+ languages:
4
+ - java
5
+ severity: ERROR
6
+ # Non-production code (example apps, demos, docs, vendored copies, tests)
7
+ # is not the library surface users ship, so findings there are noise for a
8
+ # low-FP linter. Globs intentionally omit `**/test/**`-style fixture paths
9
+ # so the rule still fires on its own fixtures under rules/tests/fixtures/.
10
+ paths:
11
+ exclude:
12
+ - "**/src/test/**"
13
+ - "**/example/**"
14
+ - "**/examples/**"
15
+ - "**/demo/**"
16
+ - "**/docs/**"
17
+ message: |
18
+ Untrusted request input flows into the URL of an outbound HTTP request.
19
+ Because the destination is attacker-controlled, this is a Server-Side
20
+ Request Forgery (CWE-918): an attacker can point the request at internal
21
+ services behind your firewall, or at the cloud metadata endpoint
22
+ (http://169.254.169.254/...) to steal IAM/instance credentials and pivot
23
+ deeper into your infrastructure.
24
+
25
+ Never build a request URL straight from a Spring `@RequestParam` /
26
+ `@RequestBody` value or a raw `HttpServletRequest.getParameter(...)` /
27
+ `getHeader(...)` value. Validate the destination against an explicit
28
+ allow-list of hosts (resolve the URL and check its host against the
29
+ allow-list, rejecting private/loopback ranges) before issuing the request
30
+ with `RestTemplate`, `WebClient`, OkHttp, or Apache HttpClient.
31
+ # Taint mode so indirection is caught — `String u = req.getParameter("url");
32
+ # restTemplate.getForObject(u, ...)` flags, not just the inline form.
33
+ # Passing the value through a host allow-list / validation guard
34
+ # (isAllowedUrl, validateUrl, assertAllowedHost, or an allow-list
35
+ # `contains(...)` if-guard) clears the taint, so a genuinely vetted
36
+ # outbound request does not fire.
37
+ mode: taint
38
+ pattern-sources:
39
+ # Spring MVC handler parameters annotated with @RequestParam / @RequestBody
40
+ # carry attacker-controlled request data. Focus the parameter so the taint
41
+ # tracks the value, not the whole method.
42
+ - patterns:
43
+ - pattern-either:
44
+ - pattern: "$RET $M(..., @RequestParam $T $P, ...) {...}"
45
+ - pattern: "$RET $M(..., @RequestParam(...) $T $P, ...) {...}"
46
+ - pattern: "$RET $M(..., @RequestBody $T $P, ...) {...}"
47
+ - focus-metavariable: $P
48
+ # Servlet API request accessors. Constrained to an HttpServletRequest
49
+ # receiver so unrelated `.getParameter(...)` / `.getHeader(...)` calls on
50
+ # other objects are not treated as untrusted input.
51
+ - pattern: (HttpServletRequest $REQ).getParameter(...)
52
+ - pattern: (HttpServletRequest $REQ).getParameterValues(...)
53
+ - pattern: (HttpServletRequest $REQ).getHeader(...)
54
+ pattern-sanitizers:
55
+ # Routing the value through a host allow-list / validation helper clears
56
+ # the taint: only the vetted destination (not the raw request input)
57
+ # reaches the request.
58
+ - pattern: isAllowedUrl(...)
59
+ - pattern: isAllowedHost(...)
60
+ - pattern: validateUrl(...)
61
+ - pattern: assertAllowedHost(...)
62
+ # An inline allow-list membership guard vets the value: a value used inside
63
+ # `if (allow.contains(...)) { ... }` is treated as validated, mirroring the
64
+ # Python rule's `if is_allowed_url(v): ...`. The boolean-returning
65
+ # membership call itself does NOT sanitize (that clears only the boolean),
66
+ # so taint is cleared by the if-guard.
67
+ - patterns:
68
+ - pattern: $V
69
+ - pattern-inside: |
70
+ if (<... $ALLOW.contains(<... $V ...>) ...>) { ... }
71
+ pattern-sinks:
72
+ # Focus the URL argument so the finding lands on the tainted destination,
73
+ # not the whole call.
74
+ - patterns:
75
+ - pattern-either:
76
+ # Spring RestTemplate.
77
+ - pattern: $RT.getForObject($URL, ...)
78
+ - pattern: $RT.getForEntity($URL, ...)
79
+ - pattern: $RT.postForObject($URL, ...)
80
+ - pattern: $RT.postForEntity($URL, ...)
81
+ - pattern: $RT.exchange($URL, ...)
82
+ - pattern: $RT.execute($URL, ...)
83
+ # Spring WebClient fluent URI.
84
+ - pattern: $WC.uri($URL)
85
+ - pattern: $WC.uri($URL, ...)
86
+ # OkHttp Request.Builder.
87
+ - pattern: $B.url($URL)
88
+ # Apache HttpClient request objects.
89
+ - pattern: new HttpGet($URL)
90
+ - pattern: new HttpPost($URL)
91
+ - pattern: new HttpPut($URL)
92
+ - pattern: new HttpDelete($URL)
93
+ - pattern: new HttpHead($URL)
94
+ # JDK URL/URI opened directly.
95
+ - pattern: new URL($URL)
96
+ - pattern: new URI($URL)
97
+ - focus-metavariable: $URL
98
+ metadata:
99
+ oauthlint-rule-id: AUTH-JAVA-FLOW-001
100
+ oauthlint-doc-url: https://oauthlint.dev/rules/java-flow-ssrf
101
+ category: security
102
+ cwe: CWE-918
103
+ owasp: API7:2023
104
+ llm-prevalence: HIGH
105
+ technology:
106
+ - spring
107
+ - resttemplate
108
+ - webclient
109
+ - okhttp
110
+ - apache-httpclient
111
+ references:
112
+ - https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html
113
+ - https://cwe.mitre.org/data/definitions/918.html
@@ -25,7 +25,7 @@ rules:
25
25
  oauthlint-doc-url: https://oauthlint.dev/rules/java-session-fixation-disabled
26
26
  category: security
27
27
  cwe: CWE-384
28
- owasp: A07:2021
28
+ owasp: API2:2023
29
29
  llm-prevalence: MEDIUM
30
30
  technology:
31
31
  - spring-security
@@ -21,13 +21,24 @@ rules:
21
21
  # HttpClient's NoopHostnameVerifier. A HostnameVerifier with real
22
22
  # (non-trivial) logic and the default verifier are not matched.
23
23
  pattern-either:
24
- # Lambda that always returns true: (hostname, session) -> true
25
- - pattern: ($HOST, $SESSION) -> true
26
- # Anonymous HostnameVerifier whose verify(...) just returns true.
27
- - pattern: |
28
- new HostnameVerifier() {
29
- public boolean verify(String $H, SSLSession $S) { return true; }
30
- }
24
+ # Lambda that always returns true, scoped to a hostname-verifier context
25
+ # so a generic two-arg lambda (BiPredicate, comparator, etc.) returning
26
+ # true is not mistaken for a permissive verifier.
27
+ - patterns:
28
+ - pattern: ($HOST, $SESSION) -> true
29
+ - pattern-either:
30
+ - pattern-inside: $X.setHostnameVerifier(...)
31
+ - pattern-inside: $X.setDefaultHostnameVerifier(...)
32
+ # Anonymous HostnameVerifier whose verify(...) just returns true, scoped to
33
+ # where it is actually installed as the verifier.
34
+ - patterns:
35
+ - pattern: |
36
+ new HostnameVerifier() {
37
+ public boolean verify(String $H, SSLSession $S) { return true; }
38
+ }
39
+ - pattern-either:
40
+ - pattern-inside: $X.setHostnameVerifier(...)
41
+ - pattern-inside: $X.setDefaultHostnameVerifier(...)
31
42
  # Apache HttpClient NoopHostnameVerifier (constructor or INSTANCE).
32
43
  - pattern: new org.apache.http.conn.ssl.NoopHostnameVerifier()
33
44
  - pattern: new NoopHostnameVerifier()
@@ -14,14 +14,15 @@ rules:
14
14
  substitute for `state` when handling browser sessions.
15
15
  pattern-either:
16
16
  # Inline authorize URL carrying both client_id and response_type but no
17
- # state. The path is not hardcoded (Google uses /o/oauth2/v2/auth, etc.).
18
- - patterns:
19
- - pattern-regex: |-
20
- ['"]https?://[^'"\s]+\?[^'"]*client_id=[^'"]*['"]
21
- - pattern-regex: |-
22
- response_type=
23
- - pattern-not-regex: |-
24
- state=
17
+ # state, evaluated per quoted URL literal (the lookaheads/lookbehind are
18
+ # bounded to the contents of one string by `[^'"]`). This avoids the
19
+ # file-level false negative where a `state=` elsewhere in the file (a
20
+ # comment, a different correct call) would suppress a genuinely
21
+ # state-less URL. The path is not hardcoded (Google uses
22
+ # /o/oauth2/v2/auth, etc.). Single/double quotes only — a dynamic
23
+ # template-literal URL (backticks) is excluded.
24
+ - pattern-regex: |-
25
+ ['"]https?://(?=[^'"]*[?&]client_id=)(?=[^'"]*[?&]response_type=)(?![^'"]*[?&]state=)[^'"]+['"]
25
26
  # Programmatic URLSearchParams build (AST object match — robust to key
26
27
  # order and length). Fires when client_id + response_type are present but
27
28
  # state is not (covers both `state: x` and the `state` shorthand).
@@ -25,9 +25,24 @@ rules:
25
25
  - pattern: '$REQ.query[$K]'
26
26
  - pattern: '$REQ.body[$K]'
27
27
  pattern-sanitizers:
28
- - pattern: '$SET.has(...)'
29
- - pattern: '$ARR.includes(...)'
30
- - pattern: '$ARR.indexOf(...)'
28
+ # An inline allow-list membership guard vets the value: a value used inside
29
+ # `if (set.has(x)) { ... }` / `if (arr.includes(x)) { ... }` /
30
+ # `if (arr.indexOf(x) ...) { ... }` is treated as validated. The
31
+ # boolean-returning membership call itself does NOT sanitize its argument
32
+ # (that would only clear the boolean, not the value), so we clear taint by
33
+ # the if-guard, mirroring the Python rule's `if is_safe_url(v): ...`.
34
+ - patterns:
35
+ - pattern: $X
36
+ - pattern-inside: |
37
+ if (<... $SET.has($X) ...>) { ... }
38
+ - patterns:
39
+ - pattern: $X
40
+ - pattern-inside: |
41
+ if (<... $ARR.includes($X) ...>) { ... }
42
+ - patterns:
43
+ - pattern: $X
44
+ - pattern-inside: |
45
+ if (<... $ARR.indexOf($X) ...>) { ... }
31
46
  pattern-sinks:
32
47
  - patterns:
33
48
  - pattern-either:
@@ -16,10 +16,15 @@ rules:
16
16
  (`grant_type=authorization_code`) for user login, or
17
17
  `client_credentials` for machine-to-machine.
18
18
  pattern-either:
19
- # Object literal / assignment: { grant_type: 'password' } or
20
- # grant_type = 'password'. The `=` alt also covers `grant_type = "password"`.
19
+ # Object literal entry: `{ grant_type: 'password' }` (bare or quoted key).
20
+ # The colon anchors it to a property, not a bare variable assignment.
21
21
  - pattern-regex: |-
22
- grant_type\s*[:=]\s*['"]password['"]
22
+ grant_type\s*:\s*['"]password['"]
23
+ # Property write that builds a request body: `body.grant_type = 'password'`.
24
+ # The leading `.` requires a member assignment, so a library's own bare
25
+ # local `grant_type = 'password'` (an internal constant) is NOT flagged.
26
+ - pattern-regex: |-
27
+ \.grant_type\s*=\s*['"]password['"]
23
28
  # URL-encoded request body: "grant_type=password&username=…" (single,
24
29
  # double, or template-literal string). The value is bounded so
25
30
  # `grant_type=password_reset` and friends are not flagged.
@@ -28,13 +28,14 @@ rules:
28
28
  - pattern: 'new URLSearchParams({..., state: "$S", ...})'
29
29
  - pattern: "new URLSearchParams({..., state: '$S', ...})"
30
30
  # Inline authorize URL string literal carrying both response_type and a
31
- # constant state value. A dynamic state would be a template literal
32
- # (backticks) with `${...}`, which this single/double-quoted form excludes.
33
- - patterns:
34
- - pattern-regex: |-
35
- ['"]https?://[^'"\s]+\?[^'"]*response_type=[^'"]*['"]
36
- - pattern-regex: |-
37
- ['"]https?://[^'"\s]+\?[^'"]*state=[A-Za-z0-9._~%-]+[^'"]*['"]
31
+ # constant state value WITHIN THE SAME quoted literal. Using a single
32
+ # regex (lookaheads bounded by `[^'"]`) prevents the file-level false
33
+ # positive where `response_type=` in one string and a constant `state=`
34
+ # in a different string would otherwise combine into a finding. A dynamic
35
+ # state would be a template literal (backticks) with `${...}`, which this
36
+ # single/double-quoted form excludes.
37
+ - pattern-regex: |-
38
+ ['"]https?://(?=[^'"]*[?&]response_type=)(?=[^'"]*[?&]state=[A-Za-z0-9._~%-]+)[^'"]+['"]
38
39
  metadata:
39
40
  oauthlint-rule-id: AUTH-OAUTH-016
40
41
  oauthlint-doc-url: https://oauthlint.dev/rules/oauth-static-state
@@ -30,7 +30,7 @@ rules:
30
30
  oauthlint-doc-url: https://oauthlint.dev/rules/py-cookie-insecure-flags
31
31
  category: security
32
32
  cwe: CWE-614
33
- owasp: A05:2021
33
+ owasp: API8:2023
34
34
  llm-prevalence: HIGH
35
35
  technology:
36
36
  - flask
@@ -46,7 +46,7 @@ rules:
46
46
  oauthlint-doc-url: https://oauthlint.dev/rules/py-cors-allow-all
47
47
  category: security
48
48
  cwe: CWE-942
49
- owasp: A05:2021
49
+ owasp: API8:2023
50
50
  llm-prevalence: MEDIUM
51
51
  technology:
52
52
  - flask-cors
@@ -41,7 +41,7 @@ rules:
41
41
  oauthlint-doc-url: https://oauthlint.dev/rules/py-flow-requests-verify-disabled
42
42
  category: security
43
43
  cwe: CWE-295
44
- owasp: API8:2023
44
+ owasp: A02:2021
45
45
  llm-prevalence: HIGH
46
46
  technology:
47
47
  - requests
@@ -21,12 +21,20 @@ rules:
21
21
  # (dict / kwarg form) or bounded token (URL-encoded form), so
22
22
  # `grant_type=password_reset` and `grant_type=client_credentials` never
23
23
  # fire, and a dynamic `grant_type=grant` variable is not a literal and is
24
- # not flagged.
24
+ # not flagged. Each form anchors `grant_type` to a request-parameter
25
+ # position (dict key, call keyword, query string, or pair) so a library's
26
+ # own bare local assignment — `grant_type = "password"`, as in Authlib's
27
+ # `_guess_grant_type` — is NOT treated as an application sending the grant.
25
28
  pattern-either:
26
- # Dict entry `"grant_type": "password"` or keyword `grant_type="password"`.
27
- # The optional quote after the key covers the dict form's closing `"`.
29
+ # Dict / mapping entry: `{"grant_type": "password"}`. The key is a quoted
30
+ # literal followed by a colon, which a bare variable assignment is not.
28
31
  - pattern-regex: |-
29
- grant_type['"]?\s*[:=]\s*['"]password['"]
32
+ ['"]grant_type['"]\s*:\s*['"]password['"]
33
+ # Call keyword argument: `fetch_token(..., grant_type="password")`. The
34
+ # leading `(` or `,` anchors it to an argument list, so a top-level
35
+ # statement `grant_type = "password"` (library internal) does not match.
36
+ - pattern-regex: |-
37
+ [(,]\s*grant_type\s*=\s*['"]password['"]
30
38
  # URL-encoded request body: "grant_type=password&username=…". The value is
31
39
  # bounded so `grant_type=password_reset` is not flagged.
32
40
  - pattern-regex: |-
@@ -26,7 +26,7 @@ rules:
26
26
  oauthlint-doc-url: https://oauthlint.dev/rules/rust-cookie-insecure
27
27
  category: security
28
28
  cwe: CWE-614
29
- owasp: A05:2021
29
+ owasp: API8:2023
30
30
  llm-prevalence: HIGH
31
31
  technology:
32
32
  - cookie
@@ -27,7 +27,7 @@ rules:
27
27
  oauthlint-doc-url: https://oauthlint.dev/rules/rust-cors-permissive
28
28
  category: security
29
29
  cwe: CWE-942
30
- owasp: A05:2021
30
+ owasp: API8:2023
31
31
  llm-prevalence: MEDIUM
32
32
  technology:
33
33
  - actix-web