Skip to content

Insufficient iteration count and constant salt for PBKDF2

Moderate
meld-cp published GHSA-xqjw-wwh3-v87v Apr 30, 2023

Package

obsidian-encrypt

Affected versions

> 1.4.0

Patched versions

2.2.0

Description

Summary

Iteration count: The iteration count for PBKDF2 is currently set at 1000:

const iterations = 1000;

This is extremely low (OWASP recommends a minimum of 600000) and allows attackers to brute-force a password used to encrypt a note.

Constant salt: The salt is set to a constant:

const salt = utf8Encoder.encode(navigator.userAgent);

The purpose of the salt is to avoid dictionary attacks, but given it is constant, an attacker can build a dictionary of PBKDF2 hashes, for pretty cheap given the above iteration count, and thereby speed up the brute-force attacks.

Suggested workarounds

  • Preferably switch to a modern password-based key derivation function like Argon2id, as PBKDF2 is pretty outdated at this point.
  • Update the cost parameters to match the recommendations of OWASP
  • Make the salt random for each string/file that is encrypted. The salt can be appended to the beginning of the string or file, before going through key-derivation again.

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N

CVE ID

No known CVE

Weaknesses

Credits