|
1 | 1 | /**
|
2 |
| - * Provides a taint-tracking configuration for detecting reflected server-side |
3 |
| - * cross-site scripting vulnerabilities. |
| 2 | + * Provides a taint-tracking configuration for detecting "reflected server-side cross-site scripting" vulnerabilities. |
| 3 | + * |
| 4 | + * Note, for performance reasons: only import this file if |
| 5 | + * `ReflectedXSS::Configuration` is needed, otherwise |
| 6 | + * `ReflectedXSSCustomizations` 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 reflected server-side cross-site |
15 |
| - * scripting vulnerabilities. |
| 14 | + * Provides a taint-tracking configuration for detecting "reflected server-side cross-site scripting" vulnerabilities. |
16 | 15 | */
|
17 |
| -class ReflectedXssConfiguration extends TaintTracking::Configuration { |
18 |
| - ReflectedXssConfiguration() { this = "ReflectedXssConfiguration" } |
| 16 | +module ReflectedXSS { |
| 17 | + import ReflectedXSSCustomizations::ReflectedXSS |
19 | 18 |
|
20 |
| - override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } |
| 19 | + /** |
| 20 | + * A taint-tracking configuration for detecting "reflected server-side cross-site scripting" vulnerabilities. |
| 21 | + */ |
| 22 | + class Configuration extends TaintTracking::Configuration { |
| 23 | + Configuration() { this = "ReflectedXSS" } |
21 | 24 |
|
22 |
| - override predicate isSink(DataFlow::Node sink) { |
23 |
| - exists(HTTP::Server::HttpResponse response | |
24 |
| - response.getMimetype().toLowerCase() = "text/html" and |
25 |
| - sink = response.getBody() |
26 |
| - ) |
27 |
| - } |
| 25 | + override predicate isSource(DataFlow::Node source) { source instanceof Source } |
28 | 26 |
|
29 |
| - override predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { |
30 |
| - guard instanceof StringConstCompare |
31 |
| - } |
| 27 | + override predicate isSink(DataFlow::Node sink) { sink instanceof Sink } |
32 | 28 |
|
33 |
| - // TODO: For now, since there is not an `isSanitizingStep` member-predicate part of a |
34 |
| - // `TaintTracking::Configuration`, we use treat the output is a taint-sanitizer. This |
35 |
| - // is slightly imprecise, which you can see in the `m_unsafe + SAFE` test-case in |
36 |
| - // python/ql/test/library-tests/frameworks/markupsafe/taint_test.py |
37 |
| - // |
38 |
| - // However, it is better than `getAnInput()`. Due to use-use flow, that would remove |
39 |
| - // the taint-flow to `SINK()` in `some_escape(tainted); SINK(tainted)`. |
40 |
| - override predicate isSanitizer(DataFlow::Node node) { node = any(HtmlEscaping esc).getOutput() } |
| 29 | + override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer } |
| 30 | + |
| 31 | + override predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { |
| 32 | + guard instanceof SanitizerGuard |
| 33 | + } |
| 34 | + } |
41 | 35 | }
|
| 36 | + |
| 37 | +/** |
| 38 | + * DEPRECATED: Don't extend this class for customization, since this will lead to bad |
| 39 | + * performance, instead use the new `ReflectedXSSCustomizations.qll` file, and extend |
| 40 | + * its' classes. |
| 41 | + */ |
| 42 | +deprecated class ReflectedXssConfiguration = ReflectedXSS::Configuration; |
0 commit comments