Skip to content

security: Lane Ten — fuzz coverage, WalkerLimits production, no-network audit - #124

Merged
DrunkOnJava merged 4 commits into
mainfrom
security/fuzz-limits
Aug 29, 2026
Merged

DrunkOnJava merged 4 commits into
mainfrom
security/fuzz-limits

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Aug 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Lane Ten (security) hardening for M8-01 / M8-02 / M8-05:

  1. Fuzz regression coverage expanded to remaining public byte parsers (find_gzip_offsets / inflate_all_chunks, class_index, ArcWall scan/decode, rect-opening index, share decode_from_fragment, STEP writer adversarial strings). Added fuzz_public_byte_parsers libFuzzer target + nightly matrix entry. Nightly install uses cargo +stable install cargo-fuzz (OPS-01).
  2. WalkerLimits in production scanning — ArcWall find_all / partition scans honor max_scan_bytes + max_candidates; IFC export + diagnostics use limited scans and surface WalkerLimitHit warnings; rvt-inspect exposes the same CLI limit flags as rvt-ifc.
  3. No-network VW1-21 — always-on Playwright test viewer/tests/wasm-no-network-imports.spec.ts runs wasm-objdump on viewer/pkg/rvt_bg.wasm (complements runtime no-network.spec.ts).

Test plan

  • cargo test --release --lib find_all_with_limits
  • cargo test --release --test fuzz_regressions
  • WASM network-import audit (wasm-objdump)
  • cd viewer && npx playwright test tests/wasm-no-network-imports.spec.ts
  • Optional: cargo +nightly fuzz build fuzz_public_byte_parsers if nightly available

Note

Medium Risk
Changes production IFC/inspect export paths and partition scanning behavior when limits hit; security-focused but can truncate ArcWall recovery on hostile or very large partition streams.

Overview
Lane Ten security hardening extends fuzzing, applies WalkerLimits to production partition/ArcWall scanning, and adds a compile-time viewer check for VW1-21.

Fuzzing (M8-01): New libFuzzer target fuzz_public_byte_parsers exercises gzip offset/inflate-all-chunks, class index extraction, bounded ArcWall scan/decode, rect-opening index, share decode_from_fragment, and related paths. Nightly CI runs it and installs cargo-fuzz via cargo +stable. tests/fuzz_regressions adds matching in-process no-panic regressions (including STEP writer adversarial strings).

DoS bounds (API-11 / T3): ArcWallRecord::find_all_with_limits and version-gated scans cap max_scan_bytes and max_candidates, returning scanned_bytes and WalkerLimitHit. scan_partition_arc_walls_with_limits applies the same caps across Partitions/* streams. IFC export and diagnostics use these limited scans and push limit-hit messages into export warnings. rvt-inspect accepts the same walker limit CLI flags as rvt-ifc. THREAT_MODEL.md marks WalkerLimits as shipped (not pending).

Viewer privacy (VW1-21): New Playwright test wasm-no-network-imports.spec.ts runs wasm-objdump on viewer/pkg/rvt_bg.wasm and fails if imports match network primitives—complementing runtime no-network.spec.ts. Docs/READMEs reference both checks.

Reviewed by Cursor Bugbot for commit 243cfe8. Configure here.

…rk audit

Expand fuzz regressions and add fuzz_public_byte_parsers for remaining
public byte parsers (gzip offsets, class_index, ArcWall, rect opening,
share fragment, STEP writer). Apply WalkerLimits to ArcWall/partition
production scans and rvt-inspect; surface limit hits in IFC diagnostics.
Add always-on Playwright wasm-objdump VW1-21 import audit and harden
nightly cargo-fuzz install to use stable.

Co-authored-by: DrunkOnJava <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Partition scan drops later streams
    • The outer partition loop now breaks only on MaxCandidates, so MaxScanBytes truncates the current buffer and scanning continues on later Partitions/* streams.
  • ✅ Fixed: Diagnostics repeats partition inflate
    • export_rvt_doc now returns the partition scan limit_hit and export_with_diagnostics passes it to build_export_diagnostics_with_limits, avoiding a second inflate-and-scan pass.

Create PR

Or push these changes by commenting:

@cursor push f429b89732
Preview (f429b89732)
diff --git a/src/ifc/mod.rs b/src/ifc/mod.rs
--- a/src/ifc/mod.rs
+++ b/src/ifc/mod.rs
@@ -504,7 +504,7 @@
         rf: &mut crate::RevitFile,
         limits: crate::walker::WalkerLimits,
     ) -> Result<IfcModel> {
-        export_rvt_doc(rf, RvtDocExportMode::Default, limits)
+        export_rvt_doc(rf, RvtDocExportMode::Default, limits).map(|(model, _)| model)
     }
 
     pub fn export_with_diagnostics(&self, rf: &mut crate::RevitFile) -> Result<ExportResult> {
@@ -516,12 +516,14 @@
         rf: &mut crate::RevitFile,
         limits: crate::walker::WalkerLimits,
     ) -> Result<ExportResult> {
-        let model = self.export_with_limits(rf, limits)?;
+        let (model, partition_arc_wall_limit_hit) =
+            export_rvt_doc(rf, RvtDocExportMode::Default, limits)?;
         let diagnostics = build_export_diagnostics_with_limits(
             rf,
             &model,
             ExportDiagnosticsMode::Default,
             limits,
+            Some(partition_arc_wall_limit_hit),
         );
         Ok(ExportResult { model, diagnostics })
     }
@@ -548,7 +550,7 @@
         rf: &mut crate::RevitFile,
         limits: crate::walker::WalkerLimits,
     ) -> Result<IfcModel> {
-        export_rvt_doc(rf, RvtDocExportMode::DiagnosticProxies, limits)
+        export_rvt_doc(rf, RvtDocExportMode::DiagnosticProxies, limits).map(|(model, _)| model)
     }
 
     pub fn export_with_diagnostics(&self, rf: &mut crate::RevitFile) -> Result<ExportResult> {
@@ -560,12 +562,14 @@
         rf: &mut crate::RevitFile,
         limits: crate::walker::WalkerLimits,
     ) -> Result<ExportResult> {
-        let model = self.export_with_limits(rf, limits)?;
+        let (model, partition_arc_wall_limit_hit) =
+            export_rvt_doc(rf, RvtDocExportMode::DiagnosticProxies, limits)?;
         let diagnostics = build_export_diagnostics_with_limits(
             rf,
             &model,
             ExportDiagnosticsMode::DiagnosticProxies,
             limits,
+            Some(partition_arc_wall_limit_hit),
         );
         Ok(ExportResult { model, diagnostics })
     }
@@ -581,7 +585,7 @@
     rf: &mut crate::RevitFile,
     mode: RvtDocExportMode,
     walker_limits: crate::walker::WalkerLimits,
-) -> Result<IfcModel> {
+) -> Result<(IfcModel, Option<crate::walker::WalkerLimitHit>)> {
     // Identity from PartAtom if present; fall back to
     // BasicFileInfo's original path.
     let part = rf.part_atom().ok();
@@ -668,12 +672,14 @@
     // See `reports/element-framing/RE-14.3-synthesis.md` and
     // `reports/element-framing/RE-15-arcwall-trailer-synthesis.md`.
     let mut building_storeys = Vec::new();
+    let mut partition_arc_wall_limit_hit = None;
     if let Some(revit_version) = bfi.as_ref().map(|b| b.version) {
         if let Ok(scan) = crate::partition_arc_walls::scan_partition_arc_walls_with_limits(
             rf,
             revit_version,
             walker_limits,
         ) {
+            partition_arc_wall_limit_hit = scan.limit_hit;
             let level_names = collect_partition_building_storey_names(rf);
             let recovery = crate::partition_arc_walls::recover_storeys_from_arc_walls(
                 &scan.walls,
@@ -712,18 +718,21 @@
 
     let recovered_units = recover_project_units(rf);
 
-    Ok(IfcModel {
-        project_name,
-        description,
-        entities,
-        classifications,
-        units: recovered_units.assignments,
-        building_storeys,
-        materials: Vec::new(),
-        material_layer_sets: Vec::new(),
-        material_profile_sets: Vec::new(),
-        representation_maps: Vec::new(),
-    })
+    Ok((
+        IfcModel {
+            project_name,
+            description,
+            entities,
+            classifications,
+            units: recovered_units.assignments,
+            building_storeys,
+            materials: Vec::new(),
+            material_layer_sets: Vec::new(),
+            material_profile_sets: Vec::new(),
+            representation_maps: Vec::new(),
+        },
+        partition_arc_wall_limit_hit,
+    ))
 }
 
 /// Placeholder thickness used only when the ArcWall trailer has no
@@ -1203,7 +1212,13 @@
     model: &IfcModel,
     mode: ExportDiagnosticsMode,
 ) -> ExportDiagnostics {
-    build_export_diagnostics_with_limits(rf, model, mode, crate::walker::WalkerLimits::default())
+    build_export_diagnostics_with_limits(
+        rf,
+        model,
+        mode,
+        crate::walker::WalkerLimits::default(),
+        None,
+    )
 }
 
 pub fn build_export_diagnostics_with_limits(
@@ -1211,6 +1226,7 @@
     model: &IfcModel,
     mode: ExportDiagnosticsMode,
     walker_limits: crate::walker::WalkerLimits,
+    precomputed_partition_arc_wall_limit_hit: Option<Option<crate::walker::WalkerLimitHit>>,
 ) -> ExportDiagnostics {
     let bfi = rf.basic_file_info().ok();
     let part = rf.part_atom().ok();
@@ -1246,16 +1262,24 @@
     let mut warnings = diagnostic_candidates.warnings;
     // Surface ArcWall partition-scan limit hits so crafted large
     // Partitions/* streams are visible in the diagnostics sidecar.
-    if let Some(version) = bfi.as_ref().map(|b| b.version) {
-        if let Ok(scan) = crate::partition_arc_walls::scan_partition_arc_walls_with_limits(
-            rf,
-            version,
-            walker_limits,
-        ) {
-            if let Some(hit) = scan.limit_hit {
-                warnings.push(format!("{}: {}", hit.code(), hit.message()));
+    let partition_arc_wall_limit_hit = match precomputed_partition_arc_wall_limit_hit {
+        Some(hit) => hit,
+        None => {
+            if let Some(version) = bfi.as_ref().map(|b| b.version) {
+                crate::partition_arc_walls::scan_partition_arc_walls_with_limits(
+                    rf,
+                    version,
+                    walker_limits,
+                )
+                .ok()
+                .and_then(|scan| scan.limit_hit)
+            } else {
+                None
             }
         }
+    };
+    if let Some(hit) = partition_arc_wall_limit_hit {
+        warnings.push(format!("{}: {}", hit.code(), hit.message()));
     }
     if exported.building_elements == 0 {
         warnings.push("No building elements were exported; output is scaffold-only.".into());

diff --git a/src/partition_arc_walls.rs b/src/partition_arc_walls.rs
--- a/src/partition_arc_walls.rs
+++ b/src/partition_arc_walls.rs
@@ -170,10 +170,7 @@
                 break;
             }
         }
-        if matches!(
-            limit_hit,
-            Some(WalkerLimitHit::MaxCandidates | WalkerLimitHit::MaxScanBytes)
-        ) {
+        if matches!(limit_hit, Some(WalkerLimitHit::MaxCandidates)) {
             break;
         }
     }

You can send follow-ups to the cloud agent here.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 243cfe8. Configure here.

limit_hit,
Some(WalkerLimitHit::MaxCandidates | WalkerLimitHit::MaxScanBytes)
) {
break;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partition scan drops later streams

Medium Severity

scan_partition_arc_walls_with_limits stops the whole multi-stream loop when any one partition reports WalkerLimitHit::MaxScanBytes. That flag only means the current buffer was larger than max_scan_bytes; max_candidates is the only budget reduced across partitions. A single oversized Partitions/* stream therefore drops ArcWalls from every later stream, including under default 128 MiB limits that are tighter than the 256 MiB open-stream cap.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 243cfe8. Configure here.

Comment thread src/ifc/mod.rs
if let Some(hit) = scan.limit_hit {
warnings.push(format!("{}: {}", hit.code(), hit.message()));
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diagnostics repeats partition inflate

Medium Severity

export_with_diagnostics_and_limits already runs scan_partition_arc_walls_with_limits while building the model, then build_export_diagnostics_with_limits runs the same inflate-and-scan again only to read limit_hit. read_stream is uncached, so every Partitions/* stream is read and inflated twice on rvt-inspect and IFC diagnostics.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 243cfe8. Configure here.

@DrunkOnJava
DrunkOnJava marked this pull request as ready for review August 29, 2026 10:06
@DrunkOnJava
DrunkOnJava merged commit 753c758 into main Aug 29, 2026
22 checks passed
@DrunkOnJava
DrunkOnJava deleted the security/fuzz-limits branch August 29, 2026 10:23
DrunkOnJava added a commit that referenced this pull request Aug 31, 2026
…rk audit (#124)

## Summary

Lane Ten (security) hardening for M8-01 / M8-02 / M8-05:

1. **Fuzz regression coverage** expanded to remaining public byte
parsers (`find_gzip_offsets` / `inflate_all_chunks`, `class_index`,
ArcWall scan/decode, rect-opening index, share `decode_from_fragment`,
STEP writer adversarial strings). Added `fuzz_public_byte_parsers`
libFuzzer target + nightly matrix entry. Nightly install uses `cargo
+stable install cargo-fuzz` (OPS-01).
2. **WalkerLimits in production scanning** — ArcWall `find_all` /
partition scans honor `max_scan_bytes` + `max_candidates`; IFC export +
diagnostics use limited scans and surface `WalkerLimitHit` warnings;
`rvt-inspect` exposes the same CLI limit flags as `rvt-ifc`.
3. **No-network VW1-21** — always-on Playwright test
`viewer/tests/wasm-no-network-imports.spec.ts` runs `wasm-objdump` on
`viewer/pkg/rvt_bg.wasm` (complements runtime `no-network.spec.ts`).

## Test plan

- [x] `cargo test --release --lib find_all_with_limits`
- [ ] `cargo test --release --test fuzz_regressions`
- [ ] WASM network-import audit (`wasm-objdump`)
- [ ] `cd viewer && npx playwright test
tests/wasm-no-network-imports.spec.ts`
- [ ] Optional: `cargo +nightly fuzz build fuzz_public_byte_parsers` if
nightly available

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes production IFC/inspect export paths and partition scanning
behavior when limits hit; security-focused but can truncate ArcWall
recovery on hostile or very large partition streams.
> 
> **Overview**
> Lane Ten security hardening extends fuzzing, applies
**`WalkerLimits`** to production partition/ArcWall scanning, and adds a
compile-time viewer check for VW1-21.
> 
> **Fuzzing (M8-01):** New libFuzzer target `fuzz_public_byte_parsers`
exercises gzip offset/inflate-all-chunks, class index extraction,
bounded ArcWall scan/decode, rect-opening index, share
`decode_from_fragment`, and related paths. Nightly CI runs it and
installs `cargo-fuzz` via **`cargo +stable`**. `tests/fuzz_regressions`
adds matching in-process no-panic regressions (including STEP writer
adversarial strings).
> 
> **DoS bounds (API-11 / T3):** `ArcWallRecord::find_all_with_limits`
and version-gated scans cap **`max_scan_bytes`** and
**`max_candidates`**, returning `scanned_bytes` and `WalkerLimitHit`.
`scan_partition_arc_walls_with_limits` applies the same caps across
`Partitions/*` streams. IFC export and diagnostics use these limited
scans and push limit-hit messages into export warnings.
**`rvt-inspect`** accepts the same walker limit CLI flags as
**`rvt-ifc`**. `THREAT_MODEL.md` marks WalkerLimits as shipped (not
pending).
> 
> **Viewer privacy (VW1-21):** New Playwright test
**`wasm-no-network-imports.spec.ts`** runs `wasm-objdump` on
`viewer/pkg/rvt_bg.wasm` and fails if imports match network
primitives—complementing runtime `no-network.spec.ts`. Docs/READMEs
reference both checks.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
2c5215c2a752dcaf5fbd96fec5939a8cda153830. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: DrunkOnJava <[email protected]>
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.

2 participants