Skip to content

Commit 3dc1b81

Browse files
Changing ProcessNameToHash query to path-problem. Any additional feedback will be welcomed
1 parent 9ef4aef commit 3dc1b81

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

csharp/ql/src/experimental/Security Features/backdoor/PotentialTimeBomb.ql

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,15 @@ private class FlowsFromTimeComparisonCallableToSelectionStatementCondition exten
122122
* which is then used for a DateTime comparison timeComparisonCall and the result flows to a Selection statement which is likely a TimeBomb trigger
123123
*/
124124
predicate isPotentialTimeBomb(
125-
DataFlow::PathNode pathSource, DataFlow::PathNode pathSink,
126-
Call getLastWriteTimeMethodCall, Call timeArithmeticCall, Call timeComparisonCall,
127-
SelectionStmt selStatement
125+
DataFlow::PathNode pathSource, DataFlow::PathNode pathSink, Call getLastWriteTimeMethodCall,
126+
Call timeArithmeticCall, Call timeComparisonCall, SelectionStmt selStatement
128127
) {
129128
exists(
130129
FlowsFromGetLastWriteTimeConfigToTimeSpanArithmeticCallable config1, Node sink,
131130
DateTimeStruct dateTime, FlowsFromTimeSpanArithmeticToTimeComparisonCallable config2,
132131
Node sink2, FlowsFromTimeComparisonCallableToSelectionStatementCondition config3, Node sink3
133132
|
134-
pathSource.getNode() = exprNode(getLastWriteTimeMethodCall) and
133+
pathSource.getNode() = exprNode(getLastWriteTimeMethodCall) and
135134
config1.hasFlow(exprNode(getLastWriteTimeMethodCall), sink) and
136135
timeArithmeticCall = dateTime.getATimeSpanArtithmeticCallable().getACall() and
137136
timeArithmeticCall.getAChild*() = sink.asExpr() and
@@ -144,13 +143,13 @@ predicate isPotentialTimeBomb(
144143
)
145144
}
146145

147-
from DataFlow::PathNode source, DataFlow::PathNode sink,
148-
Call getLastWriteTimeMethodCall, Call timeArithmeticCall, Call timeComparisonCall,
149-
SelectionStmt selStatement
146+
from
147+
DataFlow::PathNode source, DataFlow::PathNode sink, Call getLastWriteTimeMethodCall,
148+
Call timeArithmeticCall, Call timeComparisonCall, SelectionStmt selStatement
150149
where
151-
isPotentialTimeBomb(source, sink, getLastWriteTimeMethodCall, timeArithmeticCall, timeComparisonCall,
152-
selStatement)
153-
select selStatement, source, sink,
150+
isPotentialTimeBomb(source, sink, getLastWriteTimeMethodCall, timeArithmeticCall,
151+
timeComparisonCall, selStatement)
152+
select selStatement, source, sink,
154153
"Possible TimeBomb logic triggered by $@ that takes into account $@ from the $@ as part of the potential trigger.",
155154
timeComparisonCall, timeComparisonCall.toString(), timeArithmeticCall, "an offset",
156155
getLastWriteTimeMethodCall, "last modification time of a file"

csharp/ql/src/experimental/Security Features/backdoor/ProcessNameToHashTaintFlow.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @name ProcessName to hash function flow
33
* @description Flow from a function retrieving process name to a hash function
44
* NOTE: This query is an example of a query that may be useful for detecting potential backdoors, and Solorigate is just one such example that uses this mechanism.
5-
* @kind problem
5+
* @kind path-problem
66
* @tags security
77
* solorigate
88
* @problem.severity warning
@@ -11,7 +11,7 @@
1111
*/
1212

1313
import csharp
14-
import DataFlow
14+
import DataFlow::PathGraph
1515
import experimental.code.csharp.Cryptography.NonCryptographicHashes
1616

1717
class DataFlowFromMethodToHash extends TaintTracking::Configuration {
@@ -49,8 +49,8 @@ predicate isSuspiciousPropertyName(PropertyRead pr) {
4949
pr.getTarget().getQualifiedName() = "System.Diagnostics.Process.ProcessName"
5050
}
5151

52-
from Node src, Node sink, DataFlowFromMethodToHash conf
53-
where conf.hasFlow(src, sink)
54-
select src,
52+
from DataFlow::PathNode src, DataFlow::PathNode sink, DataFlowFromMethodToHash conf
53+
where conf.hasFlow(src.getNode(), sink.getNode())
54+
select src.getNode(), src, sink,
5555
"The hash is calculated on the process name $@, may be related to a backdoor. Please review the code for possible malicious intent.",
56-
sink, "here"
56+
sink.getNode(), "here"

0 commit comments

Comments
 (0)