Skip to content

Crafted files: eighteen readers do unbounded work or hold unbounded memory, two of them exponential #1833

Closed

Description

@DrunkOnJava

What

Eighteen places where a crafted file can make a reader do work, or hold memory, that grows faster than the file, with no budget. None panics; each is a hang or an out-of-memory on a hostile file. Each was found by an audit of the parsing paths and confirmed by a second reader. rvtDevelop re-read the two exponential ones (A, B) against main (1a9aacc7). #1831 has the panics from the same audit.

Exponential

  • A. src/research/native_index.rs:357-421, fixed_layout: the only bound is depth < 128. A chain of classes, each holding two reference fields (base == 14) to the next, makes 2^127 visits, with or without leaves. Every native read reaches it (native_preamble).
  • B. src/research/native_graphics_traversal.rs:544, only_curves: seen holds only the current path, and nothing counts calls. A duplicated or shared child at each level makes up to 2^128 calls. visit stops at 100,000, but this check never counts against that. Default export (saved graphics) and the viewer.

Polynomial in a file-sized count, on the default export path

  • C. src/research/partition_pipe_axes.rs:413-415, scan_pipe_end_keys: a contains on an uncapped key Vec, O(H²) in connector markers.
  • D. partition_pipe_axes.rs:223-241, BoxGrid::new: 4,096 cells per pipe box, no cap on the total over boxes.
  • E. partition_pipe_axes.rs:307-315, connector_points: holds runs before the 64-point cap, H × boxes per cell.
  • F. src/research/partition_curve_fields.rs:243-246: each anchor's 2 KB window is not clamped to the next anchor, and oversized boxes are tested at every point, anchors × boxes.
  • G. src/research/partition_room_parameters.rs:337-354, enclosing_data_object: a 200,000-step backward search for every parameter-key hit (:462, :518), hits uncapped, about 4e12 steps in 256 MiB.
  • H. src/research/partition_room_boundaries.rs:877-890, solid_headers_by_id: headers per id uncapped, and each rescans 64 KiB.
  • I. src/research/element_record_plan_profiles.rs:820-888, solve_loops / sole_candidate: Θ(n⁴) to Θ(n⁵) in one owner's sketch lines, with no cap per owner.
  • J. src/research/element_record_wall_joins.rs:286, join_trims: quadratic in wall records (each candidate scan up to 1,024 references), no cap on records.
  • K. src/research/native_empty_faces.rs:122, from native_saved_mesh.rs:2086: every matching Edge rescans every object of the graph. That is about 1e12 per face at the export's 1,000,000-object graph limit.
  • L. src/reader.rs:900, the inflated-partition memo: 1 GiB per stream, nothing over the sum of Partitions/* streams.
  • M. src/reader.rs:980, header_hits: one usize per header hit, kept for each (stream, header), about 0.8x the stream.

Opt-in paths

  • N. src/research/native_parameter_definitions.rs:310-327, matching_bindings: bindings × backlink array for each FamilyInstance / FamilySymbol record (--revit-property-sets, rvt-elements).
  • O. native_parameter_definitions.rs:379, ingest_units: UnitsElem records × definitions.
  • P. src/research/native_family_forms.rs:278-286, blocks_of: bodies × content keys, with no cancellation check inside (--family-extrusions).
  • Q. src/research/native_form_geometry.rs:1696, surface_samples: allocated outside the MESH_PAIR_BUDGET check, about 39 × 2e6 points plus 512 per solid (--family-extrusions).

Research API only

  • R. src/research/partition_scanner.rs:178, max_candidates: None by default: one candidate per 4 bytes for a schema tag repeated through a partition.

Done when

  • Each is bounded by a budget stated with its reason, or a structure that removes the blow-up (a memo, a sorted set), at no cost to a real file.
  • What a hostile input gets over a budget is stated: refused with a note, or the element is drawn without that part.
  • Every export of a real file is byte for byte as before: an unfiltered Measure for each PR.

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

Activity

  1. 6 remaining items

  2. DrunkOnJava commented on Nov 14, 2026

    @DrunkOnJava
    OwnerAuthor

    Where the eighteen stand on main (2b4f18b):

    Sites Landed in
    A, B (the two exponential ones) #1835
    J, O, P #1847
    C, D, E, F, G, H, I, K, L, M, N, Q, and R's per-stream doubling #1849

    Each of the three PRs left every export of its unfiltered Measure byte for byte as before, and #1849 reports a reader's budget stop as work_budget_reached in the diagnostics: rvt-ifc and rvt-gltf exit 3, and Python raises, unless the caller allows a partial export.

    Left: R's default. ScanOptions::default() still sets max_candidates: None. That one is not like the others: scan_partition_buffer reads each offset once and keeps at most one candidate for every four bytes (a candidate needs its tag and two zero bytes), so its time and memory grow linearly with the stream, under the reader's stream limit, rather than faster than the file. It is a research API (rvt::research::partition_scanner), and nothing in the export or the CLIs calls it: only examples/partition_scanner_json.rs and two corpus tests do. A default cap would need the candidate totals of real files first, so that it never cuts a real scan; #1849's challenger asked for those. That measurement is what keeps this open.

  3. added
    type:security
    area:reader
    priority:P2
    on Nov 14, 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

    area:readerpriority:P2type:security

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions