Skip to content

Fix DoS: infinite loop on zero-size boxes in HEIF/JXL parsers - #1

Open
jasonjul wants to merge 2 commits into
mainfrom
fix/heif-jxl-infinite-loop-dos
Open

Fix DoS: infinite loop on zero-size boxes in HEIF/JXL parsers#1
jasonjul wants to merge 2 commits into
mainfrom
fix/heif-jxl-infinite-loop-dos

Conversation

@jasonjul

@jasonjul jasonjul commented Sep 2, 2026

Copy link
Copy Markdown

Summary

  • Fixes GHSA-5p2g-fcmc-qvqq / CVE-2025-71329.
  • A crafted HEIF ispe box or JXL jxlp box with a zero-valued size field left the scan offset unchanged (offset = box.offset + box.size), so the containing while loop in heif.ts / jxl.ts never advances and spins forever, permanently blocking the event loop.
  • findBox in utils.ts already guards its own internal scan against zero-size boxes, but callers that additionally use box.size to advance their own offset were not guarded. This applies the same "advance by at least 8 bytes" guard at those call sites.

Test plan

  • Added specs/heif-jxl-dos.spec.ts with crafted HEIF/JXL buffers containing zero-size boxes; asserts the parser returns/throws instead of hanging.
  • yarn test passes with full coverage on both changed lines.
  • yarn build succeeds.

A crafted HEIF ispe box or JXL jxlp box with a zero-valued size field
left the parser's scan offset unchanged, causing the containing while
loop to spin forever and permanently block the event loop.

Fixes GHSA-5p2g-fcmc-qvqq / CVE-2025-71329.
@jasonjul jasonjul self-assigned this Sep 2, 2026
…boxes

The zero-size guard only caught an exact 0; a declared size of 1-7
(smaller than the 8-byte box header) still advanced the offset by that
tiny amount. The three call sites (findBox, HEIF's ispe scan, JXL's
jxlp scan) duplicated the same guard independently, so the gap existed
in all three. Factor the guard into a shared advanceBox helper that
clamps to the header size.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant