Crypto-graphy

Einleitung

Kryptographie

Kryptographie ist essentiell für mobile Apps, da mobile Geräte:

  • hochgradig portabel sind
  • leicht verloren gehen oder gestohlen werden können
  • Bei physischem Zugriff kann ein Angreifer auf sensible Daten zugreifen:
    • Passwörter
    • Finanzinformationen
    • Personenbezogene Daten
  • Kryptographie schützt durch Verschlüsselung vor unbefugtem Zugriff

Zweck der Sicherheitskontrollen

  • Sicherstellung der Kryptographie nach Industriestandards (z.B. NIST.SP.800-175B und NIST.SP.800-57)
  • Fokus auf Schlüsselverwaltung über den gesamten Lebenszyklus:
    • Schlüsselerzeugung
    • Speicherung
    • Schutz
  • Schlechte Schlüsselverwaltung kann selbst stärkste Kryptographie kompromittieren

Verification Controls

MASVS-CRYPTO-1

The app employs current strong cryptography and uses it according to industry best practices.

MASVS-CRYPTO-2

The app performs key management according to industry best practices.

Weakness Enumeration

MASVS-CRYPTO-1

L1, P

L1, P (cont.)

L2

MASVS-CRYPTO-2

L1, P

  • MASWE-0009: Improper Cryptographic Key Generation
  • MASWE-0010: Improper Cryptographic Key Derivation
  • MASWE-0014: Cryptographic Keys Not Properly Protected at Rest

L2

  • MASWE-0011: Cryptographic Key Rotation Not Implemented
  • MASWE-0012: Insecure or Wrong Usage of Cryptographic Key
  • MASWE-0015: Deprecated Android KeyStore Implementations
  • MASWE-0016: Unsafe Handling of Imported Cryptographic Keys
  • MASWE-0017: Cryptographic Keys Not Properly Protected on Export
  • MASWE-0018: Cryptographic Keys Access Not Restricted

Testing Guide

MASVS-CRYPTO-1


MASVS-CRYPTO-2


Beispiel MASTG-TEST-0232

Statischer Test

Test MASTG-TEST-0232 prüft, ob Weakness MASWE-0020 zu Control MASVS-CRYPTO-1 vorhanden ist.

Weakness und Control

MASWE-0020

Improper Encryption

MASVS-CRYPTO-1

The app employs current strong cryptography and uses it according to industry best practices.

MASTG-TEST-0232

  • semgrep oder Frida können genutzt werden, um nicht empfohlene Modi zu finden
  • Bei AES geht es hier vor allem um ECB
  • Allerdings ist auch CBC nicht uneingeschränkt empfohlen
  • Besser: GCM

Galois/Counter Mode (GCM)

  • IV wird wie bei Counter inkrementiert
  • Fügt Authentifizierung hinzu
    • Basiert auf Multiplikationen im Galoiskörper

Wiederholung - Flutter

Beispiel mit Encrypter Plus

https://github.com/RobinNunkesser/dart-flutter-aes/tree/main/aes_gcm