CVE-2024-47829: pnpm uses the md5 path shortening function causes packet paths to coincide, which causes indirect packet overwriting

Published Apr 23, 2025
·
Updated

pnpm is a package manager. Prior to version 10.0.0, the path shortening function uses the md5 function as a path shortening compression function, and if a collision occurs, it will result in the same storage path for two different libraries. Although the real names are under the package name /nodemodoules/, there are no version numbers for the libraries they refer to. This issue has been patched in version 10.0.0.

Other sources

The path shortening function is used in pnpm: export function depPathToFilename (depPath: string, maxLengthWithoutHash: number): string { let filename = depPathToFilenameUnescaped(depPath).replace(/[\\/:?"<>|]/g, '+') if (filename.includes('(')) { filename = filename .replace(/\)$/, '') .replace(/(\)\()|\(|\)/g, '') } if (filename.length > maxLengthWithoutHash || filename !== filename.toLowerCase() && !filename.startsWith('file+')) { return ${filename.substring(0, maxLengthWithoutHash - 27)}${createBase32Hash(filename)} } return filename } However, it uses the md5 function as a path shortening compression function, and if a collision occurs, it will result in the same storage path for two different libraries. Although the real names are under the package name /nodemodoules/, there are no version numbers for the libraries they refer to. !Schematic picture In the diagram, we assume that two packages are called packageA and packageB, and that the first 90 digits of their package names must be the same, and that the hash value of the package names with versions must be the same. Then C is the package that they both reference, but with a different version number. (npm allows package names up to 214 bytes, so constructing such a collision package name is obvious.)

Then hash(packageA@1.2.3)=hash(packageB@3.4.5). This results in the same path for the installation, and thus under the same directory. Although the package names under nodemodoules are the full paths again, they are shared with C. What is the exact version number of C? In our local tests, it depends on which one is installed later. If packageB is installed later, the C version number will change to 2.0.0. At this time, although package A requires the C@1.0.0 version, package. json will only work during installation, and will not affect the actual operation. We did not receive any installation error issues from pnpm during our local testing, nor did we use force, which is clearly a case that can be triggered.

For a package with a package name + version number longer than 120, another package can be constructed to introduce an indirect reference to a lower version, such as one with some known vulnerability. Alternatively, it is possible to construct two packages with more than 120 package names + version numbers. This is clearly an advantage for those intent on carrying out supply chain attacks.

The solution: The repair cost is also very low, just need to upgrade the md5 function to sha256.

GitHub

Affected Software

2 affected componentsFixes available
npm/pnpm<10.0.0
10.0.0
PNPM Pnpm Node.js<10.0.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/pnpm to a version that resolves this vulnerability.

    Fixed in 10.0.0
  2. Upgrade

    Upgrade npm to a version that resolves this vulnerability.

    Fixed in 10.0.0
  3. Upgrade

    Upgrade pnpm to a version that resolves this vulnerability.

    Fixed in 10.0.0

Event History

Apr 23, 2025
Advisory Published
via GitHub·02:05 PM
CVE Published
via MITRE·03:42 PM
Data Sourced
via MITRE·03:42 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·04:15 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·04:15 PM
Affected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2024-47829?

CVE-2024-47829 has a medium severity rating due to its potential impact on filename handling in pnpm.

2

How do I fix CVE-2024-47829?

To fix CVE-2024-47829, update pnpm to version 10.0.0 or later.

3

What software is affected by CVE-2024-47829?

CVE-2024-47829 affects the pnpm package management tool.

4

What does CVE-2024-47829 exploit?

CVE-2024-47829 exploits issues in the path shortening function that can lead to improper filename handling.

5

Is CVE-2024-47829 a common vulnerability?

While CVE-2024-47829 may not be among the most common vulnerabilities, it still poses a risk to projects using affected versions of pnpm.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203