mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Adding modeling for OpenSSL random number generation.
This commit is contained in:
@@ -7,6 +7,7 @@ module OpenSSLModel {
|
||||
import experimental.Quantum.OpenSSL.EVPHashOperation
|
||||
import experimental.Quantum.OpenSSL.EVPCipherAlgorithmSource
|
||||
import experimental.Quantum.OpenSSL.EVPHashAlgorithmSource
|
||||
import experimental.Quantum.OpenSSL.Random
|
||||
|
||||
|
||||
// // TODO: trace CTX from init variants to the context arg of EVP update calls
|
||||
|
||||
21
cpp/ql/lib/experimental/Quantum/OpenSSL/Random.qll
Normal file
21
cpp/ql/lib/experimental/Quantum/OpenSSL/Random.qll
Normal file
@@ -0,0 +1,21 @@
|
||||
import cpp
|
||||
private import experimental.Quantum.Language
|
||||
private import codeql.cryptography.Model
|
||||
private import LibraryDetector
|
||||
private import semmle.code.cpp.dataflow.new.DataFlow
|
||||
|
||||
class OpenSSLRandomNumberGeneratorInstance extends Crypto::RandomNumberGenerationInstance instanceof Call
|
||||
{
|
||||
OpenSSLRandomNumberGeneratorInstance() {
|
||||
this.(Call).getTarget().getName() in ["RAND_bytes", "RAND_pseudo_bytes"] and
|
||||
isPossibleOpenSSLFunction(this.(Call).getTarget())
|
||||
}
|
||||
|
||||
override Crypto::DataFlowNode getOutputNode() {
|
||||
result.asDefiningArgument() = this.(Call).getArgument(0)
|
||||
}
|
||||
|
||||
override predicate flowsTo(Crypto::FlowAwareElement other) {
|
||||
ArtifactUniversalFlow::flow(this.getOutputNode(), other.getInputNode())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user