Skip to content

Commit d72b978

Browse files
committed
Rust: Add sensitive data sources.
1 parent 8f4a520 commit d72b978

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

rust/ql/lib/codeql/rust/security/SensitiveData.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import rust
9-
private import internal.SensitiveDataHeuristics
9+
import internal.SensitiveDataHeuristics
1010
private import codeql.rust.dataflow.DataFlow
1111

1212
/**

rust/ql/lib/codeql/rust/security/WeakSensitiveDataHashingExtensions.qll

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import rust
1212
private import codeql.rust.Concepts
13+
private import codeql.rust.security.SensitiveData
1314
private import codeql.rust.dataflow.DataFlow
1415

1516
/**
@@ -23,7 +24,7 @@ module NormalHashFunction {
2324
/**
2425
* A data flow source for "use of a broken or weak cryptographic hashing algorithm on sensitive
2526
* data" vulnerabilities that does not require computationally expensive hashing. That is, a
26-
* piece of sensitive data.
27+
* piece of sensitive data that is not a password.
2728
*/
2829
abstract class Source extends DataFlow::Node {
2930
Source() { not this instanceof ComputationallyExpensiveHashFunction::Source }
@@ -52,7 +53,19 @@ module NormalHashFunction {
5253
*/
5354
abstract class Barrier extends DataFlow::Node { }
5455

55-
// TODO: SensitiveDataSourceAsSource
56+
/**
57+
* A flow source modelled by the `SensitiveData` library.
58+
*/
59+
class SensitiveDataAsSource extends Source instanceof SensitiveData {
60+
SensitiveDataAsSource() {
61+
not this.(SensitiveData).getClassification() = SensitiveDataClassification::password() and // (covered in ComputationallyExpensiveHashFunction)
62+
not this.(SensitiveData).getClassification() = SensitiveDataClassification::id() // (not accurate enough)
63+
}
64+
65+
override SensitiveDataClassification getClassification() {
66+
result = this.(SensitiveData).getClassification()
67+
}
68+
}
5669

5770
/**
5871
* A flow sink modelled by the `Cryptography` module.
@@ -117,7 +130,18 @@ module ComputationallyExpensiveHashFunction {
117130
*/
118131
abstract class Barrier extends DataFlow::Node { }
119132

120-
// TODO: PasswordSourceAsSource
133+
/**
134+
* A flow source modelled by the `SensitiveData` library.
135+
*/
136+
class PasswordAsSource extends Source instanceof SensitiveData {
137+
PasswordAsSource() {
138+
this.(SensitiveData).getClassification() = SensitiveDataClassification::password()
139+
}
140+
141+
override SensitiveDataClassification getClassification() {
142+
result = this.(SensitiveData).getClassification()
143+
}
144+
}
121145

122146
/**
123147
* A flow sink modelled by the `Cryptography` module.

0 commit comments

Comments
 (0)