JS: pick up CryptographicKeys used in asmCrypto encrypt/decrypt calls

This commit is contained in:
Alex Ford
2023-02-03 12:16:25 +00:00
parent 6b2a92a7ca
commit e17b3d975d
2 changed files with 12 additions and 1 deletions

View File

@@ -51,6 +51,7 @@ private module AsmCrypto {
DataFlow::Node input;
CryptographicAlgorithm algorithm; // non-functional
private string algorithmName;
private string methodName;
Apply() {
/*
@@ -66,7 +67,7 @@ private module AsmCrypto {
exists(DataFlow::SourceNode asmCrypto |
asmCrypto = DataFlow::globalVarRef("asmCrypto") and
algorithm.matchesName(algorithmName) and
this = asmCrypto.getAPropertyRead(algorithmName).getAMemberCall(_) and
this = asmCrypto.getAPropertyRead(algorithmName).getAMemberCall(methodName) and
input = this.getArgument(0)
)
}
@@ -79,6 +80,15 @@ private module AsmCrypto {
isBlockEncryptionAlgorithm(this.getAlgorithm()) and
result.matchesString(algorithmName)
}
DataFlow::Node getKey() {
methodName = ["encrypt", "decrypt"] and
result = super.getArgument(1)
}
}
private class Key extends CryptographicKey {
Key() { this = any(Apply apply).getKey() }
}
}

View File

@@ -1,3 +1,4 @@
| tst.js:3:34:3:36 | key |
| tst.js:7:26:7:42 | keypair.secretKey |
| tst.js:21:42:21:51 | 'a secret' |
| tst.js:36:36:36:51 | 'secret key 123' |