Skip to content

ci(release): sign Android helpers in a job that runs only workflow-commit code - #5410

Merged
thymikee merged 6 commits into
ci/release-codeownersfrom
ci/release-helper-signing-split
Dec 6, 2026
Merged

thymikee merged 6 commits into
ci/release-codeownersfrom
ci/release-helper-signing-split

Conversation

@thymikee

@thymikee thymikee commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Stacked on #5409. Planned-source code no longer runs in a job that holds the Android helper keystore.

  • compile (planned source, no secret): builds unsigned helpers.
  • sign (release environment; disposable key in dry runs): a sparse checkout of workflow_sha with no install and no cache. It fetches the compiler artifact packed, through the REST API by ID, and checks that it comes from this run. actions/download-artifact extracts without a containment check, so it is not used here. scripts/sign-android-helpers.sh unpacks only the exact expected APK names, as regular files, into a fresh directory. It checks ZIP structure and identity, signs, verifies v1+v2 and a single signer, and pins the release cert 734335…39e1.
  • build/package (planned source, no secret): packages the signed APKs after checking the cert and identity. This consumer is identical on main and 0.22.

release-android-snapshot-helper.yml and the rehearsal use the same signer. Helper artifacts are kept for 30 days to cover approvals and reruns.

Validation

  • Local signer runs: the disposable key, a keystore, and matching and wrong pins. Archives with an extra entry, ../ paths and a symlink entry are all rejected. The packaged bytes match the signed bytes.
  • The release workflow and release asset tests pass (68).
  • CI runs a dry run of the split.
  • Production proof: the first nightly has no approval prompt and helper cert 734335…39e1.

@github-actions

github-actions Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.80 MB 6.80 MB 0 B
Package (unpacked) 6.80 MB 6.80 MB 0 B
Package (download) 2.07 MB 2.07 MB -5 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 22.0 ms 21.7 ms -0.4 ms
CLI --help 49.1 ms 45.3 ms -3.9 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread test/ci/release-workflow.test.ts Resolved
@thymikee
thymikee force-pushed the ci/release-helper-signing-split branch from fc71e22 to b492465 Compare December 5, 2026 13:24
@apex-sentinel-staging

This comment has been minimized.

@thymikee

thymikee commented Dec 5, 2026

Copy link
Copy Markdown
Member Author

Two problems in the new signing split at b492465 need a fix before the signing key can be trusted to this design.

A second independent pass found that the unsigned artifact from the compile job is extracted after the signing checkout and before the keystore is loaded (release.yml:155, keystore at lines 170–190). If that artifact is a ZIP with a nested path that resolves outside the extraction directory, the pinned download action can overwrite the checked-out signing files, so a later signing step can run compiler-controlled code with the key in reach. The same sequence exists in the stable asset call and standalone dispatch (release-android-snapshot-helper.yml:94–145). The APK validator runs only after extraction, and the numeric ID picks the archive without limiting its entries. The pinned bundle passes the archive to unzip-stream's Extract, which joins and opens each destination without a containment check (extract call, path join). The PR dry run uses the same downloader, so it can lose the signed-output guarantee even with its disposable key. The rule to satisfy: no step that holds or precedes the keystore may extract compiler-controlled archive entries without a path-containment check. Both signer downloads enumerate the sites. Replace them with a pinned downloader whose bundled extractor checks containment before any write, or download without automatic decompression and write only the exact expected regular APK entries into a fresh temporary directory.

A second independent pass also found that delayed approvals and retries now break (release.yml:119). Approve a nightly or stable signing job two days after compilation. The approval is still inside GitHub's 30-day window, but the one-day compile artifact has expired, so the ID download at lines 154–159 fails. The stable asset call and standalone dispatch have the same expiry (release-android-snapshot-helper.yml:72–87). Separately, if signing succeeds and a later build or publish job fails, rerunning only failed jobs after two days (as CONTRIBUTING.md:126 says) keeps the old signer result, whose artifact has expired (release.yml:193–200, release-android-snapshot-helper.yml:148–155), so the retry fails before packaging. The old build and publish jobs compiled and signed inside the retried job, so they had no such window (base 813f53a). Keep the unsigned and signed helper artifacts in both release files for the 30-day approval and retry window, within the repository retention limit. See GitHub's docs on deployment approval and re-running jobs.

