Skip to content

Legal JPEG marker fill causes pixel billing to fall back to 16K tokens #6099

Closed

Description

@Afloat16

Problem

The lightweight JPEG scanner interprets a repeated FF byte as a length-bearing marker and skips the real frame header. Legal marker fill makes a small valid JPEG receive the 16,384-token unknown-image fallback, inflating preflight budgets.

Reproduction

At master 541cf26, encode a 40x24 JPEG and insert one FF before APP0 or three before SOF0. Jimp fully decodes both with correct dimensions, but decodeImageDims fails on the base. There are 13 passed / 2 failed.

Expected

Skip FF marker fill before interpreting the marker, retaining the bounded scan and malformed/truncated fallback. JPEG T.81 B.1.1.2 and E.2.1 define this behavior: https://www.w3.org/Graphics/JPEG/itu-t81.pdf

Prior work

Screened all 3,221 cached upstream PRs. #771/#1211/#1925/#3425 cover image billing, preprocessing and E2E tests, but not legal fill-byte runs in the lightweight dimension scanner. Previous Afloat16 PRs #6046–#6055 are excluded.

Activity

  1. ranxianglei commented on Nov 12, 2026

    @ranxianglei
    Owner

    Fixed in batch PR #6439 (merged).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions