2023-05-03 11:06:20 +02:00
== Why is this an issue?
2020-06-30 14:41:58 +02:00
include::../description.adoc[]
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2020-06-30 14:41:58 +02:00
2022-02-04 17:28:24 +01:00
[source,kotlin]
2020-06-30 14:41:58 +02:00
----
2022-11-29 16:29:30 +01:00
Cipher.getInstance("AES") // Noncompliant: by default ECB mode is chosen
Cipher.getInstance("AES/ECB/NoPadding") // Noncompliant: ECB doesn't provide serious message confidentiality
2021-04-26 17:29:13 +02:00
2022-11-29 16:29:30 +01:00
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
2020-06-30 14:41:58 +02:00
----
2023-05-03 11:06:20 +02:00
=== Compliant solution
2020-06-30 14:41:58 +02:00
2022-02-04 17:28:24 +01:00
[source,kotlin]
2020-06-30 14:41:58 +02:00
----
// Recommended for block ciphers
2022-11-29 16:29:30 +01:00
Cipher.getInstance("AES/GCM/NoPadding")
2020-06-30 14:41:58 +02:00
// Recommended for RSA
2022-11-29 16:29:30 +01:00
Cipher.getInstance("RSA/None/OAEPWITHSHA-256ANDMGF1PADDING")
2021-07-19 09:33:36 +02:00
// 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.
2022-11-29 16:29:30 +01:00
Cipher.getInstance("RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING")
2020-06-30 14:41:58 +02:00
----
2023-05-03 11:06:20 +02:00
== Resources
2021-04-26 17:29:13 +02:00
2021-11-01 15:00:32 +01:00
* https://owasp.org/Top10/A02_2021-Cryptographic_Failures/[OWASP Top 10 2021 Category A2] - Cryptographic Failures
2022-07-08 13:58:56 +02:00
* https://owasp.org/www-project-top-ten/2017/A6_2017-Security_Misconfiguration[OWASP Top 10 2017 Category A6] - Security Misconfiguration
2021-06-10 10:04:10 +02:00
* https://mobile-security.gitbook.io/masvs/security-requirements/0x08-v3-cryptography_verification_requirements[Mobile AppSec Verification Standard] - Cryptography Requirements
* https://owasp.org/www-project-mobile-top-10/2016-risks/m5-insufficient-cryptography[OWASP Mobile Top 10 2016 Category M5] - Insufficient Cryptography
2022-04-07 08:53:59 -05:00
* https://cwe.mitre.org/data/definitions/327[MITRE, CWE-327] - Use of a Broken or Risky Cryptographic Algorithm
2021-04-26 17:29:13 +02:00
* https://wiki.sei.cmu.edu/confluence/x/hDdGBQ[CERT, MSC61-J.] - Do not use insecure or weak cryptographic algorithms
* https://www.sans.org/top25-software-errors/#cat3[SANS Top 25] - Porous Defenses
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-09-20 15:38:42 +02:00
'''
== Implementation Specification
(visible only on this page)
2022-11-29 16:29:30 +01:00
include::message.adoc[]
include::highlighting.adoc[]
2021-09-20 15:38:42 +02:00
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]