Repository navigation
fix(errors)!: refuse corrupt managed, IL2CPP and universal Mach-O bytes as a malformed target - #14224
Merged
Merged
Conversation
…es as a malformed target Three formats had their own error mappers that still reported a selected file's corrupt bytes as an invalid_format path issue (invalid_request): managedInspectionInputFailure, Il2cppMetadataProvider and the Mach-O slice selection mappers. Each now projects its format owner's own failure through AnalysisMalformedTargetError at the path of the file whose bytes are at fault. - Managed PE/CLI: a broken rule is a malformed pe-cli target with the reader's scope and offset; unsupported-metadata and unsupported-signature are unsupported targets; resource limits stay with their producer. - Universal Mach-O: the container reader raises a ParseFailure once (malformed, truncated where it measured the end, unsupported from the container's own category), and requireSelectedNativeImage(FromReader) project it at the universal file's path. An unknown or ambiguous architecture stays invalid_request on the architecture field. SliceSelectionInput.pathField is removed. - IL2CPP: metadata and binary format failures each name their own file. A binary that parses but does not link to the metadata is a link conflict: invalid_request with invalid_value issues on both path and binary_path, no input-contract recovery, and the partial observation keeps both file identities. Neither file is called malformed. BREAKING CHANGE: inspect_managed_artifact, inspect_managed_members, inspect_managed_native_boundaries, compare_managed_members, inspect_il2cpp_metadata, inspect_go_binary, inspect_rust_binary, inspect_dwarf_units and inspect_native_initializers report corrupt or truncated target bytes as code unsupported_target with details.path, format, format_failure and reason instead of invalid_request with an invalid_format issue. IL2CPP link conflicts list both path and binary_path with reason invalid_value instead of one invalid_format binary_path issue.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Contributor
[Medium impact] The PR appears safe to merge; no blocking issue was found. SummaryThis PR reports corrupt managed, IL2CPP, and universal Mach-O bytes as target failures rather than bad path arguments.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
Reader[Format reader] --> Failure{Typed failure}
Failure -->|Malformed or truncated| Target[Target refusal at the affected file path]
Failure -->|Unsupported form| Unsupported[Unsupported target]
Failure -->|Architecture selection| Request[Request error on architecture]
Failure -->|IL2CPP link conflict| Pair[Request error naming both files]
Reviews (2) · Last reviewed commit: "Merge main into fix/malformed-target-for..." · Reviewed by Greptile |
morluto
enabled auto-merge (squash)
November 24, 2026 01:16
morluto
disabled auto-merge
November 24, 2026 01:20
# Conflicts: # tests/acceptance/stableArtifactParserFailureCli.test.ts
This was referenced Nov 24, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #14195, which left three formats with their own error mappers that still reported a selected file's corrupt bytes as an
invalid_formatpath issue (invalid_request).Root cause
managedInspectionInputFailure,Il2cppMetadataProvider.failureForPrimaryand the Mach-O slice selection mappers (requireSelectedNativeImage,requireSelectedNativeImageFromReader) each builtAnalysisInputErrorwithreason: "invalid_format"on the field that selected the file. The arguments were valid; the bytes were the problem. The Mach-O container reader also flattened every failure to{ kind: "malformed", message }, losing truncation and its ownunsupportedcategory, so a mapper could not project the real class without reading message text.Structural fix
machoImageSelection.ts): the container failure is now{ kind: "format", message, failure: ParseFailure }, raised once.truncatedonly where this reader measured the end (headerneeds-data, a slice prefix with no CPU identity);unsupportedfrom the container reader's own range category (alignment exponent > 52);malformedotherwise, with the slice's offset.selectionErrorinmachoSliceSelection.tsprojects it asAnalysisMalformedTargetError/AnalysisUnsupportedTargetErrorat the universal file's path. Refused selections stayinvalid_requeston the architecture field.SliceSelectionInput.pathFieldis removed (nothing names a path field any more). Consumers updated:Il2cppBinaryImage,AppleDispatchMetadata,readBinaryContainer, the test fixture.managedReaderFailure.ts):managedInspectionTargetFailureprojects the reader's issue code: rule violations → malformedpe-clitarget withfield(the reader's scope) andoffset;unsupported-metadata/unsupported-signature→ unsupported target;resource-limit→ left to its producer. The unusedinputFieldparameter is removed.Il2cppBinaryFormat.ts): the binary reasons are split intomalformed: ["malformed-container"]andlinkConflict: [...]. The provider projects metadata and binary format failures throughparseFailureAnalysisErrorat each file's own path, and a link conflict throughlinkConflict.Decision tables
Managed PE/CLI (single input per call; comparison runs one inspection per side)
unsupported_target,format_failure: malformed,format: pe-clidetails.path= that file;details.field= reader scopedetails.path= that side's fileargument_observations.unsupported-metadata,unsupported-signatureunsupported_targetdetails.pathresource-limitUniversal Mach-O slice selection
unsupported_target,malformed,format: machodetails.pathunsupported_target,truncateddetails.path,details.offset= sliceunsupported_target,malformeddetails.path,details.offset= sliceunsupported_targetdetails.pathinvalid_request,invalid_valuearchitecture/binary_architectureIL2CPP (
path+ optionalbinary_path)unsupported_target,malformed/truncated,format: il2cpp-metadatadetails.path= metadataunrecognized-magic,unsupported-version(not 24/27/29/31/39)unsupported_targetdetails.path= metadatamalformed-container(binary or its universal container)unsupported_target,malformed/truncated,format: il2cpp-binaryormachodetails.path= binary*-not-found,ambiguous-*,invalid-method-pointer,invalid-method-token,invalid-typeinvalid_request,invalid_valueon bothpathandbinary_path(--binaryin the CLI), noinspect_input_contractrecoverybinary_pathinvalid_requestbinary_architectureDesign notes
unsupportedclass: IL2CPP versions outside 24/27/29/31/39 and unknown magic, managedunsupported-metadata/unsupported-signature, a Mach-O FAT alignment the container reader rejects as unsupported. Mach-O CPU types REA cannot decode in a selection remain the caller's selection (architecture_not_present), never malformed. IL2CPP link failures that might be an unknown registration layout are reported as a conflict, not as corrupt bytes.details.path: metadata versusbinary_path, and the universal file (with the slice'soffset) for slice faults. IL2CPP keeps both identities (path, SHA-256, bytes) in the partial observation. When both files parse but disagree, the refusal lists both fields and blames neither.AnalysisErrorpassthrough, thesignal.abortedcheck,ArtifactReaderFailurehandling), and the existing cancellation andartifact_changedtests still pass. Malformed and unsupported refusals are not retryable and offer "choose another target". Selection errors keep "fix the request". The link conflict's remediation names the pair.code, the Mach-OParseFailurekind and the container'scategory, and the IL2CPP reason category list. Nothing is derived from message text. Where an owner does not establish truncation (for example the FAT table "is truncated"malformedreason frommachoContainer), the projection keeps the owner'smalformed.code, markedfix(errors)!:with aBREAKING CHANGE:footer listing the operations. No detail fields are renamed. The new fields are the additiveformat_failure,format,fieldandoffsetfrom fix(errors): refuse malformed target bytes as a target, not invalid input #14195's projection.Tests
managedReaderFailure.test.ts(new: malformed with field and offset, offset omitted when unknown, both unsupported codes, limit and foreign causes).MachoSliceSelection.test.ts: the owner failure shape (malformed, truncated slice, unsupported alignment), plus both public mappers (buffer and reader) for unknown slice →architecture, truncated slice, header/table disagreement and unsupported alignment.il2cppBinaryFile.test.ts: overlap, header disagreement and subtype mismatch as malformed binary targets; a new truncated slice case and an unknown-slice control.il2cppMetadataProvider.test.ts: truncated metadata, corrupt binary container, corrupt metadata found while linking, and the valid-but-inconsistent pair (both issues,invalid_request, no recovery, both identities).stableArtifactParserFailureCligains the single-input cases: 3 managed commands (section past EOF) andinspect-go-binary,inspect-rust-binary,inspect-dwarf-units,inspect-native-initializers(overlapping universal Mach-O). The managed per-command copy inmanagedCliOutputis removed. Newil2cppMetadataCliCLI+MCP test: corrupt metadata names the metadata, a truncated universal slice names the binary, and an inconsistent pair lists both fields.universalSliceMcp,managedMemberComparisonCli(each side now gets its own malformed file, so the path names the side),il2cppStructuralExtentsCliand existingil2cppMetadataCliexpectations are updated.viewJSON), architecture selection errors, cancellation,artifact_changedand identity coverage.unsupported-signaturefall through to malformed fails the managed owner test, and disabling the link-conflict branch fails two IL2CPP provider tests. Both pass again after revert.Validation
npx vitest runon 67 affected source and boundary files (Mach-O, IL2CPP, managed, Go, Rust, DWARF, initializers, Apple dispatch, MCP universal slice): 2270 passed, 20 skipped. 43 managed source/boundary/composition files: 914 passed.tests/boundary/cli/dylibResolutionCli.test.tsneeds the compiled CLI (dist/) and was not run locally.createCli()throughserveInProcessCli) confirmed each new acceptance expectation: managedpe-climalformed withfield/offset, four native commands on an overlapping universal file (macho,file-snapshot-hashretained), an unknown slice stayinginvalid_requestonarchitecture, and the three IL2CPP pair cases (including CLI fieldbinary).tscover the changed sources and tests found no errors (only pre-existingfridatyping errors outside this change).oxlintreported no errors,oxfmtran on every changed file, andscripts/verify/architecture-guards.mjspassed.tests/acceptance/*suites andmanagedMemberComparisonCli(they needdist/), the full typecheck, anddocs:check.docs/user-visible-errors.csvis unchanged: no error tag or classification changed.Docs
docs/il2cpp-metadata.md(failure categories malformed/conflict/unsupported, damaged-metadata projection, FAT table wording),docs/guides/managed/managed-code-analysis.md,docs/guides/native/go-binaries.md(damaged universal file).Real-provider verification scope
None needed. All three are local static parsers.
Remaining cleanup
managedMetadataFailureStatusstill reportsunsupported-signatureasmalformedin inventory status. The refusal path now calls it unsupported. Aligning the inventory status changes result payloads, so it is left for a separate change.invalid-method-tokencovers both a metadata-internal duplicate MethodDef row and a cross-file token range. Splitting it at the producer would let the duplicate case blame the metadata. It is reported as a conflict for now, the conservative choice.machoContainerreports "FAT header/table is truncated" asmalformed; it could carry a typed truncation fact. Not changed here because that reader is shared with the artifact reader producers being reworked on another branch.