Not blocking, and these can be taken or left: the invariant test at release-workflow.test.ts:122 reads only release.yml, so the keystore-holding job in release-android-snapshot-helper.yml is not asserted (one test over a table of file, signer and unkeyed jobs would enumerate every signer); the signer job and the release certificate literal exist in several copies (release-android-snapshot-helper.yml:141, release.yml:186), so one owner such as a reusable job or a default pin in scripts/sign-android-helpers.sh would remove the "Keep it equal" comment; and CI runs only the disposable-key branch of sign-android-helpers.sh:67, so the keystore branch and the pin match and mismatch have no automated test unless the first post-merge nightly is accepted as the proof.

The two open inline threads on the test regex and the dropped setup-node step still stand, both as non-blocking notes.

The only failing check is Body rules, which checks the PR body and not the code: it needs a "## Summary" section and fewer than 250 words (the body has 422). That failure is likely unrelated to the diff. The release dry-run split, rehearsal and package jobs, repo guards and smoke tests passed at this head. Before merge, the two problems above need a fix and the body needs a rewrite.

Not verified here: the stable-tag or dispatch snapshot path and the release-environment keystore path, which PR CI does not run; the author's local pin and keystore validation; and the environment deployment policy and branch ruleset, which are admin settings. The first nightly (no build-job secret, helper certificate 734335…39e1) and the next stable tag are the proof for those paths.

@thymikee

thymikee commented Dec 5, 2026

Copy link
Copy Markdown
Member Author

Replies to the review in 6aecb64:

  • Zip-slip before the keystore: fixed. Signers no longer use actions/download-artifact. They fetch the artifact ZIP packed (gh api …/artifacts/<id>/zip, run ID checked), and the signer writes only the exact expected APK names, as regular files of at most 1 MiB, into a fresh directory with O_EXCL. I checked it locally against archives with an extra entry, ../ names and a symlink entry; all were rejected.
  • Retention: unsigned and signed helper artifacts now have retention-days: 30 in both files.
  • Invariant test: now table-driven over both signers.
  • Left as is:
    • The cert literal stays as two pins rather than a shared reusable job. The extra indirection isn't worth it for one constant.
    • The keystore branch has no automated test. It was checked locally (matching and wrong pin), and the first nightly is its production proof.

@thymikee
thymikee force-pushed the ci/release-helper-signing-split branch from 8f3a026 to 2596025 Compare December 5, 2026 14:29
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging 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.

Apex Sentinel: 3 new findings on 2596025. The verdict and the full list are in the summary comment.

Comment thread test/ci/release-workflow.test.ts Resolved
@apex-sentinel-staging

This comment has been minimized.

@thymikee

thymikee commented Dec 5, 2026

Copy link
Copy Markdown
Member Author

