|
| 1 | +/** |
| 2 | + * Provides a taint tracking configuration for reasoning about decompression bomb vulnerabilities. |
| 3 | + */ |
| 4 | + |
| 5 | +import go |
| 6 | + |
| 7 | +class MimeMultipartFileHeader extends UntrustedFlowSource::Range { |
| 8 | + MimeMultipartFileHeader() { |
| 9 | + exists(DataFlow::FieldReadNode frn | this = frn | |
| 10 | + frn.getField().hasQualifiedName("mime/multipart", "FileHeader", ["Filename", "Header"]) |
| 11 | + ) |
| 12 | + or |
| 13 | + exists(DataFlow::Method m | |
| 14 | + m.hasQualifiedName("mime/multipart", "FileHeader", "Open") and |
| 15 | + this = m.getACall().getResult(0) |
| 16 | + ) |
| 17 | + or |
| 18 | + exists(DataFlow::FieldReadNode frn | |
| 19 | + frn.getField().hasQualifiedName("mime/multipart", "Form", "Value") |
| 20 | + ) |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +/** Provides a taint tracking configuration for reasoning about decompression bomb vulnerabilities. */ |
| 25 | +module DecompressionBomb { |
| 26 | + import experimental.frameworks.DecompressionBombsCustomizations |
| 27 | + |
| 28 | + module Config implements DataFlow::StateConfigSig { |
| 29 | + class FlowState = DecompressionBombs::FlowState; |
| 30 | + |
| 31 | + predicate isSource(DataFlow::Node source, FlowState state) { |
| 32 | + source instanceof UntrustedFlowSource and |
| 33 | + state = "" |
| 34 | + } |
| 35 | + |
| 36 | + predicate isSink(DataFlow::Node sink, FlowState state) { |
| 37 | + sink instanceof DecompressionBombs::Sink and |
| 38 | + state = |
| 39 | + [ |
| 40 | + "ZstdNewReader", "XzNewReader", "GzipNewReader", "PgzipNewReader", "S2NewReader", |
| 41 | + "SnappyNewReader", "ZlibNewReader", "FlateNewReader", "Bzip2NewReader", "ZipOpenReader", |
| 42 | + "ZipKlauspost" |
| 43 | + ] |
| 44 | + } |
| 45 | + |
| 46 | + predicate isAdditionalFlowStep(DataFlow::Node fromNode, DataFlow::Node toNode) { |
| 47 | + exists(DecompressionBombs::AdditionalTaintStep addStep | |
| 48 | + addStep.isAdditionalFlowStep(fromNode, toNode) |
| 49 | + ) |
| 50 | + } |
| 51 | + |
| 52 | + predicate isAdditionalFlowStep( |
| 53 | + DataFlow::Node fromNode, FlowState fromState, DataFlow::Node toNode, FlowState toState |
| 54 | + ) { |
| 55 | + exists(DecompressionBombs::AdditionalTaintStep addStep | |
| 56 | + addStep.isAdditionalFlowStep(fromNode, fromState, toNode, toState) |
| 57 | + ) |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + /** Tracks taint flow for reasoning about decompression bomb vulnerabilities. */ |
| 62 | + module Flow = TaintTracking::GlobalWithState<Config>; |
| 63 | +} |
0 commit comments