Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps)!: Update dependency crypto-js to v4 [SECURITY] #177

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Oct 26, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
crypto-js ^3.0.0 -> ^4.2.0 age adoption passing confidence

GitHub Vulnerability Alerts

CVE-2023-46233

Impact

Summary

Crypto-js PBKDF2 is 1,000 times weaker than originally specified in 1993, and at least 1,300,000 times weaker than current industry standard. This is because it both (1) defaults to SHA1, a cryptographic hash algorithm considered insecure since at least 2005 and (2) defaults to one single iteration, a 'strength' or 'difficulty' value specified at 1,000 when specified in 1993. PBKDF2 relies on iteration count as a countermeasure to preimage and collision attacks.

Potential Impact:

  1. If used to protect passwords, the impact is high.
  2. If used to generate signatures, the impact is high.

Probability / risk analysis / attack enumeration:

  1. For at most $45,000, an attacker, given control of only the beginning of a crypto-js PBKDF2 input, can create a value which has identical cryptographic signature to any chosen known value.
  2. Due to the length extension attack on SHA1, we can create a value that has identical signature to any unknown value, provided it is prefixed by a known value. It does not matter if PBKDF2 applies 'salt' or 'pepper' or any other secret unknown to the attacker. It will still create an identical signature.

crypto-js has 10,642 public users as displayed on NPM, today October 11th 2023. The number of transient dependents is likely several orders of magnitude higher.

A very rough GitHub search shows 432 files cross GitHub using PBKDF2 in crypto-js in Typescript or JavaScript, but not specifying any number of iterations.

Affected versions

All versions are impacted. This code has been the same since crypto-js was first created.

Further Cryptanalysis

The issue here is especially egregious because the length extension attack makes useless any secret that might be appended to the plaintext before calculating its signature.

Consider a scheme in which a secret is created for a user's username, and that secret is used to protect e.g. their passwords. Let's say that password is 'fake-password', and their username is 'example-username'.

To encrypt the user password via symmetric encryption we might do encrypt(plaintext: 'fake-password', encryption_key: cryptojs.pbkdf2(value: 'example username' + salt_or_pepper)). By this means, we would, in theory, create an encryption_key that can be determined from the public username, but which requires the secret salt_or_pepper to generate. This is a common scheme for protecting passwords, as exemplified in bcrypt & scrypt. Because the encryption key is symmetric, we can use this derived key to also decrypt the ciphertext.

Because of the length extension issue, if the attacker obtains (via attack 1), a collision with 'example username', the attacker does not need to know salt_or_pepper to decrypt their account data, only their public username.

Description

PBKDF2 is a key-derivation is a key-derivation function that is used for two main purposes: (1) to stretch or squash a variable length password's entropy into a fixed size for consumption by another cryptographic operation and (2) to reduce the chance of downstream operations recovering the password input (for example, for password storage).

Unlike the modern webcrypto standard, crypto-js does not throw an error when a number of iterations is not specified, and defaults to one single iteration. In the year 2000, when PBKDF2 was originally specified, the minimum number of iterations suggested was set at 1,000. Today, OWASP recommends 1,300,000:

https://github.com/brix/crypto-js/blob/4dcaa7afd08f48cd285463b8f9499cdb242605fa/src/pbkdf2.js#L22-L26

Patches

No available patch. The package is not maintained.

Workarounds

Consult the OWASP PBKDF2 Cheatsheet. Configure to use SHA256 with at least 250,000 iterations.

Coordinated disclosure

This issue was simultaneously submitted to crypto-js and crypto-es on the 23rd of October 2023.

Caveats

This issue was found in a security review that was not scoped to crypto-js. This report is not an indication that crypto-js has undergone a formal security assessment by the author.


Release Notes

brix/crypto-js (crypto-js)

v4.2.0

Compare Source

v4.1.1

Compare Source

v4.1.0

Compare Source

v4.0.0

Compare Source

v3.3.0

Compare Source

v3.2.1

Compare Source

v3.2.0

Compare Source

v3.1.8

Compare Source

v3.1.7

Compare Source

v3.1.6

Compare Source

v3.1.5

Compare Source

v3.1.4

Compare Source


Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

