Files
codeql/java/ql/lib/semmle/code/java/security/ExternallyControlledFormatStringQuery.qll
2024-04-26 14:12:41 +02:00

33 lines
1.1 KiB
Plaintext

/** Provides a taint-tracking configuration to reason about externally controlled format string vulnerabilities. */
import java
private import semmle.code.java.dataflow.FlowSinks
private import semmle.code.java.dataflow.FlowSources
private import semmle.code.java.StringFormat
/**
* A class of string format sink nodes.
*/
class StringFormatSink extends ApiSinkNode {
StringFormatSink() { this.asExpr() = any(StringFormat formatCall).getFormatArgument() }
}
/**
* A taint-tracking configuration for externally controlled format string vulnerabilities.
*/
module ExternallyControlledFormatStringConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source instanceof ThreatModelFlowSource }
predicate isSink(DataFlow::Node sink) { sink instanceof StringFormatSink }
predicate isBarrier(DataFlow::Node node) {
node.getType() instanceof NumericType or node.getType() instanceof BooleanType
}
}
/**
* Taint-tracking flow for externally controlled format string vulnerabilities.
*/
module ExternallyControlledFormatStringFlow =
TaintTracking::Global<ExternallyControlledFormatStringConfig>;