Skip to content

MASWE-0008: Improper Hashing

MAS Requirement

The app properly hashes sensitive data.

Mappings

MASVS V1: MSTG-CRYPTO-4

MASVS V2: MASVS-CRYPTO-1

CWE: CWE-328: Use of Weak Hash

Android Core Quality: Cryptographic_Algorithms

Overview

This weakness occurs when a broken or unsuitable hash function is used in a security-sensitive context, such as integrity checks, digital signatures, or certificate fingerprints.

Broken algorithms such as MD5 and SHA-1 have practical collision attacks, and NIST has deprecated both for all security purposes; they must not be used in any security-sensitive context. Using an otherwise sound hash function for the wrong job is equally problematic: passwords and passphrases require a dedicated password-based key derivation function rather than a plain hash (see Improper Cryptographic Key Derivation), and non-cryptographic checksums provide no security at all.

Modes of Introduction

  • Broken Hash Algorithms: Using algorithms such as MD5 or SHA-1 in contexts that require collision or second-preimage resistance, e.g. digital signatures, integrity verification, or fingerprinting.
  • Wrong Hash for the Job: Using a plain, fast hash for password storage or key derivation instead of a password-based KDF (see Improper Cryptographic Key Derivation), or using non-cryptographic checksums such as CRC-32 where a cryptographic hash is required.
  • Truncated Digests: Truncating hash output below the security strength required by the use case, reducing collision and preimage resistance.

Impact

  • Compromise of Sensitive Data: Attackers can substitute or modify data without invalidating its hash, resulting in undetected manipulation of sensitive information.
  • Authentication or Authorization Bypass: Attackers can forge artifacts whose authenticity is established via hashes, such as signed payloads or fingerprinted certificates, resulting in impersonation or unauthorized access.

Mitigations

  • Use Approved Hash Functions: Use hash functions approved by current standards, such as SHA-256 or stronger members of the SHA-2 and SHA-3 families, per NIST.SP.800-131Ar2, and follow emerging post-quantum guidance such as NIST IR 8547.
  • Use Password-Based KDFs for Passwords: Never hash passwords or passphrases directly; use a dedicated password-based KDF as described in Improper Cryptographic Key Derivation.
  • Preserve Digest Length: Do not truncate digests below the security strength required by the use case.

Tests

MASTG-TEST-0211: Broken Hashing Algorithms