-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathWeakBlockMode.ql
More file actions
34 lines (32 loc) · 1.02 KB
/
WeakBlockMode.ql
File metadata and controls
34 lines (32 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* @name Weak block mode
* @description Finds uses of symmetric encryption block modes that are weak, obsolete, or otherwise unaccepted.
* @id cpp/weak-block-mode
* @kind problem
* @problem.severity error
* @precision high
* @tags external/cwe/cwe-327
*/
import cpp
import experimental.cryptography.Concepts
from BlockModeAlgorithm alg, string name, string msg, Expr confSink
where
exists(string tmpMsg |
(
name = alg.getBlockModeName() and
name = unknownAlgorithm() and
tmpMsg = "Use of unrecognized block mode algorithm."
or
name != unknownAlgorithm() and
name = alg.getBlockModeName() and
not name = ["CBC", "CTS", "XTS"] and
tmpMsg = "Use of weak block mode algorithm " + name + "."
) and
if alg.hasConfigurationSink() and alg.configurationSink() != alg
then (
confSink = alg.configurationSink() and msg = tmpMsg + " Algorithm used at sink: $@."
) else (
confSink = alg and msg = tmpMsg
)
)
select alg, msg, confSink, confSink.toString()