Skip to content

Latest commit

 

History

History
57 lines (46 loc) · 6.34 KB

threat-modeling.md

File metadata and controls

57 lines (46 loc) · 6.34 KB

Threat Model Analysis for tencent/mmkv

  • Description: An attacker gains physical access to the device or uses a compromised application with elevated privileges to directly read the MMKV data files. They could use debugging tools, file explorers (if permissions allow), or exploit other vulnerabilities to bypass standard OS protections. This bypasses MMKV's basic file-level protections.
  • Impact: Exposure of sensitive data stored in MMKV, potentially including user credentials, session tokens, personal information, or application configuration data. This could lead to identity theft, account compromise, or privacy violations.
  • Affected Component: MMKV storage files (e.g., .mmkv files on Android, files in the Documents directory on iOS). The core MMKV data storage mechanism is affected.
  • Risk Severity: High (if sensitive data is stored without additional encryption).
  • Mitigation Strategies:
    • Application-Level Encryption: Encrypt sensitive data before storing it in MMKV using strong, well-vetted cryptographic libraries (e.g., libsodium, Android Keystore, iOS Keychain).
    • Secure Key Management: Use a robust Key Derivation Function (KDF) like PBKDF2 or Argon2 to derive encryption keys. Store keys securely using platform-specific secure storage (Android Keystore, iOS Keychain). Never hardcode keys.
  • Description: An attacker with physical access or a malicious application modifies the contents of the MMKV data files. They might alter configuration settings, inject malicious data, or corrupt existing data to cause the application to malfunction, behave unexpectedly, or even execute arbitrary code (if the tampered data is used in a vulnerable way, e.g., to influence control flow).
  • Impact: Application instability, data corruption, potential privilege escalation (if the attacker can influence application logic through tampered data), denial of service.
  • Affected Component: MMKV storage files. The core MMKV data storage and retrieval mechanisms are affected.
  • Risk Severity: High (if the tampered data can lead to code execution or privilege escalation).
  • Mitigation Strategies:
    • Data Integrity Checks: Calculate a cryptographic hash (e.g., SHA-256) or a Message Authentication Code (MAC) of the data before storing it in MMKV. Verify the hash/MAC upon retrieval.
    • Authenticated Encryption: Use authenticated encryption modes (e.g., AES-GCM, ChaCha20-Poly1305) to provide both confidentiality and integrity. This combines encryption and integrity checks.
  • Description: If MMKV is used in multi-process mode, a malicious application on the same device could attempt to connect to the shared MMKV instance and read or modify data without authorization, bypassing any intended access controls.
  • Impact: Data leakage, data tampering, potential privilege escalation (if the attacker can influence the behavior of other processes using the shared MMKV instance).
  • Affected Component: MMKV's inter-process communication (IPC) mechanism and the shared MMKV instance. Specifically, the functions related to creating and accessing shared instances (e.g., MMKV.mmkvWithID(mmapID, MMKVMode.MultiProcess) on Android).
  • Risk Severity: Critical (if multi-process mode is used without proper security measures).
  • Mitigation Strategies:
    • Avoid Multi-process Mode if Possible: Single-process mode is significantly more secure.
    • Secure IPC: Use platform-specific secure IPC mechanisms (e.g., Android's ContentProvider with strong permissions, iOS's XPC services with entitlements).
    • Authentication and Authorization: Implement authentication and authorization within the IPC mechanism to ensure that only authorized processes can access the MMKV instance.
    • Encrypted Communication: Use a secure communication channel (e.g., encrypted sockets) for IPC.
  • Description: Similar to unauthorized IPC access, but the attacker focuses on modifying data within the shared MMKV instance rather than just reading it. This leverages MMKV's multi-process functionality for malicious purposes.
  • Impact: Data corruption, application malfunction, potential privilege escalation.
  • Affected Component: MMKV's IPC mechanism and the shared MMKV instance.
  • Risk Severity: Critical (if multi-process mode is used without proper security measures).
  • Mitigation Strategies:
    • Same as Unauthorized IPC Access: All mitigations for unauthorized IPC access also apply to data tampering via IPC.
    • Data Integrity Checks: Implement data integrity checks (hashing/MAC) even for data accessed via IPC.
    • Authenticated Encryption: Use authenticated encryption for data stored in MMKV when using multi-process mode.
  • Description: An attacker exploits a vulnerability within the MMKV library itself (e.g., a buffer overflow, integer overflow, or logic error) to gain control of the application or access sensitive data. This is a direct attack on the MMKV code.
  • Impact: Code execution, data leakage, data tampering, denial of service, potentially complete system compromise.
  • Affected Component: The specific vulnerable function or module within the MMKV library.
  • Risk Severity: Critical (depending on the nature of the vulnerability).
  • Mitigation Strategies:
    • Keep MMKV Updated: Regularly update MMKV to the latest version to patch known vulnerabilities.
    • Monitor Security Advisories: Watch for security advisories and vulnerability reports related to MMKV.
    • Security Audits and Penetration Testing: Conduct security audits and penetration testing of your application, including the MMKV integration.
    • Static Analysis: Use static analysis tools to identify potential vulnerabilities in your code and in the MMKV library (if source code is available).