Skip to content

Crafted files: seven overflows in arithmetic on file values panic a reader, two of them in the 32-bit viewer build #1831

Closed

Description

@DrunkOnJava

What

Seven places where arithmetic on a value read from the file can overflow, so a crafted file can panic a reader. Each was found by an audit of the parsing paths, confirmed by a second reader, and re-read against main (1a9aacc7).

Two panic in every 32-bit build, including the wasm32 viewer, whose release build has no overflow checks:

  1. src/research/native_index.rs:548, parse: episodes.len().checked_sub(creation_episode as usize + 1), with creation_episode a u32 from Global/ElemTable. At 0xFFFF_FFFF the + 1 wraps to 0 on a 32-bit target, the checked_sub passes, and episodes[reverse] indexes past the end. With overflow checks the add panics first. Every native read reaches it (native_preamble).
  2. src/research/native_walls.rs:105, shell_widths: exterior + interior, two shell-layer counts from a CompoundStructure. On a 32-bit target two large counts wrap, the length check passes, and widths[..exterior] slices past the end. 64-bit is safe: no decoded count exceeds i64::MAX.

Three panic only where overflow checks are on (debug builds, CI's i686 job), on every target. A release build wraps:

  1. src/research/native_index.rs:135, decode_increment_rows: greatest_episode + 1 at m_greatest.m_id = i64::MAX. Release wraps to i64::MIN, which u64::try_from refuses.
  2. src/research/native_stairs.rs:569, native_stair_counts: top - base of a StairsRun's riser indices, at i64::MAX and i64::MIN. Release wraps to -1 risers, which the export would write as the run's riser count.
  3. src/research/native_stairs.rs:1022, railing_records: the same subtraction. Release wraps to -1, and the railing gets no length.

Two more panic on 32-bit targets only with overflow checks. Without them they wrap: 6 reads its number from the wrong offset, and 7 misjudges the encoding.

  1. src/research/partition_mep_systems.rs:83, circuit_number: list + 4 + count * 32, with count a u32 from an electrical system's object. The multiply is checked but the add is not. It is on the default export path for 2024 and later (attach_mep_systems).
  2. src/transmission_data.rs:152, looks_like_utf16_le: ascii_nul * 100, for a TransmissionData stream of 85,899,346 bytes or more, under the 256 MiB stream cap. Nothing in the repository calls it (probe_transmission_data is public API).

Done when

  • Each is a checked operation that refuses the value on every target.
  • Every export of a real file is byte for byte as before: one unfiltered Measure (samples, Nordic, Revit 2025, held-out) against main.

None has a repro. Each needs a crafted schema and object graph to reach it through the public reader, which is out of proportion to a one-line checked operation. Each was verified by reading.

Found by Tendrils audit workers (DeepSeek), checked by a second worker each, and re-read by rvtDevelop.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions