Skip to content

fix(native): preserve literal line breaks in signing identifiers - #2107

Merged
morluto merged 2 commits into
morluto:mainfrom
1NormalGuy:fix/codesign-literal-line-breaks
Oct 13, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
1NormalGuy:fix/codesign-literal-line-breaks

Conversation

@1NormalGuy

@1NormalGuy 1NormalGuy commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Preserve literal CRLF and trailing CR characters in signing identifiers, and exclude exact echoed paths before parsing codesign records. Reproduced against upstream 0d5033ad1 with macOS /usr/bin/codesign; no related open issue was found.

Problem and expected behavior

parseCodeSignature normalized every CRLF before removing the known executable path. For a file named tool\r\nAuthority=FORGED\r\nIdentifier=FORGED, normalization prevented the exact path match. The fallback then interpreted the filename's Identifier= line as the signing identifier, returning FORGED\nIdentifier=tool\nAuthority=FORGED\nIdentifier=FORGED-<suffix> instead of the actual tool\r\nAuthority=FORGED\r\nIdentifier=FORGED-<suffix>.

Even without an echoed path, the same normalization changed legitimate identifier bytes. Signature identity must retain the producer's exact value, and known pathname bytes must not become diagnostic fields.

Change and scope

Frame the exact path first, determine its record separator, and use that separator to frame the identifier. If no supplied path matches, infer the separator from the producer-owned Format record, preserving literal CRLF and trailing CR inside the identifier. Split only the remaining diagnostic fields into lines. This removes the lossy whole-output normalization at its owning parser; the signature provider already supplies both snapshot and canonical paths, so callers need no additional interpretation.

Contract and boundary impact

  • Semantic owner and earliest changed stage: native codesign diagnostic parser.
  • CLI and MCP/tool-catalog contract: unchanged schemas; corrected inspect_signature identifier evidence.
  • Provider, bridge, target-format, or platform compatibility: macOS signature observations; both existing LF/CRLF record representations remain covered.
  • Evidence, artifact, provenance, or reconstruction contract: retain literal signing identity; snapshot/digest binding and raw captures unchanged.
  • Process execution, authorization, cleanup, or containment impact: none. Only disposable copies of /usr/bin/true were signed in verification; inspected targets were not executed.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Extended the real CLI regression to ad hoc sign and inspect filenames containing LF and CRLF plus apparent signature fields. Existing unsigned-message, entitlement and designated-requirement filename cases still run.

  • Parser cases distinguish embedded CRLF/trailing CR from both LF and CRLF record separators, including a path containing a fake identifier and an identifier containing a fake format line.

  • Before the fix, the focused two-file regression run had 4 failures and 35 passes. Afterward, all four affected/regression suites passed.

  • A separate real codesign -d --verbose=4 comparison confirmed the CLI's fixed identifier exactly matches the producer value.

  • 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

Node 24.18.0 / npm 11.16.0, macOS:

npm run test:focused -- \
  tests/boundary/cli/nativeSignatureCli.test.ts \
  tests/boundary/providers/native/nativeProvider.test.ts \
  tests/boundary/providers/native/nativeInventory.golden.test.ts \
  tests/boundary/providers/native/nativeSignatureTargetBinding.test.ts \
  tests/boundary/mcp/promptCompletion.test.ts
  • 90 tests passed, including real codesign, compiled CLI, and ancestor-directory-swap target binding.
  • npm run check — passed: typecheck, lint (0 errors), formatting, module boundaries and architecture guards.
  • npm run verify:package — passed on macOS arm64, including packaged MCP cold/warm prompt completion. Local loopback addresses were excluded from this host's HTTP proxy.
  • git diff --check — passed.
  • Rebased onto upstream e4d3e1399. The earlier CI failures in promptCompletion and packaged MCP smoke were corrected upstream by 621cee192 and fe4b94a66.
  • The review regression (pathless/unmatched CRLF output) failed in 3 added cases before the follow-up fix; all now pass.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real provider/OS coverage: macOS system codesign and compiled CLI verified. This change does not involve Hopper/Ghidra/browser. A separate real stdio MCP signature run was not performed; its shared provider path is unchanged.
  • Package or release metadata impact: none.
  • Security/privacy review: preserve exact identity and keep caller-selected filename text outside diagnostic fields; target snapshot ownership is unchanged.

Review checklist

  • Concrete problem reproduced with the actual producer; focused Conventional Commit title.
  • No related issue; found while reviewing the parsing boundary.
  • Observable regression and existing target-binding/failure coverage verified.
  • No public schema or generated metadata changes required.
  • Representative before/after output included.
  • Final diff checked for secrets, unrelated cleanup and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T14:58:09.694457Z cb04b8b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8adddd1931

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/native/parsers/codesign.ts Outdated
else if (text.startsWith("Executable=")) {
// Frame the exact source path before interpreting record separators. A CRLF
// inside that path or the signing identifier is payload, not a line ending.
let newline = "\n";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Detect CRLF in the pathless parser case

When parseCodeSignature is used with its default empty executablePaths (or no candidate matches) on a CRLF-formatted diagnostic, this remains \n; the later Format= search consequently matches only the LF suffix of \r\n and includes the separator's CR in the source identity (Identifier=foo\r\nFormat=... returns foo\r). That input was normalized to foo before this change, and the field parser still explicitly accepts CRLF, so frame the separator in the unmatched branch as well without stripping CR payload.

AGENTS.md reference: AGENTS.md:L25-L25

Useful? React with 👍 / 👎.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issue was found.

Summary

Preserves literal line breaks in signing identifiers without treating echoed filenames as diagnostic fields.

  • Signature inspection preserves line breaks and ignores echoed path text.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Raw codesign diagnostics"] --> B["Remove exact echoed path"]
  B --> C["Determine record separator"]
  C --> D["Keep identifier bytes through the Format boundary"]
  D --> E["Split remaining diagnostic fields"]
  E --> F["Return signature evidence"]
Loading

Reviews (1) · Last reviewed commit: "fix(native): infer codesign framing with..." · Reviewed by Greptile

@morluto
morluto merged commit ec3db37 into morluto:main Oct 13, 2026
3 checks passed
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@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.

2 participants