Repository navigation
fix(native): preserve literal line breaks in signing identifiers - #2107
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. |
There was a problem hiding this comment.
💡 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".
| 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"; |
There was a problem hiding this comment.
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 👍 / 👎.
8adddd1 to
cb04b8b
Compare
|
@greptileai review |
|
Summary
Preserve literal CRLF and trailing CR characters in signing identifiers, and exclude exact echoed paths before parsing
codesignrecords. Reproduced against upstream0d5033ad1with macOS/usr/bin/codesign; no related open issue was found.Problem and expected behavior
parseCodeSignaturenormalized every CRLF before removing the known executable path. For a file namedtool\r\nAuthority=FORGED\r\nIdentifier=FORGED, normalization prevented the exact path match. The fallback then interpreted the filename'sIdentifier=line as the signing identifier, returningFORGED\nIdentifier=tool\nAuthority=FORGED\nIdentifier=FORGED-<suffix>instead of the actualtool\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
codesigndiagnostic parser.inspect_signatureidentifier evidence./usr/bin/truewere signed in verification; inspected targets were not executed.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=4comparison 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:
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.e4d3e1399. The earlier CI failures in promptCompletion and packaged MCP smoke were corrected upstream by621cee192andfe4b94a66.Compatibility, safety, and release
codesignand 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.Review checklist