fix(android): bound helper output and verify installed bytes
Merged
TH
29m ago+742+742+012345678901234567890123456789-616-616-012345678901234567890123456789
Summary
The installed Android helper must be the trusted artifact, and the host must stay bounded about app text. Install checks cover replacements that complete before admission. A holder of the helper signing key can still update the package between pm path and am instrument, so the guarantee depends on #5341's key rotation.
Before / after
| Before | After | |
|---|---|---|
| Installed helper with a higher versionCode | Counted as current, ran unverified | State newer: uninstall, then install the bundled APK. versionCode comes from dumpsys package |
| Warm admission | Memo hit skipped device checks | One pm path compared with the verified path |
| Helper output on the host | Unbounded | 32 MiB cap per stream: command_output_limit for a one-shot call, android_snapshot_helper_session_response_too_large for a session |
| Text over 64K chars | Serialized in full | Helper keeps a prefix and marks text-clipped. get text and is text refuse with text_clipped. Fill verification accepts a clipped node only when it is the prefix of a longer expected value |
Validation
- Head 2ff26e8323. Prod delta vs
0.22: about +240 / -170 lines. - Affected Android, selector and helper test files pass; hosted CI green.
- Reverting each change failed the tests that pin it.
- No device runs. The Java test was not run locally.
- Known gap: before Android 8.0, a same-path reinstall is not detected by warm admission.