|
| 1 | +/** |
| 2 | + * Provides a taint tracking configuration for reasoning about DoS attacks |
| 3 | + * using a user-controlled object with an unbounded .length property. |
| 4 | + * |
| 5 | + * Note, for performance reasons: only import this file if |
| 6 | + * `LoopBoundInjection::Configuration` is needed, otherwise |
| 7 | + * `LoopBoundInjectionCustomizations` should be imported instead. |
| 8 | + */ |
| 9 | + |
| 10 | +import javascript |
| 11 | +import semmle.javascript.security.TaintedObject |
| 12 | + |
| 13 | +module LoopBoundInjection { |
| 14 | + import LoopBoundInjectionCustomizations::LoopBoundInjection |
| 15 | + |
| 16 | + /** |
| 17 | + * A taint tracking configuration for reasoning about looping on tainted objects with unbounded length. |
| 18 | + */ |
| 19 | + class Configuration extends TaintTracking::Configuration { |
| 20 | + Configuration() { this = "LoopBoundInjection" } |
| 21 | + |
| 22 | + override predicate isSource(DataFlow::Node source, DataFlow::FlowLabel label) { |
| 23 | + source instanceof Source and label = TaintedObject::label() |
| 24 | + } |
| 25 | + |
| 26 | + override predicate isSink(DataFlow::Node sink, DataFlow::FlowLabel label) { |
| 27 | + sink instanceof Sink and label = TaintedObject::label() |
| 28 | + } |
| 29 | + |
| 30 | + override predicate isSanitizerGuard(TaintTracking::SanitizerGuardNode guard) { |
| 31 | + guard instanceof TaintedObject::SanitizerGuard or |
| 32 | + guard instanceof IsArraySanitizerGuard or |
| 33 | + guard instanceof InstanceofArraySanitizerGuard or |
| 34 | + guard instanceof LengthCheckSanitizerGuard |
| 35 | + } |
| 36 | + |
| 37 | + override predicate isAdditionalFlowStep( |
| 38 | + DataFlow::Node src, DataFlow::Node trg, DataFlow::FlowLabel inlbl, DataFlow::FlowLabel outlbl |
| 39 | + ) { |
| 40 | + TaintedObject::step(src, trg, inlbl, outlbl) |
| 41 | + } |
| 42 | + } |
| 43 | +} |
0 commit comments