Repository navigation
fix(il2cpp): report a magic without a complete version as a truncated header - #5726
Closed
8rulerstar wants to merge 1 commit into
Closed
8rulerstar wants to merge 1 commit into
8rulerstar wants to merge 1 commit into
Conversation
… header A 4 to 7 byte file that starts with the IL2CPP magic was rejected as unrecognized-magic, an unsupported target, although only its version field was missing. Classify it as truncated-header (an input error with an invalid_format issue) without assuming a version or header size. Files shorter than four bytes or with another magic keep unrecognized-magic. Fixes morluto#5403
Contributor
Author
2 tasks done
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.
Summary
Thank you @coygeek for the clear report and the reproducible CLI script.
Fixes #5403
A 4 to 7 byte file that starts with the complete IL2CPP magic
0xFAB11BAFwas rejected asunrecognized-magic(an unsupported target), although the magic is present and only the version field is missing. It is now an input error (invalid_request) with aninvalid_formatissue namingtruncated-header, asdocs/il2cpp-metadata.mddescribes for a file shorter than its header.Problem and expected behavior
readHeaderinsrc/il2cpp/Il2cppMetadataFile.tscombined two checks:bytes.length < 8 || magic !== IL2CPP_METADATA_MAGIC. A recognized magic followed by a partial version therefore took the wrong-magic branch. The documented contract reservesunrecognized-magicfor a magic other than0xFAB11BAF.Change and scope
null) and keepunrecognized-magic, because they cannot establish metadata.truncated-headerwithout assuming a version or header size:the file has N bytes, ending inside the 4-byte metadata version field; the version and header size are unknown.truncated-header(a corrupt reason) toAnalysisInputErrorwithinvalid_formatand keeps partial source Evidence, so no provider change was needed.truncated-headernow mentions the incomplete version field.Not included: any change to wrong-magic, unsupported-version or version-specific header-size handling.
Contract and boundary impact
Semantic owner and earliest changed stage:
readHeaderinsrc/il2cpp/Il2cppMetadataFile.ts, header classification.Contribution scope fit and linked maintainer decision: ordinary fix within the existing IL2CPP metadata reader; not applicable.
CLI and MCP/tool-catalog contract: no schema change. For 4 to 7 byte magic-prefixed files,
codechanges fromunsupported_targettoinvalid_requestwithdetails.issues[0].reason: invalid_format.Provider, bridge, target-format, or platform compatibility: none.
Evidence, artifact, provenance, or reconstruction contract: partial source Evidence (path, SHA-256, byte length,
not-returned-as-complete) is retained as before.Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
Generated metadata, package, or installation 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/boundary/il2cpp/il2cppMetadataFile.test.ts: every length 4, 5, 6, 7 with the magic istruncated-header(corrupt) and names its byte count; at 8 bytes the version decides (39 and 27 give their owntruncated-headerwith 380 and 256 byte headers, 30 givesunsupported-version); a 3-byte magic prefix and a one-byte-off magic stayunrecognized-magic.tests/boundary/il2cpp/il2cppMetadataProvider.test.ts: a 7-byte file returnsAnalysisInputErrorwith oneinvalid_formatissue and partial source Evidence.The issue's
v27-eight.datcontrol is now a supported version on main, so a version 30 file was used as the complete unsupported-version control.tools/callfor the same files returns the sameinvalid_request/invalid_formatresult as the CLI.For evidence-bearing changes:
Validation performed
npm run build:cached: passednpm run test:focused -- tests/boundary/il2cpp/il2cppMetadataFile.test.ts tests/boundary/il2cpp/il2cppMetadataProvider.test.ts: 66 passed (base revision: 2 failed, 64 passed)npm run check:fast(typecheck and lint): passednpm run format:check: passednpm run metadata:check: passednpm run docs:check: passedCompatibility, safety, and release
unsupported_targetfor these malformed 4 to 7 byte files now receiveinvalid_request, as documented.Author readiness
Human owner: @8rulerstar
Before merge
type(scope): outcome.Thanks again for the report.