|
1 | 1 | /**
|
2 |
| - * Provides a taint-tracking configuration for detecting URL redirection |
3 |
| - * vulnerabilities. |
| 2 | + * Provides a taint-tracking configuration for detecting "URL redirection" vulnerabilities. |
| 3 | + * |
| 4 | + * Note, for performance reasons: only import this file if |
| 5 | + * `UrlRedirect::Configuration` is needed, otherwise |
| 6 | + * `UrlRedirectCustomizations` should be imported instead. |
4 | 7 | */
|
5 | 8 |
|
6 |
| -import python |
| 9 | +private import python |
7 | 10 | import semmle.python.dataflow.new.DataFlow
|
8 | 11 | import semmle.python.dataflow.new.TaintTracking
|
9 |
| -import semmle.python.Concepts |
10 |
| -import semmle.python.dataflow.new.RemoteFlowSources |
11 |
| -import semmle.python.dataflow.new.BarrierGuards |
12 | 12 |
|
13 | 13 | /**
|
14 |
| - * A taint-tracking configuration for detecting URL redirection vulnerabilities. |
| 14 | + * Provides a taint-tracking configuration for detecting "URL redirection" vulnerabilities. |
15 | 15 | */
|
16 |
| -class UrlRedirectConfiguration extends TaintTracking::Configuration { |
17 |
| - UrlRedirectConfiguration() { this = "UrlRedirectConfiguration" } |
| 16 | +module UrlRedirect { |
| 17 | + import UrlRedirectCustomizations::UrlRedirect |
18 | 18 |
|
19 |
| - override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } |
| 19 | + /** |
| 20 | + * A taint-tracking configuration for detecting "URL redirection" vulnerabilities. |
| 21 | + */ |
| 22 | + class Configuration extends TaintTracking::Configuration { |
| 23 | + Configuration() { this = "UrlRedirect" } |
20 | 24 |
|
21 |
| - override predicate isSink(DataFlow::Node sink) { |
22 |
| - sink = any(HTTP::Server::HttpRedirectResponse e).getRedirectLocation() |
23 |
| - } |
| 25 | + override predicate isSource(DataFlow::Node source) { source instanceof Source } |
24 | 26 |
|
25 |
| - override predicate isSanitizer(DataFlow::Node node) { |
26 |
| - // Url redirection is a problem only if the user controls the prefix of the URL. |
27 |
| - // TODO: This is a copy of the taint-sanitizer from the old points-to query, which doesn't |
28 |
| - // cover formatting. |
29 |
| - exists(BinaryExprNode string_concat | string_concat.getOp() instanceof Add | |
30 |
| - string_concat.getRight() = node.asCfgNode() |
31 |
| - ) |
32 |
| - } |
| 27 | + override predicate isSink(DataFlow::Node sink) { sink instanceof Sink } |
| 28 | + |
| 29 | + override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer } |
33 | 30 |
|
34 |
| - override predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { |
35 |
| - guard instanceof StringConstCompare |
| 31 | + override predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { |
| 32 | + guard instanceof SanitizerGuard |
| 33 | + } |
36 | 34 | }
|
37 | 35 | }
|
| 36 | + |
| 37 | +/** |
| 38 | + * DEPRECATED: Don't extend this class for customization, since this will lead to bad |
| 39 | + * performance, instead use the new `UrlRedirectCustomizations.qll` file, and extend |
| 40 | + * its' classes. |
| 41 | + */ |
| 42 | +deprecated class UrlRedirectConfiguration = UrlRedirect::Configuration; |
0 commit comments