Repository navigation
fix(android): verify the helper APK digest before running settings locale as shell - #5143
Conversation
…cale as shell settings locale loads SystemLocaleCommand from the installed helper's base APK through app_process as the shell user. The install step may accept a cached decision or a higher installed versionCode without reading the APK, so an APK installed under the helper package name could run as shell. Resolve the base APK path once, hash that file on the device, and run app_process only from that path when its SHA-256 matches the trusted manifest. A missing path, unreadable APK, or digest mismatch refuses with locale-helper-apk-unverified and dispatched no, and drops the cached install decision so the next command inspects the device again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Size Report
Startup median (7 runs, lower is better):
|
There was a problem hiding this comment.
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
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 2 new findings on 7608df3. The verdict and the full list are in the summary comment.
|
The review of 7608df3 found problems to resolve before merge in the digest check for Android settings-locale.ts:34 now runs the shell route only after a pull of the device's A second independent pass found a likely gap at settings-locale.ts:38. The Android locale route has no SDK gate, and the helper manifest admits API 25. Android 7.1 gives a new install the first vacant numeric directory (installer rename, path allocation). Apps cannot write there directly, but a verified path can be reused by another revision before A second independent pass found that a newer official helper likely loses locale support at settings-locale.ts:130. The base code ran a newer helper that has a working A second independent pass found that settings-locale.ts:113 likely loses adb diagnostics. With a warm install memo, the device can go offline or revoke authorization before A second independent pass found that a pull timeout can likely block locale at settings-locale.ts:121 while the shell works. On a slow ADB link, short commands can succeed while the full APK pull exceeds the 10-second identity timeout. The caught timeout is then hidden behind uninstall advice. The base code needed only A second independent pass found that device changes can likely precede the refusal at settings-locale.ts:103. Preparation can install a missing helper, uninstall an incompatible one, or force-stop a retiring one before the verification pull fails. A second independent pass found that the refusal likely adds work to a later snapshot (settings-locale.ts:94). After a transient pull failure, the next snapshot misses the install memo and hashes the local and installed APKs again. Can a failed locale check force a recheck for locale retries only, while the snapshot memo and the check before each locale execution stay in place? Not blocking: settings-locale.ts:110 repeats the path-and-digest steps that These high-priority threads still apply: reason documentation row and The only checks that did not pass are two cancelled "Body rules" runs. This is likely unrelated to the code: a later body edit probably superseded them, and the job does not exercise any file in this diff. All 22 other checks pass. Not verified here: the tests were not run, and their regression value was judged only by reading them against the earlier path lookup. A byte match between a real device's Before merge, please resolve the points above, then attach the live Android |
Copy the helper's base APK into the shell scratch directory, hash that copy, and run app_process from it only on a match with the trusted manifest. Apps cannot write there, so a reused install directory or a package swap cannot change the bytes after the check. Keep adb failures from pm path, the copy, and the pull classified instead of reporting them as an unverified APK. Name a helper install that preparation completed on every failure before the locale write. Drop a refused install decision only on the next locale command, so snapshots keep their memo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Response to the review of 7608df3. b2d37f9 addresses each point.
Live run at b2d37f9 with the source build ( Afterwards, |
…d install path Replace the staged copy with a smaller rule. Android 8.0 gives each install a random directory, so a verified base APK path names one APK and app_process can run from it. Older releases can reuse an install path for another APK, so settings locale refuses them with locale-api-level-unsupported before it prepares the helper. A missing base APK or a digest mismatch drops the cached install decision it disproves. Transport failures keep their adb classification and leave the decision in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Update at 5ff4a0c. The staged-copy mechanism from b2d37f9 is removed in favor of a smaller rule.
Live run at 5ff4a0c with the source build ( The emulator was booted and shown through the host device binding. The commands ran from the source build, because the host binding's CLI is a client of the released daemon and does not contain this change. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 5ff4a0c. The verdict and the full list are in the summary comment.
|
At 5ff4a0c, one problem from the earlier review remains: a definitive locale refusal still evicts the shared install memo. A second independent pass found that this likely still slows the next snapshot ( One lower-priority thread still applies as a non-blocking cost note. These threads no longer apply and can be resolved: this one, because the docs row now names both refusal cases and an unreadable APK no longer maps to that reason; this one, because a nonzero Not verified here: tests were not run locally, so CI covers them, and their regression value was judged by reading them against the production route. Not verified here: the live run covers only Android 17, and, as the PR body states, a The Body rules check fails because the PR body has 270 words outside code blocks, and the limit is under 250. This failure comes from the body text, not the code, and only a body edit fixes it. A second Body rules run was cancelled and superseded. All other checks pass. Before merge, fix the memo eviction above and trim the PR body below 250 words outside code blocks. |
…apshot memo A locale refusal no longer deletes the shared install memo. It records the device, and the next locale command inspects the install instead of trusting the memo, while snapshots keep answering from it. The digest check still runs on every locale command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Update at cda1497 for the review of 5ff4a0c.
Live run at cda1497, source build, one daemon, Android 17 emulator: |
This comment has been minimized.
This comment has been minimized.
|
At cda1497, the problem from the earlier review is fixed: a locale refusal now records a recheck and no longer evicts the shared install memo. Two problems remain, one in the new test and one in how that recheck is cleared. A second independent pass found that the new snapshot probe in A second independent pass also found that an overlapping locale call can likely erase a newer refusal without inspecting the install ( These threads no longer apply and can be resolved: this one, because the docs row now names both refusal cases and an unreadable APK keeps its adb error; this one, because a nonzero Not verified here: tests were not run locally, and the regression value of the new test was judged by reading it against 5ff4a0c and the production install route. Not verified here: the live run in the PR body covers the Android 17 success path at cda1497, not a live refusal followed by a snapshot and a second locale call; only the fake-adb test shows that interaction. The Lint, Typecheck & Package check fails because of the TS4104 error above, which this change introduces. The Body rules run was cancelled and superseded; the PR body now has about 240 words outside code blocks, under the 250 limit, so a rerun should pass. All other checks pass, including the unit jobs. Before merge, fix the test type, protect newer refusals from being cleared, and rerun Body rules. |
…ts recheck Each locale refusal records a fresh token. A locale call clears the recheck only when it asked for the inspection and the token it saw is still current, so a refusal recorded while it prepared the helper keeps the next locale call inspecting the install. Type the snapshot probe calls as readonly argument lists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Update at 566e9c7 for the review of cda1497.
The changes since cda1497 touch only refusal bookkeeping. The live success path recorded at cda1497 is unchanged. |
Apex Sentinel · ✅ Approve · review of
|
| 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.
|
At 566e9c7, both problems from the earlier review are fixed, and no code problem remains. The snapshot probe now uses the executor's argument type, and a locale call now clears only the refusal it inspected, so a newer refusal still forces an install check on the next call. A new test covers that overlap. These threads no longer apply and can be resolved: this one, because the docs now name both refusal cases and an unreadable APK keeps its adb error; this one, because a nonzero Not verified here: tests were not run locally. The regression value of the overlap test was judged by reading it against the earlier implementation, and its pass relies on CI. Not verified here: the live run in the PR body covers the Android 17 success path at cda1497, and no live run covers a refusal followed by a second locale call. The changes since that run only affect in-process refusal tracking and tests, so no new device run is requested. The only check not passing is Body rules, which was cancelled and did not fail; it checks the PR body, which this diff does not touch. All other checks pass, including Typecheck. Before merge, rerun Body rules. The body is about 235 words, under the 250 limit, so it should pass. |
Summary
settings localeon Android (#5050) runsSystemLocaleCommandfrom the installed helper APK as the shell user. The install step can trust a memo or a higher versionCode without reading the APK, so a foreign APK under the helper package name could run as shell.Each locale command now hashes the base APK and runs
app_processfrom that path only when the SHA-256 matches the trusted manifest.locale-api-level-unsupportedbefore helper preparation.locale-helper-apk-unverified. The next locale command inspects the install; the shared snapshot memo stays, and an older overlapping call cannot clear a newer refusal.pm pathand pull failures keep their adb classification.dispatched: noand name a completed helper install.Follow-ups:
cmd locale set-device-localeon Android 16 QPR2+;resetsemantics.Before / after
settings locale de-DEwith a newer foreign APK as the helper package:app_processruns it as shell.locale-helper-apk-unverified,dispatched: no, no shell execution.Validation
Source build of
cda1497, Android 17 emulator, one daemon:settings locale de-DEtwice (previousLocaleen-US, thende-DE), thenreset(en-US).At
566e9c7,settings-locale.test.tspasses 17/17. Removing the digest check, the API gate, the locale recheck, or the refusal token fails the matching tests. The changes sincecda1497touch only refusal bookkeeping. CI pending. Android 8–16 and remote providers not run.🤖 Generated with Claude Code