BEGIN_COMMIT_OVERRIDE
fix(deps): Update dependency crypto-js to v4 [SECURITY] (#177)
END_COMMIT_OVERRIDE

@renovate renovate bot requested review from imrannayer and a team as code owners October 26, 2023 01:57
@dpebot
Copy link
Collaborator

dpebot commented Oct 26, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from f2c3269 to 34a133d Compare November 1, 2023 23:44
@dpebot
Copy link
Collaborator

dpebot commented Nov 1, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 34a133d to 16593f8 Compare November 1, 2023 23:45
@dpebot
Copy link
Collaborator

dpebot commented Nov 1, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 16593f8 to 470e13e Compare November 2, 2023 15:01
@dpebot
Copy link
Collaborator

dpebot commented Nov 2, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 470e13e to 1fff79e Compare November 2, 2023 20:04
@dpebot
Copy link
Collaborator

dpebot commented Nov 2, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 1fff79e to 1b058d5 Compare November 6, 2023 09:19
@dpebot
Copy link
Collaborator

dpebot commented Nov 6, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 1b058d5 to 9b34a3b Compare November 6, 2023 16:34
@dpebot
Copy link
Collaborator

dpebot commented Nov 6, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 9b34a3b to 600001a Compare November 6, 2023 17:03
@dpebot
Copy link
Collaborator

dpebot commented Nov 6, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 600001a to 7e5df31 Compare November 6, 2023 17:05
@dpebot
Copy link
Collaborator

dpebot commented Nov 6, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 7e5df31 to bea1bc5 Compare November 6, 2023 17:34
@dpebot
Copy link
Collaborator

dpebot commented Nov 6, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from bea1bc5 to 082c06d Compare November 6, 2023 17:35
@dpebot
Copy link
Collaborator

dpebot commented Nov 6, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 082c06d to d3a5d73 Compare November 6, 2023 22:38
@dpebot
Copy link
Collaborator

dpebot commented Nov 6, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from d3a5d73 to 4c37898 Compare November 6, 2023 22:40
@dpebot
Copy link
Collaborator

dpebot commented Nov 6, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 4c37898 to 6eaafd9 Compare November 8, 2023 15:26
@dpebot
Copy link
Collaborator

dpebot commented Nov 8, 2023

/gcbrun

@dpebot
Copy link
Collaborator

dpebot commented Dec 14, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from fa3a76b to a7827e8 Compare December 19, 2023 18:53
@dpebot
Copy link
Collaborator

dpebot commented Dec 19, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from a7827e8 to 0e17c05 Compare December 19, 2023 18:54
@dpebot
Copy link
Collaborator

dpebot commented Dec 19, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 0e17c05 to 8a29fa0 Compare December 20, 2023 02:26
@dpebot
Copy link
Collaborator

dpebot commented Dec 20, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 8a29fa0 to cc88188 Compare December 20, 2023 03:49
@dpebot
Copy link
Collaborator

dpebot commented Dec 20, 2023

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from cc88188 to 98a2adc Compare January 3, 2024 20:14
@dpebot
Copy link
Collaborator

dpebot commented Jan 3, 2024

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 98a2adc to f7838a4 Compare January 3, 2024 22:54
@dpebot
Copy link
Collaborator

dpebot commented Jan 3, 2024

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from f7838a4 to 9af10a5 Compare January 4, 2024 17:20
@dpebot
Copy link
Collaborator

dpebot commented Jan 4, 2024

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 9af10a5 to d7a0269 Compare January 4, 2024 18:27
@dpebot
Copy link
Collaborator

dpebot commented Jan 4, 2024

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from d7a0269 to 28f5dbd Compare January 8, 2024 19:58
@dpebot
Copy link
Collaborator

dpebot commented Jan 8, 2024

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 28f5dbd to 7d25695 Compare January 8, 2024 19:58
@dpebot
Copy link
Collaborator

dpebot commented Jan 8, 2024

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from 7d25695 to bc03b0a Compare January 8, 2024 22:28
@dpebot
Copy link
Collaborator

dpebot commented Jan 8, 2024

/gcbrun

@renovate renovate bot force-pushed the renovate/npm-crypto-js-vulnerability branch from bc03b0a to 6942842 Compare January 8, 2024 22:29
@dpebot
Copy link
Collaborator

dpebot commented Jan 8, 2024

/gcbrun

@apeabody apeabody merged commit c4fdd6d into master Jan 8, 2024
8 checks passed
@apeabody apeabody deleted the renovate/npm-crypto-js-vulnerability branch January 8, 2024 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants