Skip to content

fix(native): preserve app bundle executable filename whitespace - #767

Closed
rudycelekli wants to merge 1 commit into
morluto:mainfrom
rudycelekli:fix/rea-app-executable-whitespace-20261006
Closed

rudycelekli wants to merge 1 commit into
morluto:mainfrom
rudycelekli:fix/rea-app-executable-whitespace-20261006

Conversation

@rudycelekli

Copy link
Copy Markdown

Summary

Preserve the actual CFBundleExecutable value in XML and binary app plists. XML string whitespace is part of the declared filename. Native plutil -n removes its added raw-output newline while preserving the binary plist value. Existing executable-name and bundle containment checks remain intact.

Native reproduction and verification

Signed DCO head ef466bb5cde8c6d6c95196592de65ec0937592fc on current 4.1.0 release main 9622b4b4cf0b2eb92305afd52fd67e932d57c753. Fresh authored-feedback and all-open file inventories have no actionable feedback or changed-file overlap for this patch; unrelated hosted cancellation is tracked in its owning lane.

  • Actual Clang builds benign Mach-O program files. XML and native-plutil-converted binary app plists declare the existing filename App; native plutil independently preserves that value.
  • Before: public compiled inspect-macho fails to resolve both surrounding-space program filenames; ordinary App controls pass for both plist forms.
  • After: four XML/binary ordinary/spaced bundle observations through the compiled CLI and a separate real stdio MCP subprocess exactly match direct native inspection of their actual program files.
  • Focused baseline: 4 failures, 13 controls pass. Final existing binary target module: 17 pass, including actual macOS plutil binary conversions, leading/trailing spaces and trailing tab.
  • npm run check: all 5 tasks pass, 125 existing warnings and zero errors; none concern the changed files. check:fast, build:cached, SSH signature verification, DCO and diff checks pass. All evidence rerun on the final release base with reused compatible pinned dependencies.

No schema, setup or distribution change. This verifies native macOS file resolution and inspection; no Hopper, Ghidra, IDA, Windows, GUI or target execution claim. Hosted checks remain separate.

AI-assisted implementation and independent source review. Fixes #765.

@morluto

morluto commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Reviewed: preserving CFBundleExecutable whitespace (drop .trim(), add plutil -n) is correct — XML string whitespace is data and -n suppresses only the tool-added newline. isSafeExecutableName already allows spaces/tabs, containment via realpath+isPathWithinRoot unchanged. XML + darwin-native binary-plist cases cover leading/trailing/both. APPROVE. Non-blocking robustness: consider .stdout.replace(/\r?\n$/, '') instead of bare .stdout to be safe across plutil versions.

@morluto

morluto commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Review — APPROVE

Fixes #765.

Summary

parseXmlPlistExecutable stops .trim(); readBinaryPlistExecutable adds plutil -n and stops .trim(), preserving leading/trailing spaces and tabs in CFBundleExecutable.

Verification

  • Correct: XML string whitespace is data; plutil -n suppresses only the tool-added newline.
  • isSafeExecutableName already allows spaces/tabs (rejects only "", ., .., \0, /\); containment via realpath + isPathWithinRoot unchanged.
  • Tests: tests/boundary/filesystem/binaryTarget.test.ts XML cases (" leading" / "trailing " / " both ") plus darwin-only native binary-plist cases (Ordinary / " App " / "Tab\t").
  • CI: all SUCCESS, including Real Apple artifact CLI/MCP E2E.

Suggestion (non-blocking)

  • src/application/BinaryTargetResolver.ts:277-287: verbatim .stdout relies entirely on -n to suppress the added newline. More robust across plutil versions while still preserving spaces/tabs:
    .stdout.replace(/\r?\n$/, "")
    Current code works on macOS 14 CI, so this is a COMMENT, not a blocker.

@rudycelekli

Copy link
Copy Markdown
Author

I checked the terminal-newline suggestion with an actual native binary plist and an existing benign Clang executable whose filename is Terminal\n (the final newline is part of the filename). plutil -extract CFBundleExecutable raw -n -o - returns the exact value with hex 5465726d696e616c0a, and the production bundle resolver successfully opens that exact program path.

Applying .replace(/\r?\n$/, "") changes it to Terminal, which does not exist in the bundle. Since -n suppresses the tool-added newline, stripping another terminal newline would remove caller data. I have retained verbatim stdout; the native XML/binary-plist and containment controls remain unchanged.

Comment thread src/application/BinaryTargetResolver.ts Resolved
@morluto

morluto commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Superseded by #815, which integrated this change and has now merged (3af3811). Thanks @rudycelekli for the fix and the thorough verification — much appreciated!

@morluto morluto closed this Oct 7, 2026
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App bundle executable filename whitespace is lost during plist decoding

2 participants