[PR #938] [MERGED] fix(dotnet): validate managed metadata and CIL boundaries #2515

Closed
opened 2026-10-17 21:07:03 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/938
Author: @morluto
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @morluto

Base: main ← Head: codex/managed-metadata-audit


📝 Commits (10+)

  • 609977c perf(dotnet): reuse decoded metadata rows
  • c58fb1e test(dotnet): preserve expanded fixture metadata
  • 48933ab Merge remote-tracking branch 'origin/main' into codex/managed-metadata-audit
  • e9a92d9 style(dotnet): format metadata inventory
  • d9504c7 Merge remote-tracking branch 'origin/main' into codex/managed-metadata-audit
  • 97be420 fix(dotnet): bound method bodies to PE section data
  • e83ef26 fix(dotnet): derive fixture metadata index widths
  • c3dc2c5 Merge remote-tracking branch 'origin/main' into codex/managed-metadata-integration
  • 4431260 fix(dotnet): validate managed metadata bounds
  • f4dbb89 test(dotnet): cover large metadata ReadyToRun layout

📊 Changes

18 files changed (+1822 additions, -220 deletions)

View changed files

📝 src/dotnet/ManagedArtifactFailures.test.ts (+35 -0)
📝 src/dotnet/ManagedArtifactInspector.test.ts (+287 -0)
📝 src/dotnet/ManagedCilDecoding.test.ts (+326 -2)
➕ src/dotnet/ManagedExceptionRegionValidation.ts (+86 -0)
📝 src/dotnet/ManagedMemberInspector.test.ts (+109 -0)
📝 src/dotnet/ManagedMemberInspector.ts (+4 -2)
📝 src/dotnet/ManagedMemberInspectorCore.ts (+61 -41)
📝 src/dotnet/ManagedMemberInstructionDecoder.ts (+35 -16)
📝 src/dotnet/ManagedMemberRows.ts (+27 -2)
📝 src/dotnet/ManagedMetadataHeaps.ts (+23 -1)
📝 src/dotnet/ManagedMetadataInventory.ts (+53 -45)
📝 src/dotnet/ManagedMetadataInventoryRows.ts (+50 -8)
📝 src/dotnet/ManagedMethodBodyReader.ts (+27 -1)
📝 src/dotnet/ManagedNativeBoundaryHelpers.ts (+25 -1)
📝 src/dotnet/ManagedNativeBoundaryInspector.test.ts (+97 -0)
📝 src/dotnet/ManagedNativeBoundaryInspector.ts (+3 -1)
📝 src/dotnet/ManagedPe.fixture.ts (+556 -100)
📝 src/dotnet/ManagedPeReader.ts (+18 -0)

📄 Description

The managed inspector now decodes AssemblyRef and CustomAttribute rows once and reuses them across inventory consumers. The change also validates coded-index row bounds, decodes nested supported CIL signatures iteratively, and checks exception-region extents and instruction boundaries while retaining malformed metadata and raw EH clauses with actionable issues. Method-body reads remain bounded to file-backed PE section bytes.

Scalable source-owned PE fixtures now derive heap and coded-index widths from emitted tables and lay out large metadata, resources, and ReadyToRun data without overlap. Default and ReadyToRun fixture bytes remain unchanged (SHA-256 c96cd66659210492a76543a1760925838463c48b626c71ad6a560bfa699b2f63 and 129d2e4ad3a8e58103c4077d4bf1d3f0cdc0a373814ee2368d023493999d43a8).

A 12-measurement alternating baseline/candidate run of the full inspectManagedArtifactBytes path on valid generated PE32/CLI inputs (including parsing, inventories, and result-schema validation) preserved exact output digests and complete coverage. Median time was 1.768 to 1.374 ms at 1,000 AssemblyRefs (input SHA-256 3f6b364414123b02064e40ed5c9ee499c4a8c897097436bb02c5d0374cce741a, output SHA-256 2bd50ed87a5d447cfd35875b583fa255ea93ff2f4a5bce6df7c37066b647db45) and 9.219 to 5.758 ms at 5,000 (input 935e09b883f87a0b90dcd8faa932b955e626f7d8171269dc04de85f214cb4c89, output 93ef214f4b5876417f9b67fc6b984fe842c6e745f2f66c1971fcb1ff4e2986c7). These measurements describe those fixture sizes and this host.

Validation: 58 managed tests, npm run build:cached, npm run check:fast, npm run docs:check, and npm run format:check pass. The .NET SDK is unavailable here, so real CLR conformance remains unverified. EH boundary checks follow ECMA-335, 6th edition, §I.12.4.2.7: ECMA-335.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/938 **Author:** [@morluto](https://github.com/morluto) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `codex/managed-metadata-audit` --- ### 📝 Commits (10+) - [`609977c`](https://github.com/morluto/rea/commit/609977cb5a37e466a857942789eb56b2c7774ee0) perf(dotnet): reuse decoded metadata rows - [`c58fb1e`](https://github.com/morluto/rea/commit/c58fb1e053076cd301d9e5ed8c7e54b2d4e09e57) test(dotnet): preserve expanded fixture metadata - [`48933ab`](https://github.com/morluto/rea/commit/48933ab27c37515180860ed0afd981c262b2e804) Merge remote-tracking branch 'origin/main' into codex/managed-metadata-audit - [`e9a92d9`](https://github.com/morluto/rea/commit/e9a92d926f4c5270cc0625af7498f0f194f1cf4e) style(dotnet): format metadata inventory - [`d9504c7`](https://github.com/morluto/rea/commit/d9504c79f25e249ff52fa635316d5dd774cfcb5c) Merge remote-tracking branch 'origin/main' into codex/managed-metadata-audit - [`97be420`](https://github.com/morluto/rea/commit/97be420fe3b619447b2d76d8be54cf340ee8107d) fix(dotnet): bound method bodies to PE section data - [`e83ef26`](https://github.com/morluto/rea/commit/e83ef2620a973dafe7d270d9b34bfaef45ad9e95) fix(dotnet): derive fixture metadata index widths - [`c3dc2c5`](https://github.com/morluto/rea/commit/c3dc2c5aea1817b1671fa19c7ce78bcd2a623761) Merge remote-tracking branch 'origin/main' into codex/managed-metadata-integration - [`4431260`](https://github.com/morluto/rea/commit/44312601a3c2224c8902efcb2b802b268f650c69) fix(dotnet): validate managed metadata bounds - [`f4dbb89`](https://github.com/morluto/rea/commit/f4dbb89653695ef0be3e8a0e14189fdebb74ceea) test(dotnet): cover large metadata ReadyToRun layout ### 📊 Changes **18 files changed** (+1822 additions, -220 deletions) <details> <summary>View changed files</summary> 📝 `src/dotnet/ManagedArtifactFailures.test.ts` (+35 -0) 📝 `src/dotnet/ManagedArtifactInspector.test.ts` (+287 -0) 📝 `src/dotnet/ManagedCilDecoding.test.ts` (+326 -2) ➕ `src/dotnet/ManagedExceptionRegionValidation.ts` (+86 -0) 📝 `src/dotnet/ManagedMemberInspector.test.ts` (+109 -0) 📝 `src/dotnet/ManagedMemberInspector.ts` (+4 -2) 📝 `src/dotnet/ManagedMemberInspectorCore.ts` (+61 -41) 📝 `src/dotnet/ManagedMemberInstructionDecoder.ts` (+35 -16) 📝 `src/dotnet/ManagedMemberRows.ts` (+27 -2) 📝 `src/dotnet/ManagedMetadataHeaps.ts` (+23 -1) 📝 `src/dotnet/ManagedMetadataInventory.ts` (+53 -45) 📝 `src/dotnet/ManagedMetadataInventoryRows.ts` (+50 -8) 📝 `src/dotnet/ManagedMethodBodyReader.ts` (+27 -1) 📝 `src/dotnet/ManagedNativeBoundaryHelpers.ts` (+25 -1) 📝 `src/dotnet/ManagedNativeBoundaryInspector.test.ts` (+97 -0) 📝 `src/dotnet/ManagedNativeBoundaryInspector.ts` (+3 -1) 📝 `src/dotnet/ManagedPe.fixture.ts` (+556 -100) 📝 `src/dotnet/ManagedPeReader.ts` (+18 -0) </details> ### 📄 Description The managed inspector now decodes AssemblyRef and CustomAttribute rows once and reuses them across inventory consumers. The change also validates coded-index row bounds, decodes nested supported CIL signatures iteratively, and checks exception-region extents and instruction boundaries while retaining malformed metadata and raw EH clauses with actionable issues. Method-body reads remain bounded to file-backed PE section bytes. Scalable source-owned PE fixtures now derive heap and coded-index widths from emitted tables and lay out large metadata, resources, and ReadyToRun data without overlap. Default and ReadyToRun fixture bytes remain unchanged (SHA-256 `c96cd66659210492a76543a1760925838463c48b626c71ad6a560bfa699b2f63` and `129d2e4ad3a8e58103c4077d4bf1d3f0cdc0a373814ee2368d023493999d43a8`). A 12-measurement alternating baseline/candidate run of the full `inspectManagedArtifactBytes` path on valid generated PE32/CLI inputs (including parsing, inventories, and result-schema validation) preserved exact output digests and complete coverage. Median time was 1.768 to 1.374 ms at 1,000 AssemblyRefs (input SHA-256 `3f6b364414123b02064e40ed5c9ee499c4a8c897097436bb02c5d0374cce741a`, output SHA-256 `2bd50ed87a5d447cfd35875b583fa255ea93ff2f4a5bce6df7c37066b647db45`) and 9.219 to 5.758 ms at 5,000 (input `935e09b883f87a0b90dcd8faa932b955e626f7d8171269dc04de85f214cb4c89`, output `93ef214f4b5876417f9b67fc6b984fe842c6e745f2f66c1971fcb1ff4e2986c7`). These measurements describe those fixture sizes and this host. Validation: 58 managed tests, `npm run build:cached`, `npm run check:fast`, `npm run docs:check`, and `npm run format:check` pass. The .NET SDK is unavailable here, so real CLR conformance remains unverified. EH boundary checks follow ECMA-335, 6th edition, §I.12.4.2.7: [ECMA-335](https://www.ecma-international.org/wp-content/uploads/ECMA-335_6th_edition_june_2012.pdf). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:07:03 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2515
No description provided.