GHSA-rgj7-g3m4-5g8c: sharp Vulnerabilities Vulnerability

HIGH
CWE-122
Published
Advisory Summary

GHSA-rgj7-g3m4-5g8c is a HIGH vulnerabilities vulnerability (CWE-122: Heap-based Buffer Overflow) affecting sharp libraries in the npm ecosystem. The issue involves vulnerabilities in libheif: ghsa-g89c-p67h-r497 and ghsa-2jg2-4ch7-h545. Remediation is available by upgrading affected packages to version 0.35.4.

GHSA-rgj7-g3m4-5g8c at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-rgj7-g3m4-5g8c
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-122: Heap-based Buffer Overflow
Affected Product sharp
Package Ecosystem npm
Published Date
Last Updated

How to Fix GHSA-rgj7-g3m4-5g8c

To remediate this vulnerability, upgrade all affected sharp dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

sharp fixed: 0.35.4
npm install sharp@0.35.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls sharp

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-rgj7-g3m4-5g8c, inspect your project dependencies using npm:

npm ls sharp

Analyze the terminal output to locate any version of sharp in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.35.4), your application is affected.

Note: The npm ls sharp command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-122: Heap-based Buffer Overflow, where a heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). In sharp, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact A number of vulnerabilities, two rated as "Critical" severity using CVSSv3, have been discovered and fixed in the upstream libheif dependency. These can lead to possible remote code execution (RCE) on glibc-based Linux when run under certain conditions. The attack vector for these claims to be "network" however sharp does not provide any networking features so this vulnerability is down-rated to a "High" severity using CVSSv4 but please note its Subsequent System Impact. Those processing untrusted input with versions of sharp prior to 0.35.4 are affected. ### Patches #### Using prebuilt binaries provided by sharp? Most people rely on the prebuilt binaries provided by sharp. Please upgrade sharp to the latest version, currently 0.35.4, which provides libheif 1.23.2. #### Using a globally-installed libheif? Please ensure you are using the latest libheif 1.23.2. ### Workarounds Add the following to your code to prevent sharp from decoding AVIF images. ```js sharp.block({ operation: ["VipsForeignLoadHeif"] }); ``` Ensure you are using a `node` executable binary compiled as a Position Independent Executable (PIE). Most Linux package managers already do this for protection against RCE however be warned that the "official" Node.js binaries do not. ### References - [CVE-2026-84383](https://github.com/strukturag/libheif/security/advisories/GHSA-g89c-p67h-r497) - https://github.com/strukturag/libheif/security/advisories/GHSA-2jg2-4ch7-h545

GHSA-rgj7-g3m4-5g8c Affected sharp Versions

1 component(s)
Fixed Versions:
0.35.4
Product / Package Ecosystem Affected Versions Fixed Version
sharp
npm
< 0.35.4
0.35.4

References

Frequently Asked Questions

What is GHSA-rgj7-g3m4-5g8c?
GHSA-rgj7-g3m4-5g8c is a security vulnerability in sharp involving Vulnerabilities in libheif: GHSA-g89c-p67h-r497 and GHSA-2jg2-4ch7-h545 under CWE-122: Heap-based Buffer Overflow.
Which sharp versions are affected?
Affected versions include releases prior to 0.35.4 across affected packages: sharp.
What version fixes GHSA-rgj7-g3m4-5g8c?
Upgrading to 0.35.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is sharp affected?
Yes, sharp is affected in releases prior to 0.35.4. Upgrade your dependency to 0.35.4 or later.
What CWE is associated with GHSA-rgj7-g3m4-5g8c?
GHSA-rgj7-g3m4-5g8c is classified under CWE-122: Heap-based Buffer Overflow (A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().).
How can I check npm dependencies for GHSA-rgj7-g3m4-5g8c?
Run the dependency tree command: 'npm ls sharp'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-rgj7-g3m4-5g8c",
  "modified" : "2026-09-08T21:25:11Z",
  "published" : "2026-09-08T21:25:11Z",
  "aliases" : [ ],
  "summary" : "sharp: Vulnerabilities in libheif: GHSA-g89c-p67h-r497 and GHSA-2jg2-4ch7-h545",
  "details" : "### Impact\nA number of vulnerabilities, two rated as \"Critical\" severity using CVSSv3, have been discovered and fixed in the upstream libheif dependency. These can lead to possible remote code execution (RCE) on glibc-based Linux when run under certain conditions.\n\nThe attack vector for these claims to be \"network\" however sharp does not provide any networking features so this vulnerability is down-rated to a \"High\" severity using CVSSv4 but please note its Subsequent System Impact.\n\nThose processing untrusted input with versions of sharp prior to 0.35.4 are affected.\n\n### Patches\n\n#### Using prebuilt binaries provided by sharp?\n\nMost people rely on the prebuilt binaries provided by sharp.\n\nPlease upgrade sharp to the latest version, currently 0.35.4, which provides libheif 1.23.2.\n\n#### Using a globally-installed libheif?\n\nPlease ensure you are using the latest libheif 1.23.2.\n\n### Workarounds\nAdd the following to your code to prevent sharp from decoding AVIF images.\n```js\nsharp.block({ operation: [\"VipsForeignLoadHeif\"] });\n```\n\nEnsure you are using a `node` executable binary compiled as a Position Independent Executable (PIE). Most Linux package managers already do this for protection against RCE however be warned that the \"official\" Node.js binaries do not.\n\n### References\n- [CVE-2026-84383](https://github.com/strukturag/libheif/security/advisories/GHSA-g89c-p67h-r497)\n- https://github.com/strukturag/libheif/security/advisories/GHSA-2jg2-4ch7-h545",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "sharp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.35.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/lovell/sharp/security/advisories/GHSA-rgj7-g3m4-5g8c"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/strukturag/libheif/security/advisories/GHSA-2jg2-4ch7-h545"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/strukturag/libheif/security/advisories/GHSA-g89c-p67h-r497"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/lovell/sharp"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/lovell/sharp/releases/tag/v0.35.4"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-122" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-08T21:25:11Z",
    "nvd_published_at" : null
  }
}