Skip to content

MASTG-TEST-0210: Weak Encryption Algorithms

Content in BETA

This content is in beta and still under active development, so it is subject to change any time (e.g. structure, IDs, content, URLs, etc.).

Send Feedback

Overview

To test for the use of weak encryption algorithms in iOS apps, we need to focus on methods from cryptographic frameworks and libraries that are used to perform encryption and decryption operations.

  • CommonCrypto: The CCCrypt function is used for symmetric algorithms and specifies the algorithm in its second parameter alg. This includes:

    • kCCAlgorithmAES128
    • kCCAlgorithmDES
    • kCCAlgorithm3DES
    • kCCAlgorithmCAST
    • kCCAlgorithmRC4
    • kCCAlgorithmRC2
  • CryptoKit: This library does not support weak encryption algorithms. It supports the following symmetric algorithms:

    • AES.GCM
    • ChaChaPoly

Note: the Security framework only supports asymmetric algorithms and is therefore out of scope for this test (see note about symmetric keys).

Steps

  1. Run a static analysis tool such as radare2 for iOS on the app binary, or use a dynamic analysis tool like Frida for iOS, and look for uses of the cryptographic functions that perform encryption and decryption operations.

Observation

The output should contain the disassembled code of the functions using the relevant cryptographic functions.

Evaluation

The test case fails if you can find the use of weak encryption algorithms within the source code. For example:

  • DES
  • 3DES
  • RC2
  • RC4

Stay up-to-date: This is a non-exhaustive list of weak algorithms. Make sure to check the latest standards and recommendations from organizations such as the National Institute of Standards and Technology (NIST), the German Federal Office for Information Security (BSI) or any other relevant authority in your region.

Some algorithms may not be considered weak as a whole, but may have weak configurations that should be avoided. Such as using a key with insufficient strength or not being considered quantum-safe. For example, an AES 128-bit key size is considered weak considering quantum computing attacks.

Context Considerations:

To reduce false positives, make sure you understand the context in which the algorithm is being used before reporting the associated code as insecure. Ensure that it is being used in a security-relevant context to protect sensitive data.

Demos

MASTG-DEMO-0018: Uses of Insecure Encryption Algorithms in CommonCrypto with r2