Modify rule S5542[kotlin]: Detect CBC mode when used with padding (APPSEC-30) (#1054)
This commit is contained in:
parent
5f2457dd6a
commit
3c31fb8713
3
rules/S5542/kotlin/highlighting.adoc
Normal file
3
rules/S5542/kotlin/highlighting.adoc
Normal file
@ -0,0 +1,3 @@
|
||||
=== Highlighting
|
||||
|
||||
javax.crypto.Cipher#Cipher.getInstance
|
14
rules/S5542/kotlin/message.adoc
Normal file
14
rules/S5542/kotlin/message.adoc
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
=== Message
|
||||
|
||||
==== ECB
|
||||
|
||||
Use a secure cipher mode.
|
||||
|
||||
==== CBC
|
||||
|
||||
Use another cipher mode or disable padding.
|
||||
|
||||
==== RSA
|
||||
|
||||
Use a secure padding scheme.
|
@ -4,10 +4,11 @@ include::../description.adoc[]
|
||||
|
||||
[source,kotlin]
|
||||
----
|
||||
val c1 = Cipher.getInstance("AES") // Noncompliant: by default ECB mode is chosen
|
||||
val c2 = Cipher.getInstance("AES/ECB/NoPadding") // Noncompliant: ECB doesn't provide serious message confidentiality
|
||||
Cipher.getInstance("AES") // Noncompliant: by default ECB mode is chosen
|
||||
Cipher.getInstance("AES/ECB/NoPadding") // Noncompliant: ECB doesn't provide serious message confidentiality
|
||||
|
||||
val c3 = Cipher.getInstance("RSA/None/NoPadding") // Noncompliant: RSA without OAEP padding scheme is not recommanded
|
||||
Cipher.getInstance("AES/CBC/PKCS5Padding") // Noncompliant: Vulnerable to Padding Oracle attacks
|
||||
Cipher.getInstance("RSA/None/NoPadding") // Noncompliant: RSA without OAEP padding scheme is not recommended
|
||||
----
|
||||
|
||||
== Compliant Solution
|
||||
@ -15,12 +16,12 @@ val c3 = Cipher.getInstance("RSA/None/NoPadding") // Noncompliant: RSA without O
|
||||
[source,kotlin]
|
||||
----
|
||||
// Recommended for block ciphers
|
||||
val c1 = Cipher.getInstance("AES/GCM/NoPadding"); // Compliant
|
||||
Cipher.getInstance("AES/GCM/NoPadding")
|
||||
|
||||
// Recommended for RSA
|
||||
val c3 = Cipher.getInstance("RSA/None/OAEPWITHSHA-256ANDMGF1PADDING") // Compliant
|
||||
Cipher.getInstance("RSA/None/OAEPWITHSHA-256ANDMGF1PADDING")
|
||||
// or the ECB mode can be used for RSA when "None" is not available with the security provider used - in that case, ECB will be treated as "None" for RSA.
|
||||
val c3 = Cipher.getInstance("RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING"); // Compliant
|
||||
Cipher.getInstance("RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING")
|
||||
----
|
||||
|
||||
== See
|
||||
@ -39,7 +40,9 @@ ifdef::env-github,rspecator-view[]
|
||||
== Implementation Specification
|
||||
(visible only on this page)
|
||||
|
||||
include::../message.adoc[]
|
||||
include::message.adoc[]
|
||||
|
||||
include::highlighting.adoc[]
|
||||
|
||||
'''
|
||||
== Comments And Links
|
||||
|
Loading…
x
Reference in New Issue
Block a user