Repository navigation
fix(apple): validate build-version tool records within cmdsize - #1784
Conversation
Codex Review SummaryThis 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. |
N0zoM1z0
left a comment
There was a problem hiding this comment.
Reviewed the command-local bounds check and the compiled CLI regression. The new test fails on the affected base; after the fix it preserves valid/unknown platform evidence and reports missing records as malformed, including sibling-command and maximum-count controls. Reader tests passed 24/24, CLI rerun 10/10 and static checks passed; the initial existing-test timeout is recorded in the PR. Validation is offline Mach-O bytes on Linux, with no dyld/macOS runtime claim. No blocking findings; waiting for current-head CI before merge.
Summary
Report malformed Mach-O
LC_BUILD_VERSIONcommands when their declared tool records do not fit insidecmdsize. Fixes #1775.Problem and expected behavior
A 24-byte command with
ntools=1previously produced parsed platform evidence despite having no tool record. The reader must validate the command's complete structure before accepting its platform.Change and scope
Compare the declared count with the current command body's available 8-byte records, after checking its 24-byte header. This performs no count-driven allocation or iteration. Extra command padding remains accepted; unrelated load-command policies are unchanged.
Contract and boundary impact
MachoLoadCommandReader.trace-dylib-resolutionnow reports these images as malformed.Evidence and regression coverage
Tests added or updated: one compiled CLI scenario covers valid zero/one records, unknown platform, missing one/two records, maximum u32 count, and a truncated header. A sibling command and image trailer cannot satisfy a missing record.
Base reproduction: the added CLI test failed against unchanged production at
0bdc7a40a: expectedmalformed, receivedparsed; nine existing CLI tests passed.User-visible output: affected images expose
parse_status: "malformed", a reason namingLC_BUILD_VERSION, empty slices, and partial coverage. The CLI can still exit 0 while preserving those failures.Remaining proof gaps: Linux synthetic file workflows; no actual dyld execution or native macOS provider validation.
Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run test:focused -- src/artifacts/apple/MachoLoadCommandReader.test.ts tests/boundary/cli/dylibResolutionCli.test.ts— reader 24/24 and new CLI regression passed; one pre-existing CLI scenario hit its 30-second timeout.npm run test:focused -- tests/boundary/cli/dylibResolutionCli.test.ts— rerun passed 10/10 without changing timeouts.npm run check— typecheck, lint/module boundaries, formatting, Knip, metadata and architecture guards passed after moving the new test outside the existing describe block to respect its line limit.Compatibility, safety, and release
Review checklist