Skip to content

Commit 96116c2

Browse files
committed
Suggested query changes.
1 parent cd51b49 commit 96116c2

File tree

3 files changed

+58
-82
lines changed

3 files changed

+58
-82
lines changed

cpp/ql/src/experimental/campaigns/nccoe-pqc-migration/QuantumVulnerableDiscovery/WinCng.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import cpp
1515
import DataFlow::PathGraph
1616
import WindowsCng
17-
import WindowsCngPQVAsymmetricKeyUsage
17+
import WindowsCngPQCVAsymmetricKeyUsage
1818

1919
// CNG-specific DataFlow configuration
2020
class BCryptConfiguration extends TaintTracking::Configuration {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import cpp
2+
import WindowsCng
3+
//TODO: Verify NCrypt calls (parameters) & find all other APIs that should be included (i.e. decrypt, etc.)
4+
predicate isExprKeyHandleForBCryptSignHash(Expr e){
5+
exists( FunctionCall call |
6+
e = call.getArgument(0)
7+
and
8+
call.getTarget().hasGlobalName("BCryptSignHash")
9+
)
10+
}
11+
12+
class BCryptSignHashArgumentSink extends BCryptOpenAlgorithmProviderSink {
13+
BCryptSignHashArgumentSink() {
14+
isExprKeyHandleForBCryptSignHash(this.asExpr())
15+
}
16+
}
17+
18+
class BCryptOpenAlgorithmProviderPqcVulnerableAlgorithmsSource extends BCryptOpenAlgorithmProviderSource {
19+
BCryptOpenAlgorithmProviderPqcVulnerableAlgorithmsSource() {
20+
this.asExpr() instanceof StringLiteral and
21+
(
22+
this.asExpr().getValue() in ["DH", "DSA", "ECDSA", "ECDH"]
23+
or this.asExpr().getValue().matches("ECDH%")
24+
or this.asExpr().getValue().matches("RSA%")
25+
)
26+
}
27+
}
28+
29+
predicate stepOpenAlgorithmProvider(DataFlow::Node node1, DataFlow::Node node2)
30+
{
31+
exists( FunctionCall call |
32+
// BCryptOpenAlgorithmProvider 2nd argument specifies the algorithm to be used
33+
node1.asExpr() = call.getArgument(1)
34+
and
35+
call.getTarget().hasGlobalName("BCryptOpenAlgorithmProvider")
36+
and
37+
node2.asDefiningArgument() = call.getArgument(0)
38+
)
39+
}
40+
41+
predicate stepImportGenerateKeyPair(DataFlow::Node node1, DataFlow::Node node2)
42+
{
43+
exists( FunctionCall call |
44+
node1.asExpr() = call.getArgument(0)
45+
and
46+
( call.getTarget().hasGlobalName("BCryptImportKeyPair") or
47+
call.getTarget().hasGlobalName("BCryptGenerateKeyPair"))
48+
and
49+
node2.asDefiningArgument() = call.getArgument(1)
50+
)
51+
}
52+
53+
predicate isWindowsCngAsymmetricKeyAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) {
54+
stepOpenAlgorithmProvider(node1, node2)
55+
or
56+
stepImportGenerateKeyPair(node1, node2)
57+
}

cpp/ql/src/experimental/campaigns/nccoe-pqc-migration/QuantumVulnerableDiscovery/WindowsCngPQVAsymmetricKeyUsage.qll

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)