Skip to content

fix(research): native readers fail closed on a group record length that overflows a 32-bit usize, and cylinder trim rings and trimmed-cell cuts are bounded (#1815) - #1823

Merged
DrunkOnJava merged 2 commits into
mainfrom
fix/1815-native-reader-bounds
Nov 12, 2026
Merged

DrunkOnJava merged 2 commits into
mainfrom
fix/1815-native-reader-bounds

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

This closes four gaps #1815 lists in the native readers:

  • A group record length that overflows a 32-bit usize now fails closed.
  • The walker's two-column container read is checked.
  • A cylinder face's trim ring has a total point budget.
  • The v-knot scans of trimmed_cells are counted against a budget.

No real file should change; the Measure run checks that.

Motivation

Part of #1815: (1) and (3) are done as it asks. (2) is bounded, but its refusal is not yet shown on a synthetic face, and (4) has no reachable repro. Both are recorded on #1815. Tendrils audit workers found these and I checked each against main. I wrote the code, adapting the workers' proposals: the cylinder budget and the cut budget differ from what they proposed, for the reasons below.

Changes

  • src/research/native_document.rs, group_records: end + 4 is a checked add. On a 32-bit target, a length of 0xFFFF_FFF5 used to panic under overflow checks, or slice out of range without them (wasm32, which the viewer runs).
  • src/walker.rs, read_field's Container { kind: 0x0e }: 4 + count * 6 and 2 * col_bytes are checked, as trial_walk_checked already checks the same read.
  • src/research/native_saved_mesh.rs:
    • A cylinder's trim ring is held to CYLINDER_RING_POINT_BUDGET, 20,000. That is twice PLANAR_FACE_POINT_BUDGET: each plane's polygon is held to that, and a column or pipe is cut by two planes.
    • Each crossing edge is bounded by the points the ring has left, before it is refined, and is refused as cylinder trim budget exceeded.
    • An edge that runs out of points now refuses the face. The ring's budget is below an edge's own 100,000, so this replaces the old case where such an edge kept its stored samples. The plane sharing the edge refuses at 10,000 first, so the element wasn't drawn either way. Any other refinement error still keeps the stored samples.
    • refine_crossing_edge, now used only by tests, is compiled for tests only. Its doc moved to refine_crossing_edge_within, which production calls.
  • src/research/native_parametric_mesh.rs: each trapezoid's scan of the v knots is counted against CUT_BUDGET, 250,000,000, the same as the planar work budget, and refused as trim cut budget exceeded. STRIP_BUDGET keeps its meaning.
    • The worker proposed multiplying STRIP_BUDGET's product by the v knots. That over-counts: the strip filter is not repeated per knot, and it could refuse a real face.
  • tests/fuzz_regressions.rs: native_group_record_length_overflow_does_not_panic builds a crafted MS-CFB file in memory (a 2023 BasicFileInfo, a native schema registry, one partition with one channel-101 group) and walks it through native_form_geometry.
  • changelog.d/security/1815-native-reader-bounds.md: what a crafted file could do before, and what it gets now.

Testing

Expected results are registered on #1815 before the run. One unfiltered byte-identity Measure follows.

The walker fix has no repro through the public reader. read_adocument only reads where the checked trial walk matched every field, and an overflowing count can't fit the bytes it needs. #1815 records this.

  • tools/check-local.sh: not run locally (no local builds); CI runs it
  • Real files: the unfiltered Measure, registered first
  • Hardening: the i686 overflow-checks job runs tests/fuzz_regressions.rs

Audit-honesty checklist

  • No claim beyond what ships; (4)'s missing repro is stated
  • Security changelog fragment: a crafted file could crash the wasm viewer or take unbounded work
  • No emojis or private paths

Legal and contribution hygiene

  • Apache-2.0; no Autodesk source; synthetic test bytes only

Breaking changes

None. The changed functions are crate-private.

https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge

…at overflows a 32-bit usize, and cylinder trim rings and trimmed-cell cuts are bounded (#1815)

group_records added 4 unchecked to a record's end after checking start + length: on a 32-bit
target a length of 0xFFFFFFF5 puts the end within 4 of usize::MAX, which panicked under overflow
checks (the i686 job) and sliced out of range without them (wasm32). The sum is checked now, and
tests/fuzz_regressions.rs reaches it through native_form_geometry with a crafted MS-CFB file built
in memory (cfb, already a dependency, as a dev-dependency).

The walker's two-column container read multiplied a file's count unchecked once a caller raised
max_container_records; it is checked as trial_walk_checked's read of the same shape is. No crafted
file reaches it through the public reader: read_adocument reads only where that checked trial walk
matched every field, and a count that overflows cannot fit the bytes the trial needs.

A cylinder face's trim ring had no total point budget: each edge it shares with a crossing plane
could take EDGE_POINT_BUDGET points. It is held to CYLINDER_RING_POINT_BUDGET, twice
PLANAR_FACE_POINT_BUDGET (each plane's polygon is held to that, and a column or pipe is cut by two),
counted before each edge is refined and refused as "cylinder trim budget exceeded"; any other
refinement error keeps the stored samples as before.

trimmed_cells counted strips times segments but not the v knots each trapezoid scans; that scan is
counted as it happens against CUT_BUDGET (250,000,000, as the planar faces' work budget) and refused
as "trim cut budget exceeded", with two pure-helper tests of the failure.

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
…tests the cut as cut, and drops a redundant dev-dependency

A security changelog fragment says what a crafted file could do before (crash the 32-bit and wasm32
viewer through a record length, take unbounded work in a cylinder's trim ring or a trimmed face's
cuts) and what it gets now. The under-budget trimmed_cells test asserts the four-band loop is cut
whole, every triangle inside it and their area its 2, not only that the budget did not refuse it.
cfb is already a dependency, so the dev-dependency line goes. The cylinder edge's doc says that an
edge out of points now always refuses the face, since the ring's budget is below the edge's own.

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
@DrunkOnJava
DrunkOnJava merged commit b91838b into main Nov 12, 2026
63 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/1815-native-reader-bounds branch November 12, 2026 20:36
DrunkOnJava added a commit that referenced this pull request Nov 12, 2026
…ostics moved, the scorer residue, the probe's lines and the timing ratios (#1830)

## Summary

Measure's run summary now opens with its verdict, so its reader no
longer downloads both sides' results to learn which exports moved:

- how many models' `ifc.sha256` and `diagnostics.json` equal the base's,
naming the ones that differ (the scorer diff leaves both files out);
- whether the scorer diff holds anything beyond what the head side alone
writes (each model's `probe.txt`, its `probe: exit N` line, and
`areas_across_saves*`), with the first such lines;
- with a probe, its lines counted across the models, and any model whose
probe did not exit 0.

A timed run opens its timing table with a timing verdict:
- the median, lowest and highest head / base time and peak, for the
models, the samples of Revit 2023 to 2027 and those of 2015 to 2022;
- the three longest-running files and the three with the highest peak;
- every file more than 3% slower, or more than 2% higher in peak.

Both are also in the job log and in small artifacts (`measure-verdict`,
and `timing-verdict.md` in `measure-timing`), for a reader without the
summary page.

## Motivation

Every Measure run is read for the same figures, and they were computed
by hand each time: five times on 11-12 alone (#1813, #1818, #1821, #1823
and the 0.14.1 hotfix). Neither script judges a pull request's
registered rows. They print what the rows are written in.

## Changes

- `tools/re/measure_verdict.py`: the export verdict over the merged
`measure-head` and `measure-base` directories and `scorer-diff.txt`.
- `tools/re/timing_verdict.py`: the timing verdict over the merged
`timing.md`. It computes each ratio from the medians, not from the
table's rounded ratio column.
- `.github/workflows/measure.yml`:
- the compare job checks the first script out with its other tools,
makes the scorer diff before the summary, prints the verdict at its top,
and uploads `measure-verdict`;
- the timing job checks the second script out first and prints its
verdict above the table.

## Testing

Unit tests are banned here. Both scripts were run on the results of real
runs and compared with what had been read by hand:

- **#1821's run 43291861101:** 125 of 125 exports and 101 of 101
diagnostics identical, no scorer residue, and the probe's `export
units_reads held=0 walked=1` on 100 models and `held=1` on one. This is
the read that found #1821's dropped pass.
- **#1694's C2 timing, 43288830617:** the 28 samples of Revit 2023 to
2027 at a median of 0.998, `rac_basic` 2023 at 1.070 and 2027 at 1.050,
and 2021 `rst_basic`'s peak at 1.023. These match comment 6834180051.
- **A scorer diff with two added lines and an extra file:** reported as
3 lines in 2 files, with the head-only output still left out.
- **No base, a missing head and a missing table:** each prints a plain
line and does not fail the job.

The rehearsal is run
[43304266907](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43304266907),
dispatched from this branch on two models, timed, with a probe. Its
summary, job logs and both artifacts are read before this is marked
ready. `tools/ci/check-workflows.py`: 0 errors, 0 warnings.

## Breaking changes

None.
DrunkOnJava added a commit that referenced this pull request Nov 14, 2026
…et is refused, shown on a face built by hand (#1815) (#1961)

## Summary

Shows, on a cylinder face built by hand, what #1815's cylinder trim
budget does: a face whose trim ring would hold more than 20,000 points
is refused as `cylinder trim budget exceeded`. This is the part of #1815
still open after #1823.

## Motivation

#1823 bounded a cylinder face's trim ring (`CYLINDER_RING_POINT_BUDGET`,
20,000 points), and its Measure showed that no real face comes near it.
#1815's "done when" asks for the refusal to be shown on a synthetic
input when no real file reaches it. #1823 left that out because the
tests had no way to build an object graph. They do: `ObjectGraph`
deserializes, and pointers resolve through each object's token when the
graph lists no edge.

## Changes

- `tests/fuzz_regressions.rs`,
`cylinder_trim_ring_over_its_point_budget_is_refused`:
- a face, its `CylSurf`, one `EdgeLoop` and one `Edge` whose stored
interior points alone pass the budget. `cylinder_face` refuses it as
`cylinder trim budget exceeded`, the error the saved-mesh pass turns
into drawing the element without its saved mesh;
- the same face with two fewer interior points passes the budget's check
and is refused later for something else ("too few boundary edges"), so
the first refusal is the budget's own.
- Every point lies at v = 0.5, so `refined_curved_edge` sees an
isoparametric edge and adds nothing: the count is the stored points
alone.

## Testing

A test only, with no source change, so no Measure. CI's `hardening`
class runs `fuzz_regressions`, on the i686 overflow-checks job too.

- [ ] `tools/check-local.sh`: not run locally (no local builds);
`rustfmt --check` passes; CI runs the rest.

## Audit-honesty checklist

- [x] No claim beyond what ships. With #1823 this completes #1815: its
(4), the walker's container count, is fixed as defense in depth with no
repro, since no crafted file reaches it through the public reader
(#1815, 2026-11-12).
- [x] No emojis, no private paths.

## Legal and contribution hygiene

- [x] Apache-2.0; synthetic values only.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant