Skip to content

Commit 68d668e

Browse files
committed
Final bug fixes and new sink.
1 parent 59ca3b2 commit 68d668e

File tree

2 files changed

+27
-29
lines changed

2 files changed

+27
-29
lines changed

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

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,22 @@ predicate vulnProviderLiteral(StringLiteral lit) {
3333
)
3434
}
3535

36-
//TODO: Verify NCrypt calls (parameters) & find all other APIs that should be included (i.e. decrypt, etc.)
3736
// ------------------ Default SINKS ----------------------
37+
/**
38+
* Argument at index 0 of call to NCryptSignHash:
39+
* [in] NCRYPT_KEY_HANDLE hKey
40+
*/
41+
class NCryptSignHashArgumentSink extends BCryptOpenAlgorithmProviderSink {
42+
int index;
43+
string funcName;
44+
45+
NCryptSignHashArgumentSink() {
46+
index = 0 and
47+
funcName = "NCryptSignHash " and
48+
isCallArgument(funcName, this.asExpr(), index)
49+
}
50+
}
51+
3852
/**
3953
* Argument at index 0 of call to BCryptSignHash:
4054
* [in] BCRYPT_KEY_HANDLE hKey,
@@ -85,30 +99,14 @@ class BCryptEncryptArgumentSink extends BCryptOpenAlgorithmProviderSink {
8599
* [in] NCRYPT_KEY_HANDLE hKey,
86100
*/
87101
class NCryptEncryptArgumentSink extends BCryptOpenAlgorithmProviderSink {
88-
int index;
89-
string funcName;
90-
91-
NCryptEncryptArgumentSink() {
92-
index = 0 and
93-
funcName = "NCryptEncrypt" and
94-
isCallArgument(funcName, this.asExpr(), index)
95-
}
96-
}
97-
98-
99-
/**
100-
* Argument at index 1 of call to NCryptEncrypt:
101-
* _Inout_ NCRYPT_KEY_HANDLE hKey,
102-
*/
103-
class SslEncryptPacketArgumentSink extends BCryptOpenAlgorithmProviderSink {
104-
int index;
105-
string funcName;
102+
int index;
103+
string funcName;
106104

107-
SslEncryptPacketArgumentSink() {
108-
index = 1 and
109-
funcName = "SslEncryptPacket" and
110-
isCallArgument(funcName, this.asExpr(), index)
111-
}
105+
NCryptEncryptArgumentSink() {
106+
index = 0 and
107+
funcName = "NCryptEncrypt" and
108+
isCallArgument(funcName, this.asExpr(), index)
109+
}
112110
}
113111

114112
// ----------------- Default SOURCES -----------------------

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ predicate stepOpenAlgorithmProvider(DataFlow::Node node1, DataFlow::Node node2)
2525
predicate stepImportGenerateKeyPair(DataFlow::Node node1, DataFlow::Node node2) {
2626
exists(FunctionCall call |
2727
node1.asExpr() = call.getArgument(0) and
28-
exists(string name |
29-
name in ["BCryptImportKeyPair", "BCryptGenerateKeyPair"] and
30-
call.getTarget().hasGlobalName(name)
31-
) and
32-
node2.asDefiningArgument() = call.getArgument(1)
28+
exists(string name | call.getTarget().hasGlobalName(name) |
29+
name = "BCryptImportKeyPair" and node2.asDefiningArgument() = call.getArgument(3)
30+
or
31+
name = "BCryptGenerateKeyPair" and node2.asDefiningArgument() = call.getArgument(1)
32+
)
3333
)
3434
}
3535

0 commit comments

Comments
 (0)