Stores: seal the GOG, Epic and Amazon sign-in files with an Android Keystore key (#486)

The stores' sign-ins (files/stores/<store>/credentials.json: access and refresh
tokens, account id and name) were plain JSON. Other apps could not read them, but
every program in the Linux session runs as the app and could. They are now sealed
with AES-256-GCM under a non-exportable AndroidKeyStore key (StrongBox when the
device has one), so the session only ever sees ciphertext.

- Format: a versioned envelope {v, alg, iv, ct}, written atomically and readable
  only by the app. No new dependencies (javax.crypto and KeyStore).
- Migration: an existing plaintext file is sealed at the next start, checked by
  decrypting it, then the plaintext is removed; users stay signed in.
- No Keystore on the device: the file stays plain and the log says so once per
  start.
- A sealed file that can never be opened (tampered, key gone or invalidated,
  broken envelope) is removed and that store asks for sign-in again. A transient
  Keystore error keeps the file and retries.
This commit is contained in:
The412Banner authored and GitHub committed 2026-10-09 14:42:23 -04:00
1 parent 71e2ae8683
commit 5af14829b0
11 files changed
+462 -16

No files matched your search

+20
View File
@@ -7,6 +7,26 @@ the timeline, then lessons and backlog. Companion to the README (what the app *d
---
## 2026-10-09 - `feat/store-credentials-keystore`: store sign-ins sealed with the Android Keystore
- **What:** `filesDir/stores/<store>/credentials.json` (GOG, Epic, Amazon: tokens, ids, names,
expiry) is now an AES-256-GCM envelope (`{"v":1,"alg":"AES/GCM","iv","ct"}`) under a
non-exportable AndroidKeyStore key (StrongBox if present, else TEE; no user authentication).
`StoreAccounts` is the one layer; `CredentialCipher` holds the envelope and the key.
- **Upgrade:** a plain file is sealed at the first start (verified, then replaced); users stay
signed in. Log: `stores: credentials encrypted <store>`.
- **Fallbacks:** no Keystore - stays plain, logged once, retried next start. A file that can never
open (bad tag, key invalidated or missing, not an envelope) - deleted, signed out (sign-in card).
Any other Keystore or I/O failure - file kept, store stays signed in but unavailable (actions show
`<Store> sign-in could not be read: try again.`), logged once, retried on the next access. Never
a crash.
- **Session:** the guest sees the envelope only; it never read the files (the Epic code comes over
the request channel, written beside the launcher and deleted by it).
- **Tests:** `StoreAccountsCipherTest` (round trip, sealed on disk, migration of all three stores,
tampered file, lost key, key missing, garbage, no-Keystore fallback then sealed next start,
transient Keystore / I/O failures keep the file and a later read succeeds, sign-out). Not yet
on a device.
## 2026-10-08 - `feat/private-logs`: every log in app-private storage, shared as one scrubbed zip
- **Where logs live:** `files/logs/` (`LinuxRuntime.logDir`), nothing under `Download/DroidDeck`