[PR #6813] [CLOSED] fix(apk): compare v1 with the lowest block scheme that has signers #7418

Closed
opened 2026-11-01 21:47:43 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6813
Author: @pablodiazjorge
Created: 10/23/2026
Status: ❌ Closed

Base: main ← Head: fix/apk-v1-lowest-signed-scheme


📝 Commits (1)

  • b18787c fix(apk): compare v1 with the lowest block scheme that has signers

📊 Changes

2 files changed (+21 additions, -1 deletions)

View changed files

📝 src/domain/apkSignature/apkSignatureReport.test.ts (+15 -0)
📝 src/domain/apkSignature/apkSignatureReport.ts (+6 -1)

📄 Description

Summary

Fixes #6440. When a present v2 block declares no signers, inspect-apk-signature returned posture.v1_signers_match_block_signers: null even if v1 and v3 name the same certificate. The posture derivation passed the first present block scheme to the v1 comparison, so an empty v2 hid the v3 signer. It now passes the lowest present scheme that has signers, which is the rule the schema comment and docs/apk-signature.md already state.

Thanks to @coygeek for the report and the matching and mismatching controls.

Problem and expected behavior

deriveApkPosture (src/domain/apkSignature/apkSignatureReport.ts) called v1MatchesBlockSigners(input.v1SignerFingerprints, present[0]). present keeps every present scheme in order, including one whose signer sequence is empty, and v1MatchesBlockSigners returns null as soon as the scheme it receives has no signers. The function's own comment, the schema comment and the documented rule say v1 is compared with the lowest block scheme that has signers.

Expected, as the issue asks: with an empty v2 and a v3 signer, true when v1 and v3 name the same certificate and false when they differ.

Change and scope

  • src/domain/apkSignature/apkSignatureReport.ts: the v1 comparison receives present.find(({ signers }) => signers.length > 0) instead of present[0]. When no present scheme has signers it still receives undefined and stays null, as before.
  • Not included: schemes_agree_on_signer and self_consistent, which the issue keeps out of scope, and whether an empty v2 signer sequence should be reported as malformed.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the signing posture derivation (deriveApkPosture) in the APK signature domain.
  • Contribution scope fit and linked maintainer decision: ordinary fix within existing boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: posture.v1_signers_match_block_signers becomes true or false instead of null for inputs with a present but signer-less lower scheme; no schema or catalog change.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: one derived posture value is now computed for these inputs; observed scheme facts and fingerprints are unchanged.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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/domain/apkSignature/apkSignatureReport.test.ts, "skips a present block scheme that declares no signers" in "deriveApkPosture v1 comparison": v1, v2 present with no signers and a v3 signer; asserts true when v1 and v3 name the same certificate and false when they differ. It calls deriveApkPosture directly because the suite's v1() helper derives v2Present from the signer count.
  • Base reproduction or other evidence: on the base revision the new test fails with expected null to be true.
  • User-visible CLI/MCP output (if applicable): not captured; the change is one derived posture field.
  • Remaining proof gaps: the issue's CLI reproduction with synthetic APKs was not rerun here; the existing CLI and MCP APK signature suites below pass.

For evidence-bearing changes:

  • 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

Windows 11 x64 10.0.26300, Node 24.22.1, on main e2efd10b7:

  • npx vitest run src/domain/apkSignature/apkSignatureReport.test.ts: 18 passed; on the base the new test fails as above.
  • npx vitest run src/domain/apkSignature src/apkSignature tests/boundary/apkSignatureV1Cli.test.ts tests/boundary/apkSignatureViewsCliMcp.test.ts: 10 files, 138 tests passed.
  • npm run check:fast: typecheck and lint pass.
  • npx oxfmt --check on the changed files: pass.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; static APK inspection only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; no cryptographic verification is added or claimed.

Author readiness

Human owner: @pablodiazjorge

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/6813 **Author:** [@pablodiazjorge](https://github.com/pablodiazjorge) **Created:** 10/23/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/apk-v1-lowest-signed-scheme` --- ### 📝 Commits (1) - [`b18787c`](https://github.com/morluto/rea/commit/b18787c5bff5493f3cbec36e149a36b8f061610a) fix(apk): compare v1 with the lowest block scheme that has signers ### 📊 Changes **2 files changed** (+21 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/apkSignature/apkSignatureReport.test.ts` (+15 -0) 📝 `src/domain/apkSignature/apkSignatureReport.ts` (+6 -1) </details> ### 📄 Description ## Summary Fixes #6440. When a present v2 block declares no signers, `inspect-apk-signature` returned `posture.v1_signers_match_block_signers: null` even if v1 and v3 name the same certificate. The posture derivation passed the first present block scheme to the v1 comparison, so an empty v2 hid the v3 signer. It now passes the lowest present scheme that has signers, which is the rule the schema comment and `docs/apk-signature.md` already state. Thanks to @coygeek for the report and the matching and mismatching controls. ## Problem and expected behavior `deriveApkPosture` (`src/domain/apkSignature/apkSignatureReport.ts`) called `v1MatchesBlockSigners(input.v1SignerFingerprints, present[0])`. `present` keeps every present scheme in order, including one whose signer sequence is empty, and `v1MatchesBlockSigners` returns `null` as soon as the scheme it receives has no signers. The function's own comment, the schema comment and the documented rule say v1 is compared with the lowest block scheme that has signers. Expected, as the issue asks: with an empty v2 and a v3 signer, `true` when v1 and v3 name the same certificate and `false` when they differ. ## Change and scope - `src/domain/apkSignature/apkSignatureReport.ts`: the v1 comparison receives `present.find(({ signers }) => signers.length > 0)` instead of `present[0]`. When no present scheme has signers it still receives `undefined` and stays `null`, as before. - Not included: `schemes_agree_on_signer` and `self_consistent`, which the issue keeps out of scope, and whether an empty v2 signer sequence should be reported as malformed. ## Contract and boundary impact <!-- Short answers are welcome. Complete applicable lines; mark unresolved facts as "unknown". Use "none" or "not applicable" only when established. --> - Semantic owner and earliest changed stage: the signing posture derivation (`deriveApkPosture`) in the APK signature domain. - Contribution scope fit and linked maintainer decision: ordinary fix within existing boundaries; not applicable. - CLI and MCP/tool-catalog contract: `posture.v1_signers_match_block_signers` becomes `true` or `false` instead of `null` for inputs with a present but signer-less lower scheme; no schema or catalog change. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: one derived posture value is now computed for these inputs; observed scheme facts and fingerprints are unchanged. - Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact (CI generates and validates ignored catalogs and `skills/`; edit authored instructions in `.agents/skills/reverse-engineer-anything/` and never commit build outputs): none. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] 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/domain/apkSignature/apkSignatureReport.test.ts`, "skips a present block scheme that declares no signers" in "deriveApkPosture v1 comparison": v1, v2 present with no signers and a v3 signer; asserts `true` when v1 and v3 name the same certificate and `false` when they differ. It calls `deriveApkPosture` directly because the suite's `v1()` helper derives `v2Present` from the signer count. - Base reproduction or other evidence: on the base revision the new test fails with `expected null to be true`. - User-visible CLI/MCP output (if applicable): not captured; the change is one derived posture field. - Remaining proof gaps: the issue's CLI reproduction with synthetic APKs was not rerun here; the existing CLI and MCP APK signature suites below pass. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed Windows 11 x64 10.0.26300, Node 24.22.1, on main `e2efd10b7`: - `npx vitest run src/domain/apkSignature/apkSignatureReport.test.ts`: 18 passed; on the base the new test fails as above. - `npx vitest run src/domain/apkSignature src/apkSignature tests/boundary/apkSignatureV1Cli.test.ts tests/boundary/apkSignatureViewsCliMcp.test.ts`: 10 files, 138 tests passed. - `npm run check:fast`: typecheck and lint pass. - `npx oxfmt --check` on the changed files: pass. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: not applicable; static APK inspection only. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none; no cryptographic verification is added or claimed. ## Author readiness Human owner: @pablodiazjorge - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:47:43 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7418
No description provided.