|
1 | 1 | /**
|
2 |
| - * Provides a taint-tracking configuration for detecting arbitrary code execution |
3 |
| - * vulnerabilities due to deserializing user-controlled data. |
| 2 | + * Provides a taint-tracking configuration for detecting "code execution from deserialization" vulnerabilities. |
| 3 | + * |
| 4 | + * Note, for performance reasons: only import this file if |
| 5 | + * `UnsafeDeserialization::Configuration` is needed, otherwise |
| 6 | + * `UnsafeDeserializationCustomizations` 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 arbitrary code execution |
15 |
| - * vulnerabilities due to deserializing user-controlled data. |
| 14 | + * Provides a taint-tracking configuration for detecting "code execution from deserialization" vulnerabilities. |
16 | 15 | */
|
17 |
| -class UnsafeDeserializationConfiguration extends TaintTracking::Configuration { |
18 |
| - UnsafeDeserializationConfiguration() { this = "UnsafeDeserializationConfiguration" } |
| 16 | +module UnsafeDeserialization { |
| 17 | + import UnsafeDeserializationCustomizations::UnsafeDeserialization |
19 | 18 |
|
20 |
| - override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } |
| 19 | + /** |
| 20 | + * A taint-tracking configuration for detecting "code execution from deserialization" vulnerabilities. |
| 21 | + */ |
| 22 | + class Configuration extends TaintTracking::Configuration { |
| 23 | + Configuration() { this = "UnsafeDeserialization" } |
21 | 24 |
|
22 |
| - override predicate isSink(DataFlow::Node sink) { |
23 |
| - exists(Decoding d | |
24 |
| - d.mayExecuteInput() and |
25 |
| - sink = d.getAnInput() |
26 |
| - ) |
27 |
| - } |
| 25 | + override predicate isSource(DataFlow::Node source) { source instanceof Source } |
| 26 | + |
| 27 | + override predicate isSink(DataFlow::Node sink) { sink instanceof Sink } |
| 28 | + |
| 29 | + override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer } |
28 | 30 |
|
29 |
| - override predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { |
30 |
| - guard instanceof StringConstCompare |
| 31 | + override predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { |
| 32 | + guard instanceof SanitizerGuard |
| 33 | + } |
31 | 34 | }
|
32 | 35 | }
|
| 36 | + |
| 37 | +/** |
| 38 | + * DEPRECATED: Don't extend this class for customization, since this will lead to bad |
| 39 | + * performance, instead use the new `UnsafeDeserializationCustomizations.qll` file, and extend |
| 40 | + * its' classes. |
| 41 | + */ |
| 42 | +deprecated class UnsafeDeserializationConfiguration = UnsafeDeserialization::Configuration; |
0 commit comments