Repository navigation
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. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Static checks are red only on the pre-existing |
[Medium impact] The change affects artifact-integrity reports for a narrow class of unpacked PE files. The PR still needs to preserve the known mismatch when the optional companion read also fails to close. SummaryAdds a checked explanation when removing a PE Authenticode certificate table restores an unpacked ASAR companion's declared SHA-256.
Source review only; tests were not run. Whether another PR supersedes this one could not be checked because GitHub access was unavailable. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Hash unpacked companion] --> B{SHA-256 mismatch?}
B -->|Yes, PE within size limit| C[Read again and compare observed hash]
C -->|Same bytes| D[Remove certificate table and clear signing fields]
D --> E{Declared hash restored?}
E -->|Yes| F[Attach explanation and signer coverage]
E -->|No| G[Keep unexplained mismatch]
C -->|Different bytes| G
F --> H[Apply integrity policy; bytes remain untrusted]
G --> H
Reviews (3) · Last reviewed commit: "fix(artifacts): preserve signed companio..." · Reviewed by Greptile |
When an unpacked PE companion fails ASAR integrity only because Authenticode was applied after packing, record a verifiable signing_explanation on the SHA-256 contradiction and error details instead of an opaque untrusted mismatch. Bytes stay observed-untrusted; any other mutation remains an unexplained contradiction. Fixes morluto#7212
decodeName now returns start/end for signer matching; keep the empty RDNSequence distinction without requiring a span-free subject shape.
analyze_javascript_application on the signed-after-packing ASAR fixture can exceed the default 30s boundary timeout on slower hosts.
caf9a6b to
5a0b3b3
Compare
Summary
Fixes #7212
When an unpacked native addon is Authenticode-signed after
app.asaris packed, its companion bytes no longer match the ASAR header hash. Before this change, REA reported that case the same way as a swapped binary: an unexplainedartifact_integrity_mismatch/ "observed bytes are untrusted". REA now checks whether removing the Authenticode certificate table restores the declared SHA-256. If it does, REA adds a verifiablesigning_explanationto the contradiction.Problem and expected behavior
*.node) whose companion was signed after packing. The file grows by exactly the certificate table, and the hash disagrees withintegrity.hash.IMAGE_DIRECTORY_ENTRY_SECURITY(removing the table range, zeroing the security directory and PE checksum) reproduces the declared SHA-256. The record should say so, and the bytes should stay observed and untrusted.Change and scope
src/native/pe/PeUnsignedDigest.ts(new) rebuilds the pre-signing PE bytes from the parsed PE headers, compares their SHA-256 with the claim, and reads signer subjects through the existingparsePeCertificates. This second read happens only for an unpacked SHA-256 PE entry that already mismatched, and is bounded to 64 MiB.scanReader(the producer) attaches the explanation once, both to the strict-policyArtifactReaderFailuredetails and to the pending contradiction.signedAfterPackingExplanationSchemalives indomain/artifactIntegrity.tsand is reused byartifactGraph(SHA-256 contradiction variant only) and the error contract. It is no longer duplicated inline.hash_statusstaysmismatched,truststaysobserved-untrusted, and equivalence is unchanged.Contribution scope: not applicable (read-only fix within the existing artifact-integrity boundary).
Contract and boundary impact
Semantic owner and earliest changed stage:
src/artifacts/inventory/scanReader.tsdigest step. Consumers arescanCanonical,JavaScriptArtifactGraphBuilder,artifactInspection, andanalysisErrorPresentation.Contribution scope fit and linked maintainer decision: not applicable.
CLI and MCP/tool-catalog contract: additive optional
signing_explanationon SHA-256integrity_contradictionsentries and onartifact_integrity_mismatchdetails.docs/error-contract.schema.jsonwas regenerated.Provider, bridge, target-format, or platform compatibility: PE Authenticode only.
Evidence, artifact, provenance, or reconstruction contract: additive. Declared and observed digests and the trust level are unchanged.
Target selection, authority, upstream behavior, and cleanup details: not applicable.
Generated metadata, package, or installation impact: none beyond the regenerated error schema.
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 added or updated:
src/native/pe/PeUnsignedDigest.test.ts: PE32 and PE32+ restore the digest. A content mutation, a missing security directory, and an extra appended trailer all stay unexplained.tests/boundary/filesystem/asarSignedAfterPacking.test.ts: a real@electron/asarpackage whose unpacked addon is signed after packing. Covers the strict-failure projection details,record-and-continuecontradiction and limitation, and the application limitation. An ordinary stripped-addon mismatch stays unexplained.Base reproduction: on
main, the same fixture produces only the generic contradiction with nosigning_explanation, so the new assertions fail.Remaining proof gaps: not run against the Razer App Engine sample from the issue. Only synthetic PE fixtures signed with the repo's PKCS#7 fixture were used.
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 typecheck: passednpm run test:focused -- src/native/pe/PeUnsignedDigest.test.ts tests/boundary/filesystem/asarSignedAfterPacking.test.ts tests/boundary/filesystem/javascriptIntegrityPolicy.test.ts tests/boundary/cli/javascriptIntegrityPolicyCli.test.ts tests/boundary/mcp/asarUnpackedExtractionMcp.test.ts tests/boundary/mcp/artifactMcp.test.ts: 36 passednpm run test:focused -- tests/boundary/mcp/electronMcp.test.ts tests/boundary/mcp/javascriptNativeHandoffIdentity.test.ts src/artifacts/DfuSeArtifactReader.test.ts(with the new tests): 25 passednpm run docs:checkandgenerate-error-schema.mjs --check: passednpm run verify:module-boundaries: passednpm run check:fast: typecheck passed. Lint failed with 1 error in the untouchedtests/acceptance/webSourceLocationCli.test.ts(max-lines-per-function), which is already onmain.Compatibility, safety, and release
Review follow-up validation (caf9a6b)
signer_subjects_completereports incomplete or ambiguous decoding; this does not verify a signature.npm run check:fast,npm run format:check, andnpm run docs:checkpassed. The generated error schema also passed Ajv 2020-12 meta-schema validation. The earlier lint failure below describes the earlier run; the latestcheck:fastpassed.Author readiness
Human owner: @BeqaKs
Before merge
type(scope): outcome.