Skip to content

Commit 2438245

Browse files
committed
More comments, and added sink BCryptGenerateKeyPair
1 parent f5ce07d commit 2438245

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ import cpp
22
import DataFlow::PathGraph
33
import semmle.code.cpp.dataflow.TaintTracking
44

5+
/**
6+
* Base abstract class to be extended to allow indirect extensions of vulnerable sinks.
7+
*/
58
abstract class BCryptOpenAlgorithmProviderSink extends DataFlow::Node { }
69

10+
/**
11+
* Base abstract class to be extended to allow indirect extensions of vulnerable sources.
12+
*/
713
abstract class BCryptOpenAlgorithmProviderSource extends DataFlow::Node { }
814

915
// ------------------ Helper Predicates ----------------------
@@ -30,7 +36,8 @@ predicate vulnProviderLiteral(StringLiteral lit) {
3036
//TODO: Verify NCrypt calls (parameters) & find all other APIs that should be included (i.e. decrypt, etc.)
3137
// ------------------ Default SINKS ----------------------
3238
/**
33-
* Argument at index 0 of call to BCryptSignHash
39+
* Argument at index 0 of call to BCryptSignHash:
40+
* [in] BCRYPT_KEY_HANDLE hKey,
3441
*/
3542
class BCryptSignHashArgumentSink extends BCryptOpenAlgorithmProviderSink {
3643
int index;
@@ -44,7 +51,23 @@ class BCryptSignHashArgumentSink extends BCryptOpenAlgorithmProviderSink {
4451
}
4552

4653
/**
47-
* Argument at index 0 of call to BCryptEncrypt
54+
* Argument at index 0 of call to BCryptGenerateKeyPair:
55+
* [in, out] BCRYPT_ALG_HANDLE hAlgorithm,
56+
*/
57+
class BCryptGenerateKeyPair extends BCryptOpenAlgorithmProviderSink {
58+
int index;
59+
string funcName;
60+
61+
BCryptGenerateKeyPair() {
62+
index = 0 and
63+
funcName = "BCryptGenerateKeyPair" and
64+
isCallArgument(funcName, this.asExpr(), index)
65+
}
66+
}
67+
68+
/**
69+
* Argument at index 0 of call to BCryptEncrypt:
70+
* [in, out] BCRYPT_KEY_HANDLE hKey,
4871
*/
4972
class BCryptEncryptArgumentSink extends BCryptOpenAlgorithmProviderSink {
5073
int index;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,16 @@ predicate isWindowsCngAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node n
4848
class BCryptConfiguration extends DataFlow::Configuration {
4949
BCryptConfiguration() { this = "BCryptConfiguration" }
5050

51+
/**
52+
* Uses indirect extensions of BCryptOpenAlgorithmProviderSource
53+
*/
5154
override predicate isSource(DataFlow::Node source) {
5255
source instanceof BCryptOpenAlgorithmProviderSource
5356
}
5457

58+
/**
59+
* Uses indirect extensions of BCryptOpenAlgorithmProviderSink
60+
*/
5561
override predicate isSink(DataFlow::Node sink) { sink instanceof BCryptOpenAlgorithmProviderSink }
5662

5763
override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {

0 commit comments

Comments
 (0)