Skip to content

[P2] PNG and UF2 LZMA decompression has no memory or output-size bounds #13

Open

Description

@UnsignedArduino

The embedded-source decoder calls lzma.decompress without a decoder memory limit or a bound on decompressed output. The resulting data is then copied into UTF-16 and parsed as JSON, further increasing peak memory usage.

Relevant code: embedded_source.py, lines 79–82.

The UF2 image-size limit bounds the compressed input image, not the expanded source. ZIP's uncompressed-size limit does not apply to PNG/UF2 imports.

A bounded review probe constructed a valid 1,458-byte MakeCode project PNG that successfully extracted 16 MiB of source. Larger compressed payloads can exhaust a build worker's memory despite the other import limits.

Expected behavior: bound both the LZMA decoder's dictionary allocation and the total expanded output before decoding/copying/parsing the complete project, and report an import error when the limits are exceeded. A decoder memory limit alone does not cap the expanded output.

Found while reviewing PR #7, toolchain at ce12c48.

Activity

  1. changed the title [-][P2] PNG and UF2 LZMA decompression has no memory or output-size bounds[/-] [+]PNG and UF2 LZMA decompression has no memory or output-size bounds[/+] on Nov 4, 2026
  2. changed the title [-]PNG and UF2 LZMA decompression has no memory or output-size bounds[/-] [+][P2] PNG and UF2 LZMA decompression has no memory or output-size bounds [found by chatgpt codex][/+] on Nov 4, 2026
  3. changed the title [-][P2] PNG and UF2 LZMA decompression has no memory or output-size bounds [found by chatgpt codex][/-] [+][P2] PNG and UF2 LZMA decompression has no memory or output-size bounds[/+] on Nov 4, 2026
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

    bugSomething isn't workingfound by chatgptIssue was originally found by ChatGPT Codex. Only used for tracking.p2

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions