|
1 | 1 | /** |
2 | | - * Provides a taint-tracking configuration for detecting stack trace exposure |
3 | | - * vulnerabilities. |
| 2 | + * Provides a taint-tracking configuration for detecting "stack trace exposure" vulnerabilities. |
| 3 | + * |
| 4 | + * Note, for performance reasons: only import this file if |
| 5 | + * `StackTraceExposure::Configuration` is needed, otherwise |
| 6 | + * `StackTraceExposureCustomizations` 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.internal.Attributes |
11 | | -private import ExceptionInfo |
12 | 12 |
|
13 | 13 | /** |
14 | | - * A taint-tracking configuration for detecting stack trace exposure. |
| 14 | + * Provides a taint-tracking configuration for detecting "stack trace exposure" vulnerabilities. |
15 | 15 | */ |
16 | | -class StackTraceExposureConfiguration extends TaintTracking::Configuration { |
17 | | - StackTraceExposureConfiguration() { this = "StackTraceExposureConfiguration" } |
| 16 | +module StackTraceExposure { |
| 17 | + import StackTraceExposureCustomizations::StackTraceExposure |
18 | 18 |
|
19 | | - override predicate isSource(DataFlow::Node source) { source instanceof ExceptionInfo } |
| 19 | + /** |
| 20 | + * A taint-tracking configuration for detecting "stack trace exposure" vulnerabilities. |
| 21 | + */ |
| 22 | + class Configuration extends TaintTracking::Configuration { |
| 23 | + Configuration() { this = "StackTraceExposure" } |
20 | 24 |
|
21 | | - override predicate isSink(DataFlow::Node sink) { |
22 | | - sink = any(HTTP::Server::HttpResponse response).getBody() |
23 | | - } |
| 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 } |
| 30 | + |
| 31 | + override predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { |
| 32 | + guard instanceof SanitizerGuard |
| 33 | + } |
24 | 34 |
|
25 | | - // A stack trace is accessible as the `__traceback__` attribute of a caught exception. |
26 | | - // seehttps://docs.python.org/3/reference/datamodel.html#traceback-objects |
27 | | - override predicate isAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) { |
28 | | - exists(AttrRead attr | attr.getAttributeName() = "__traceback__" | |
29 | | - nodeFrom = attr.getObject() and |
30 | | - nodeTo = attr |
31 | | - ) |
| 35 | + // A stack trace is accessible as the `__traceback__` attribute of a caught exception. |
| 36 | + // seehttps://docs.python.org/3/reference/datamodel.html#traceback-objects |
| 37 | + override predicate isAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) { |
| 38 | + exists(DataFlow::AttrRead attr | attr.getAttributeName() = "__traceback__" | |
| 39 | + nodeFrom = attr.getObject() and |
| 40 | + nodeTo = attr |
| 41 | + ) |
| 42 | + } |
32 | 43 | } |
33 | 44 | } |
| 45 | + |
| 46 | +/** |
| 47 | + * DEPRECATED: Don't extend this class for customization, since this will lead to bad |
| 48 | + * performance, instead use the new `StackTraceExposureCustomizations.qll` file, and extend |
| 49 | + * its' classes. |
| 50 | + */ |
| 51 | +deprecated class StackTraceExposureConfiguration = StackTraceExposure::Configuration; |
0 commit comments