The earlier review (b492465, #5410 (comment)) findings are mostly addressed at 7db0714, but the change adds one new problem that stops the Release workflow from starting. The test guard now inspects parsed step fields, Node is set up before metadata resolution, the pin has a single default in the signing script, and the rehearsal case is in the test table.

The delta adds actions: read to the nested sign-helper job in release-android-snapshot-helper.yml. The calling job android-snapshot-helper in release.yml grants only contents: write. A called workflow cannot request more than its caller job grants (see GitHub's nested workflow permissions), so GitHub should reject release.yml before any job runs. The Release run at this head (47532051557) and at every head since 6aecb64, where actions: read was added, ended in startup_failure. At b492465 it succeeded.

The whole Release workflow then fails for every event: PR dry runs, the nightly schedule, dispatch and stable tags. Nothing publishes. This is a regression against the base, where release.yml starts. PR checks do not show it because a startup failure creates no check run. Every other listed check is green.

The rule is that every job that calls a reusable workflow must grant at least the union of the permissions its nested jobs request. Please add actions: read to the android-snapshot-helper caller job in release.yml. Please also add a test-table case that, for each uses: ./.github/workflows/*.yml job, checks the caller's permissions cover every nested job's permissions.

A second independent pass reached the same finding from the stable-tag and dispatch-retry path, where the caller grants actions: none while the packed artifact fetch at lines 118-127 needs actions: read. Direct dispatch of the reusable workflow has its own grant, so it is unaffected.

Not verified here: the exact startup_failure message, because the CLI does not expose it. The attribution rests on the GitHub rule, the caller's contents-only permissions, and the failure starting exactly at the head that added actions: read. Not verified here: the release-environment keystore path, the stable-tag and dispatch snapshot path, and the artifact-zip redirect under the release environment, because PR CI does not run them. The rehearsal covers the packed fetch and extraction with a disposable key only. Not verified here: the author's local negative tests (extra entry, ../ path, symlink entry), which were not re-run. The extraction code was checked by reading it.

Before merge, a Release workflow dry run at the fixed head must start and pass compile-helpers, sign-helpers (packed fetch plus in-script extraction with the disposable key) and build. A non-startup_failure run of release.yml for the new head SHA shows this.

Of the earlier inline threads, the test guard thread (#5410 (comment)), the Node 24.13 setup thread (#5410 (comment)), the pin default thread (#5410 (comment)) and the rehearsal test-table thread (#5410 (comment)) are fixed at this head and can be resolved. The pin thread at #5410 (comment) does not apply: the trusted signer enforces the pin before upload (sign-android-helpers.sh lines 99 and 121), and the consumer runs planned-source code, so a pin there adds no guarantee. No other threads still apply.

No conflicts were reported. Before merge, add actions: read to the caller job and show the passing Release dry run at the new head.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

thymikee commented Dec 5, 2026

Copy link
Copy Markdown
Member Author

The change at 7f78198 looks good, and the startup failure from the earlier review (#5410 (comment)) is now fixed. All 35 checks pass, and the Release pull_request run at this head (47535069445) succeeds through compile, sign and build. No conflicts are known. Nothing else blocks merge.

Not verified here: the dry run skips the Android helper assets reusable-workflow jobs. The release-environment keystore path, the packed artifact fetch with actions: read on stable-tag or dispatch runs, and the publish job did not run. Only GitHub's startup permission check covers the new grant, and it passed. The new test was not re-run locally. It was read against the 7db0714 grants and would fail on the old code.

Of the other open threads, these no longer apply and can be resolved: the step-field guard (#5410 (comment)), the Node.js 24.13 setup order (#5410 (comment)), the single pin default (#5410 (comment)), the consumer-side pin (#5410 (comment), the signer enforces the pin before upload and the author withdrew it), and the rehearsal signer test case (#5410 (comment)).

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Dec 5, 2026
@thymikee
thymikee added this pull request to stack #5415 December 5, 2026 17:46
Comment on lines +99 to +102
- name: Setup Android SDK
uses: ./.github/actions/setup-android-sdk

- name: Compile unsigned helpers
Comment on lines +102 to +112
- name: Compile unsigned helpers
env:
VERSION: ${{ needs.plan.outputs.version }}
AGENT_DEVICE_ANDROID_HELPER_UNSIGNED: '1'
run: |
set -euo pipefail
for helper in snapshot ime; do
sh scripts/build-android-helper.sh "$helper" "$VERSION" "$RUNNER_TEMP/unsigned-helpers"
done

- name: Upload unsigned helpers
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 5fa19a1

Since the review of 7f78198: 0 new · 0 still open · 0 no longer raised

No open findings.

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (dcb78c4160ff).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Dec 5, 2026
@thymikee

thymikee commented Dec 5, 2026

Copy link
Copy Markdown
Member Author

The code at 5fa19a1 looks correct, and the cache-poisoning route from the earlier review (7f78198, #5410 (comment)) is now closed. The compile job runs with cache-mode: none (release.yml:91), so planned-source code holds no cache token, no step in it caches, and the privileged jobs restore no cache.

The only failing check is the CodeQL aggregate, and it comes from the two cache-poisoning alerts on compile-helpers. The rule matches the checkout plus execution and does not model job-level cache-mode, so it still fires even though the route cannot happen at this head. The other checks pass, including the release dry run and the rehearsal. Not verified here: the exact cache-mode semantics in GitHub docs, the CodeQL failure details beyond those two alerts, and the no-cache-token behavior in a scheduled or stable run.

The two inline alert threads do not apply at this head and can be resolved: #5410 (comment) and #5410 (comment). A maintainer needs to dismiss both alerts in code scanning as false positives so the CodeQL check goes green. Nothing in the code blocks merge, and no conflicts are known.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Dec 5, 2026
@thymikee
thymikee merged commit 202d135 into main Dec 6, 2026
39 of 40 checks passed
@thymikee
thymikee deleted the ci/release-helper-signing-split branch December 6, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants