|
| 1 | +/** |
| 2 | + * Using untrusted input with the Tiny File Dialogs library can lead to command |
| 3 | + * injection vulnerabilities. |
| 4 | + * |
| 5 | + * See also [this LWJGL GitHub issue](https://github.com/LWJGL/lwjgl3/issues/951). |
| 6 | + * |
| 7 | + * @kind path-problem |
| 8 | + */ |
| 9 | + |
| 10 | +// TODO: Not tested yet |
| 11 | + |
| 12 | +import java |
| 13 | +import semmle.code.java.dataflow.DataFlow |
| 14 | +import semmle.code.java.dataflow.FlowSources |
| 15 | + |
| 16 | +// For 3.3.4-SNAPSHOT; https://javadoc.lwjgl.org/org/lwjgl/util/tinyfd/TinyFileDialogs.html |
| 17 | +class TinyFdSink extends DataFlow::Node { |
| 18 | + TinyFdSink() { |
| 19 | + exists(MethodAccess call, Method m | |
| 20 | + m = call.getMethod() and |
| 21 | + m.getDeclaringType().hasQualifiedName("org.lwjgl.util.tinyfd", "TinyFileDialogs") and |
| 22 | + this.asExpr() = call.getAnArgument() and |
| 23 | + // Match text provided as `long` address, `ByteBuffer` and `CharSequence` |
| 24 | + // Note: Flow for `long` as memory address is probably not well supported by taint tracking yet |
| 25 | + // TODO: Maybe make this more specific in case this leads to false positives |
| 26 | + (this.getType().hasName("long") or not this.getType() instanceof PrimitiveType) |
| 27 | + ) |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +module TinyFdFlowConfig implements DataFlow::ConfigSig { |
| 32 | + predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } |
| 33 | + |
| 34 | + predicate isSink(DataFlow::Node sink) { sink instanceof TinyFdSink } |
| 35 | +} |
| 36 | + |
| 37 | +module TinyFdFlow = TaintTracking::Global<TinyFdFlowConfig>; |
| 38 | + |
| 39 | +import TinyFdFlow::PathGraph |
| 40 | + |
| 41 | +from TinyFdFlow::PathNode source, TinyFdFlow::PathNode sink |
| 42 | +where TinyFdFlow::flowPath(source, sink) |
| 43 | +select sink.getNode(), source, sink, "Untrusted input used as argument for Tiny File Dialogs" |
0 commit comments