CVE-2024-39918: @jmondi/url-to-png path traversal in image storage

CVE-2024-39918 · Severity: low · CVSS 3.1 · Published 2024-07-15

@jmondi/url-to-png is a Node.js library that converts URLs to PNG images and stores them on disk. A path traversal vulnerability allows attackers to write PNG files to arbitrary locations on the server's filesystem by injecting directory traversal sequences (such as `../`) into query parameters, potentially overwriting system files or placing malicious content outside the intended storage directory.

Technologies: @jmondi/url-to-png (npm). Vendors: npm.

Quick answers

Is CVE-2024-39918 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2024-39918 being exploited in the wild.
How severe is CVE-2024-39918?
Low severity, with a CVSS score of 3.1, published 15 July 2024.
Which products and versions are affected?
@jmondi/url-to-png (npm) SEMVER:introduced=0,fixed=2.1.2.
Is there a fix for CVE-2024-39918?
Yes. @jmondi/url-to-png (npm): upgrade to 2.1.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2024-39918 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2024-39918?
Check whether you run @jmondi/url-to-png (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • @jmondi/url-to-png (npm): upgrade to 2.1.2 or later
    npm install @jmondi/url-to-png@2.1.2

Technical details

The vulnerability exists in the image ID construction logic (extract_query_params.ts), where user-supplied query parameters are concatenated into a filesystem path without proper sanitization. Specifically, the `configToString()` function converts request parameters directly into the imageId string, which is later joined with the storage path using `path.join()`. An attacker can inject path traversal sequences (e.g., `../../../../tmp/hack`) via any non-numeric parameter to write files outside the intended storage directory. The vulnerability requires network access and no authentication; exploitation results in arbitrary file write capability on the filesystem. A patch was released in version 2.1.2 that applies the `slugify()` function to sanitize all parameters before path construction.

Affected products

  • Jason Raimondi @jmondi/url-to-png <2.1.2

Identifiers

  • CVE-2024-39918
  • GHSA-vvmv-wrvp-9gjr

Timeline

  • 2024-07-15: disclosed
  • 2024-07-15: patched: Fixed in version 2.1.2

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.