Validate replacement block signatures#47
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 11, 2026, 7:35 AM ET / 11:35 UTC. Summary Reproducibility: yes. Source inspection shows current master calls imp_implementationWithBlock without comparing block and method encodings, matching the PR's crash scenario; I did not execute XCTest because this review is read-only. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the signature validation once maintainers are satisfied the intentional fail-fast behavior and public error case are acceptable for the next release. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current master calls imp_implementationWithBlock without comparing block and method encodings, matching the PR's crash scenario; I did not execute XCTest because this review is read-only. Is this the best way to solve the issue? Yes. The proposed fix is narrow: read the block ABI signature, compare return and argument encodings against the Method, and reject before creating an IMP; the remaining judgment is compatibility/versioning. AGENTS.md: not found in the target repository. Codex review notes: model internal, reasoning high; reviewed against a7e1b57bedf5. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
Summary
InterposeErrorRoot cause
InterposeKit trusted the generic
HookSignaturesupplied by the caller. The Objective-C runtime therefore accepted blocks with a calling convention that did not match the target method.On unmodified
master, an object hook replaced a method returning an object with a block returningInt. Hook construction succeeded, then invoking the method on macOS 26.5 with Xcode 26.6 terminated XCTest with signal 11.The fix reads the Objective-C signature embedded in the block ABI and compares it with the target
Methodbefore callingimp_implementationWithBlock.Verification
swift testswift test -c releaseYAMS_DEFAULT_ENCODING=UTF16YAMS_DEFAULT_ENCODING=UTF8$autoreview: cleanCloses #27