Skip to content

One ParseLimits with every cap #185

Open

Description

@DrunkOnJava

Scope

Every cap (file, section, decompression, objects, handles, recursion, strings) in one struct with a conservative default and a documented permissive profile; THREAT_MODEL.md generated from or checked against it.

State on main (2026-10-21)

Several limit structs.

Acceptance

  • No allocation sized by file data without a cap
  • THREAT_MODEL.md in sync, checked in CI

Parent: #184

Activity

  1. added
    type:security
    area:security
    priority:P1
    on Oct 21, 2026
  2. DrunkOnJava commented on Oct 28, 2026

    @DrunkOnJava
    OwnerAuthor

    An inventory for the first acceptance item, "no allocation sized by file data without a cap". It was prompted by a Codex finding on #335.

    DATATABLE reserved Vec::with_capacity(column_count) after a check against the bits left in the whole payload. Those bits can lie beyond the record's data-stream boundary, so a malformed record declaring 100,000,000 columns asked for gigabytes before it read its first column. #335 now starts the vectors at count.min(1024) and lets them grow as entries decode, as objects/dictionary.rs already does.

    The same shape, Vec::with_capacity(<count read from the file>), appears at these sites. The list is taken from the head of the unp stack (#341), so it includes the decoders still in review. Calls sized by an existing buffer's .len() or by a constant are left out. Some of these counts may already be bounded against the record's boundary or a ParseLimits field before the allocation, and each site needs checking:

    • src/entities/acad_table.rs: lines 186, 210, 547, 551, 564
    • src/entities/attdef.rs: lines 142, 154
    • src/entities/attrib.rs: lines 231, 243
    • src/entities/block.rs: lines 63, 76
    • src/entities/hatch.rs: lines 321, 365, 420, 478, 499, 548, 552, 606
    • src/entities/image.rs: lines 130
    • src/entities/imagedef.rs: lines 133, 145
    • src/entities/leader.rs: lines 128
    • src/entities/lofted_surface.rs: lines 72
    • src/entities/lwpolyline.rs: lines 181, 204, 208, 212
    • src/entities/mesh.rs: lines 171, 202, 212, 224
    • src/entities/mleader.rs: lines 416, 427, 522, 589, 604, 658, 724
    • src/entities/mline.rs: lines 172, 178, 197, 216
    • src/entities/mtext.rs: lines 364, 376
    • src/entities/ole2_frame.rs: lines 70
    • src/entities/proxy_entity_passthrough.rs: lines 83
    • src/entities/spline.rs: lines 158, 162, 170
    • src/entities/text.rs: lines 221, 234
    • src/entities/tolerance.rs: lines 175, 187
    • src/entities/underlay.rs: lines 141
    • src/header.rs: lines 114
    • src/metadata.rs: lines 76, 345, 350, 468, 492
    • src/objects/acad_cell_style_map.rs: lines 48
    • src/objects/acad_mlinestyle.rs: lines 129
    • src/objects/acad_property_set_data.rs: lines 103
    • src/objects/acad_table_style.rs: lines 269
    • src/objects/block_sortents_table.rs: lines 49
    • src/objects/class_map_extension.rs: lines 77
    • src/objects/clip_spatial_filter.rs: lines 100
    • src/objects/custom_dict_entry.rs: lines 57
    • src/objects/data_table.rs: lines 101, 108, 116
    • src/objects/eval_graph.rs: lines 110, 121
    • src/objects/proxy_entity.rs: lines 51, 61
    • src/objects/proxy_object.rs: lines 49, 59
    • src/objects/sh_history.rs: lines 306
    • src/objects/table_cell_style.rs: lines 236
    • src/objects/table_content.rs: lines 412, 470, 514, 554, 578, 583, 590
    • src/objects/table_geometry.rs: lines 123, 153
    • src/objects/xdata.rs: lines 97, 113
    • src/objects/xrecord.rs: lines 244
    • src/r2007.rs: lines 149, 535, 690
    • src/section_map.rs: lines 397, 420
    • src/tables/ltype.rs: lines 146, 227
    • src/tables/mod.rs: lines 100, 112

    Two fixes would work, and each needs no new limit: start at count.min(N) and grow, or bound the count by the record's own data-stream boundary before the allocation. Either keeps a malformed record's failure an Error rather than an allocation abort. The hardening PR should come after the decoder stacks (#335 to #341, the R13 stack) land, because it touches the same files.

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:securitypriority:P1type:security

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions