[PR #4469] [MERGED] fix(native): reject empty Swift class vtable owner before slot insertion #6260

Closed
opened 2026-10-31 01:13:05 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/issue-4369-empty-swift-vtable-class-name


📝 Commits (2)

  • ab400fa fix(native): reject empty Swift class vtable owner before slot insertion
  • 99914cb test(native): verify decoding continues for valid Swift vtable siblings after a malformed descriptor

📊 Changes

2 files changed (+59 additions, -0 deletions)

View changed files

📝 src/native/AppleDispatchMetadata.test.ts (+55 -0)
📝 src/native/AppleSwiftVtables.ts (+4 -0)

📄 Description

Summary

Fixes #4369.

When parsing Swift class vtable descriptors in decodeSwiftClassVtables, an empty class name string ("") was accepted and added into swift_dispatch_slots. Because swiftDispatchSlotSchema.owner requires z.string().min(1), whole-result validation in decodeAppleDispatchMetadata failed with a ZodError outside the per-descriptor recovery block, completely discarding all metadata and preventing valid sibling descriptors from being returned.

This PR adds an explicit validation check for non-empty owner names in src/native/AppleSwiftVtables.ts, allowing descriptor-level error recovery to record partial coverage and preserve valid sibling vtable slots.

Problem and expected behavior

  • Observed behavior: A Swift binary descriptor with an empty class name caused the whole dispatch metadata decode operation to throw a ZodError (too_small at swift_dispatch_slots[...].owner), losing valid sibling vtables.
  • Expected behavior: Malformed descriptors with empty class names should be caught by per-descriptor recovery, recorded as vtable_decode_failed with partial coverage, while valid sibling vtable descriptors are retained.

Change and scope

  • Added if (owner.length === 0) throw new RangeError("Swift class vtable descriptor class name is empty"); in src/native/AppleSwiftVtables.ts.
  • Added unit test in src/native/AppleDispatchMetadata.test.ts verifying that valid sibling vtables are preserved when a descriptor has an empty class name.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Swift vtable descriptor decoder (AppleSwiftVtables.ts)

  • Contribution scope fit and linked maintainer decision: Not applicable (pure native bug fix within existing contract)

  • CLI and MCP/tool-catalog contract: none

  • Provider, bridge, target-format, or platform compatibility: all platforms

  • Evidence, artifact, provenance, or reconstruction contract: none

  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none

  • Generated metadata impact: none

  • Read existing files or captured data.

  • Launch or attach to a process.

  • Inject instrumentation or run scripts/code.

  • Change process memory, registers, files, or configuration.

  • Contact network services.

  • Recover protected code or work around protections.

  • Documentation or usability only; no target interaction.

  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/native/AppleDispatchMetadata.test.ts
  • Base reproduction or other evidence: Synthetic Mach-O fixture from issue #4369 reproduced the ZodError on base revision and confirmed resolved with partial coverage and valid sibling preservation.
  • User-visible CLI/MCP output (if applicable): none
  • Remaining proof gaps: none

Validation performed

  • npm run test:local -- src/native/AppleDispatchMetadata.test.ts — 44 passed (100%)
  • npx turbo run typecheck lint --force — 2 tasks successful (0 errors)
  • node scripts/verify-module-boundaries.mjs — Checked 1979 source files (0 errors)
  • npm run format:check — All 3765 files formatted properly

Compatibility, safety, and release

  • Breaking changes or migration steps: None
  • Real Hopper/Ghidra, browser, or OS coverage: Platform-independent Mach-O static byte decoding
  • Package or release metadata impact: None
  • Security, privacy, process, or containment review: Pure metadata validation fix

Author readiness

Human owner: @kevinjosh10

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 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/4469 **Author:** [@kevinjosh10](https://github.com/kevinjosh10) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/issue-4369-empty-swift-vtable-class-name` --- ### 📝 Commits (2) - [`ab400fa`](https://github.com/morluto/rea/commit/ab400fa62fb4e579aa11668b454a14ae91dfa0de) fix(native): reject empty Swift class vtable owner before slot insertion - [`99914cb`](https://github.com/morluto/rea/commit/99914cb54d1a7388bc8fd30240195ddae6679ed5) test(native): verify decoding continues for valid Swift vtable siblings after a malformed descriptor ### 📊 Changes **2 files changed** (+59 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/native/AppleDispatchMetadata.test.ts` (+55 -0) 📝 `src/native/AppleSwiftVtables.ts` (+4 -0) </details> ### 📄 Description ## Summary Fixes #4369. When parsing Swift class vtable descriptors in `decodeSwiftClassVtables`, an empty class name string (`""`) was accepted and added into `swift_dispatch_slots`. Because `swiftDispatchSlotSchema.owner` requires `z.string().min(1)`, whole-result validation in `decodeAppleDispatchMetadata` failed with a `ZodError` outside the per-descriptor recovery block, completely discarding all metadata and preventing valid sibling descriptors from being returned. This PR adds an explicit validation check for non-empty owner names in `src/native/AppleSwiftVtables.ts`, allowing descriptor-level error recovery to record partial coverage and preserve valid sibling vtable slots. ## Problem and expected behavior - **Observed behavior**: A Swift binary descriptor with an empty class name caused the whole dispatch metadata decode operation to throw a `ZodError` (`too_small` at `swift_dispatch_slots[...].owner`), losing valid sibling vtables. - **Expected behavior**: Malformed descriptors with empty class names should be caught by per-descriptor recovery, recorded as `vtable_decode_failed` with partial coverage, while valid sibling vtable descriptors are retained. ## Change and scope - Added `if (owner.length === 0) throw new RangeError("Swift class vtable descriptor class name is empty");` in `src/native/AppleSwiftVtables.ts`. - Added unit test in `src/native/AppleDispatchMetadata.test.ts` verifying that valid sibling vtables are preserved when a descriptor has an empty class name. ## Contract and boundary impact - Semantic owner and earliest changed stage: Swift vtable descriptor decoder (`AppleSwiftVtables.ts`) - Contribution scope fit and linked maintainer decision: Not applicable (pure native bug fix within existing contract) - CLI and MCP/tool-catalog contract: none - Provider, bridge, target-format, or platform compatibility: all platforms - Evidence, artifact, provenance, or reconstruction contract: none - Target selection, authority, upstream behavior, and cleanup details (if applicable): none - Generated metadata impact: none - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `src/native/AppleDispatchMetadata.test.ts` - Base reproduction or other evidence: Synthetic Mach-O fixture from issue #4369 reproduced the ZodError on base revision and confirmed resolved with partial coverage and valid sibling preservation. - User-visible CLI/MCP output (if applicable): none - Remaining proof gaps: none ## Validation performed - `npm run test:local -- src/native/AppleDispatchMetadata.test.ts` — 44 passed (100%) - `npx turbo run typecheck lint --force` — 2 tasks successful (0 errors) - `node scripts/verify-module-boundaries.mjs` — Checked 1979 source files (0 errors) - `npm run format:check` — All 3765 files formatted properly ## Compatibility, safety, and release - Breaking changes or migration steps: None - Real Hopper/Ghidra, browser, or OS coverage: Platform-independent Mach-O static byte decoding - Package or release metadata impact: None - Security, privacy, process, or containment review: Pure metadata validation fix ## Author readiness Human owner: @kevinjosh10 - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:13:05 +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#6260
No description provided.