Skip to content

Commit a85cbfb

Browse files
committed
use-of-weak-rsa-key-kotlin
1 parent 5fea8a2 commit a85cbfb

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
id: use-of-weak-rsa-key-kotlin
2+
language: kotlin
3+
severity: warning
4+
message: >-
5+
RSA keys should be at least 2048 bits based on NIST recommendation
6+
note: >-
7+
[CWE-326]: Inadequate Encryption Strength
8+
[OWASP A03:2017]: Sensitive Data Exposure
9+
[OWASP A02:2021]: Cryptographic Failures
10+
[REFERENCES]
11+
- https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html#algorithms
12+
rule:
13+
pattern: |
14+
$KEY.initialize($BITS)
15+
follows: KEY = $G.getInstance("RSA");
16+
constraints:
17+
BITS:
18+
regex: '^(-?(0|[1-9][0-9]?|[1-9][0-9]{2}|1[0-9]{3}|20[0-3][0-9]|204[0-7])(\.[0-9]+)?|0|-[1-9][0-9]*|-[1-9][0-9]{2,}|-1[0-9]{3}|-20[0-3][0-9]|-204[0-7])$'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
id: use-of-weak-rsa-key-kotlin
2+
snapshots:
3+
? |
4+
KeyPairGenerator.getInstance("RSA")
5+
keyGen.initialize(-5.12);
6+
: labels:
7+
- source: keyGen.initialize(-5.12)
8+
style: primary
9+
start: 36
10+
end: 60
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
id: use-of-weak-rsa-key-kotlin
2+
valid:
3+
- |
4+
KeyPairGenerator.getInstance("RSA")
5+
keyGen.initialize(2048);
6+
invalid:
7+
- |
8+
KeyPairGenerator.getInstance("RSA")
9+
keyGen.initialize(-5.12);

0 commit comments

Comments
 (0)