forked from thezdi/PoC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MindShaRE blog on MySQL Cluster Taint Analysis https://www.zerodayinitiative.com/blog
- Loading branch information
ZDI
committed
Feb 10, 2022
1 parent
96ec347
commit ec6ae36
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* @id cpp/example/empty-block | ||
* @kind path-problem | ||
*/ | ||
|
||
import cpp | ||
import DataFlow::PathGraph | ||
import semmle.code.cpp.dataflow.TaintTracking | ||
import semmle.code.cpp.controlflow.Guards | ||
import semmle.code.cpp.valuenumbering.GlobalValueNumbering | ||
|
||
class SystemCfg extends TaintTracking::Configuration { | ||
SystemCfg() { this = "SystemCfg" } | ||
|
||
override predicate isSource(DataFlow::Node node) { | ||
exists (FieldAccess va | | ||
node.asExpr() = va | ||
and | ||
va.getTarget().getName().matches("theData") | ||
) | ||
or | ||
exists(FunctionCall fc | | ||
fc.getTarget().hasName("getSection") and | ||
fc.getArgument(0) = node.asDefiningArgument() | ||
) | ||
|
||
} | ||
|
||
// https://msrc-blog.microsoft.com/2019/03/19/vulnerability-hunting-with-semmle-ql-part-2/ | ||
override predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) { | ||
exists(Expr e, FieldAccess fa | | ||
node1.asExpr() = e and node2.asExpr() = fa | | ||
fa.getQualifier*() = e and not (fa.getParent() instanceof FieldAccess) | ||
) | ||
} | ||
|
||
override predicate isSink(DataFlow::Node node) { | ||
exists (ArrayExpr ae | | ||
node.asExpr() = ae.getArrayOffset() | ||
) | ||
or | ||
exists(FunctionCall call | | ||
( | ||
call.getTarget().getName() = "memcpy" | ||
or | ||
call.getTarget().getName() = "memset" | ||
or | ||
call.getTarget().getName() = "memmove" | ||
) | ||
and | ||
node.asExpr() = call.getArgument(2) | ||
) | ||
} | ||
|
||
override predicate isSanitizer(DataFlow::Node node) { | ||
exists(MacroInvocation mi | | ||
mi.getMacroName().matches("%ptrCheckGuard%") | ||
and mi.getExpr() = node.asExpr() | ||
) | ||
or | ||
exists( IfStmt aif, RelationalOperation rop | | ||
node.asExpr().(VariableAccess).getTarget().getAnAccess() = aif.getControllingExpr().getAChild*() | ||
and aif.getASuccessor+() = node.asExpr() | ||
and not ( node.asExpr() = aif.getControllingExpr().getAChild*() ) | ||
and rop = aif.getControllingExpr().getAChild*() | ||
) | ||
} | ||
|
||
} | ||
|
||
from DataFlow::PathNode sink, DataFlow::PathNode source, SystemCfg cfg | ||
where | ||
cfg.hasFlowPath(source, sink) | ||
select sink.getNode(), source, sink, sink.getNode().getLocation().toString() | ||
|
||
|