# GHSA-54xq-cgqr-rpm3: sharp vulnerability in libwebp dependency CVE-2023-4863

> Attackers can execute arbitrary code or cause denial of service by sending malicious WebP images to applications using the sharp library.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 16 Nov 2023

## What is GHSA-54xq-cgqr-rpm3?

GHSA-54xq-cgqr-rpm3 is a memory corruption vulnerability in sharp, published on 16 Nov 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

## Overview

sharp uses libwebp to decode WebP images and versions prior to the latest 0.32.6 are vulnerable to the high severity https://github.com/advisories/GHSA-j7hp-h8jx-5ppr.

## Who does this affect?

Almost anyone processing untrusted input with versions of sharp prior to 0.32.6.

## How to resolve this?

### Using prebuilt binaries provided by sharp?

Most people rely on the prebuilt binaries provided by sharp.

Please upgrade sharp to the latest 0.32.6, which provides libwebp 1.3.2.

### Using a globally-installed libvips?

Please ensure you are using the latest libwebp 1.3.2.

## Possible workaround

Add the following to your code to prevent sharp from decoding WebP images.
```js
sharp.block({ operation: ["VipsForeignLoadWebp"] });
```

## Which versions are affected by GHSA-54xq-cgqr-rpm3?

2 open source packages ship an affected version, including sharp.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `sharp` | npm | All versions | 0.32.6 |
| `sharp` | npm | All versions | 0.32.6 |

## How do I fix GHSA-54xq-cgqr-rpm3?

Upgrade sharp to 0.32.6 or later.

## Is GHSA-54xq-cgqr-rpm3 being exploited?

There is no known exploitation of GHSA-54xq-cgqr-rpm3 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-54xq-cgqr-rpm3 and fix it if it is affected.

What it is: GHSA-54xq-cgqr-rpm3 is a memory corruption vulnerability in sharp, published on 16 Nov 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-54xq-cgqr-rpm3 in the wild and no public exploit code.

Affected packages and fixed versions:
- sharp (npm): affected all versions; fixed in 0.32.6
- sharp (npm): affected all versions; fixed in 0.32.6

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-54xq-cgqr-rpm3/ (Markdown: https://insights.sbomify.com/GHSA-54xq-cgqr-rpm3/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-54xq-cgqr-rpm3

---
From sbomify Insights: https://insights.sbomify.com/GHSA-54xq-cgqr-rpm3/
Summaries are generated and may contain mistakes; the official description above is the record.
