sharp buffer overflow in libwebp WebP image decoding

Severity: low · CVSS 3.1 · Published 2023-11-16

sharp is a widely used Node.js library for fast image processing and resizing. A critical vulnerability in its bundled libwebp dependency can allow attackers to execute arbitrary code or crash the application when processing maliciously crafted WebP images. This affects any application using sharp to process untrusted image files, potentially leading to data theft or system compromise.

Technologies: Sharp.

Quick answers

Is This vulnerability exploited in the wild?
No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.
How severe is This vulnerability?
Low severity, with a CVSS score of 3.1, published 16 November 2023.
Which products and versions are affected?
Sharp SEMVER:introduced=0,fixed=0.32.6.
Is there a fix for This vulnerability?
Yes. Sharp: upgrade to 0.32.6 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked with local access, in a software library.
Am I affected?
Check whether you run Sharp 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

  • Sharp: upgrade to 0.32.6 or later

Technical details

The vulnerability is a buffer overflow in libwebp (CVE-2023-4863), which sharp uses for decoding WebP images. The root cause lies in improper bounds checking when processing malformed WebP image data. The attack vector is local and requires user interaction (opening/processing a crafted WebP file), but no special privileges are needed. An attacker can craft a malicious WebP image that, when decoded by a vulnerable version of sharp, triggers a heap or stack buffer overflow leading to arbitrary code execution, information disclosure, or denial of service. The vulnerability is fixed in sharp 0.32.6, which bundles libwebp 1.3.2. Users with globally-installed libvips should upgrade libwebp to version 1.3.2 or later. A workaround is available to block WebP decoding in sharp via the block() API.

Affected products

  • lovell sharp < 0.32.6
  • libwebp < 1.3.2

Timeline

  • 2023-11-16: disclosed: GHSA-54xq-cgqr-rpm3 advisory published
  • 2023-11-16: patched: sharp version 0.32.6 released with libwebp 1.3.2

References

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