Address Cody review round 2: all ten findings (CODY-001 to CODY-010)

CODY-001 Bridge URL must be HTTPS (HTTP only to loopback), in the client and
         in manifest generation.
CODY-002 Even host calls stay serialised until the SDK call really settles;
         a microphone start that completes after its timeout is followed by
         a stop.
CODY-003 Request id is stored before the first submit and cleared only on a
         definitive answer; lost replies are treated as ambiguous and
         reconciled under the same id; HUD no longer claims "not sent".
CODY-004 Revoking a device cancels its in-flight turns, aborts
         transcription and asks Hermes to stop, from HTTP and CLI paths.
CODY-005 Speech model pinned to a commit with per-file SHA-256; fetched and
         verified ahead of time; verified on every load; never downloaded
         at run time; no unpinned configuration.
CODY-006 State directory 0700, database/WAL/SHM 0600 regardless of umask.
CODY-007 credential_expired handled like unauthorized on every path.
CODY-008 Approval wait start and paused agent deadline persisted and
         restored across restarts (schema v2).
CODY-009 Exactly one conversation create per epoch, sent in sequence, with
         stale results dropped before persistence.
CODY-010 Wrong pairing guesses no longer consume the outstanding code;
         failures are indistinguishable.

Checks: typecheck clean; npm test 182 passed; client build ok;
test:real-stt 11 passed (including with no network); test:real-hermes 9
passed; test:simulator 6 passed; git diff --check clean.

Not reviewed. No physical-device, droplet or production evidence.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Dan
2026-11-18 19:49:14 -08:00
co-authored by Claude Fable 5.2
parent 3d5691dfa3
commit e1c02d5266
43 changed files with 2104 additions and 227 deletions
+13 -5
View File
@@ -24,8 +24,9 @@ devices. Not reviewed by anyone but its author yet; see `docs/handoff/`.
| Threat | Control | Tested |
|---|---|---|
| Hermes key or STT key leaks through the client | Neither is in the client code, bundle or any API response. The production bundle was searched for them. | yes |
| Stolen device credential | Scoped to one device and one profile; cannot name a Hermes session; expires in 7 days; pairing ends at 90 days; revocable from the phone or the bridge host; stored on the bridge as SHA-256 only. | yes |
| Guessing a pairing code | 10 characters from a 31-symbol alphabet (about 49 bits); valid 5 minutes; single use; a new code voids the old one; 5 wrong guesses burn every outstanding code; 5 attempts per minute per client address. | yes |
| Stolen device credential | Scoped to one device and one profile; cannot name a Hermes session; expires in 7 days; pairing ends at 90 days; revocable from the phone or the bridge host; stored on the bridge as SHA-256 only. Revoking also cancels every turn the device has in flight and asks Hermes to stop it, from the HTTP route and from the CLI alike. | yes |
| Credential or recordings sent in clear text | The app refuses any bridge address that is not HTTPS, except HTTP to loopback; the manifest generator refuses to package one. | yes |
| Guessing a pairing code | 10 characters from a 31-symbol alphabet (8.2 x 10^14 values, about 49 bits); valid 5 minutes; single use; a new code voids the old one; 5 attempts per minute per client address. At that rate one address gets 25 guesses per code: a 3 in 10^14 chance. Even a million guesses in the 5 minutes would be about 1 in 10^9. Wrong guesses do not consume the code, so nobody can void the owner's code by guessing; every failure returns the same answer. | yes |
| Client picks someone else's agent session or profile | Requests with unknown fields are rejected. The Hermes session id is generated by the bridge and never leaves it. A device is valid only for the profile it was paired under. | yes |
| One device reads or cancels another's turn | Every lookup is scoped to the authenticated device; a foreign id answers 404, not 403. | yes |
| Duplicate or replayed submit runs a tool twice | Client request id is the bridge's idempotency key; the bridge forwards a derived key to Hermes. | yes, including against real Hermes |
@@ -34,6 +35,8 @@ devices. Not reviewed by anyone but its author yet; see `docs/handoff/`.
| Request flooding | Per-device turn limit, per-address pairing limit, general per-device limit. | yes |
| Cross-origin browser abuse | CORS allows only exact configured origins and sends no credentials mode. CORS is not treated as authentication: every route still needs the bearer credential. | yes |
| Secrets or content in logs | Logs carry ids, states, codes and timings. Request logging is off, a redaction list backs it up, and Hermes's own diagnostic text is never relayed or logged. | yes |
| Substituted speech-model files | The model is pinned to a commit id with a SHA-256 for every file. Files are fetched ahead of time and verified; the bridge re-verifies on every load, never downloads at run time, and reads from a directory that can be read-only. There is no unpinned mode. | yes, including with no network at all |
| State files readable by other users | The database is created owner-only before SQLite opens it (so its WAL and SHM files inherit that), in a 0700 directory; the systemd unit sets `UMask=0077`. | yes, under umask 0022 |
| Recordings retained | Audio exists only in memory for the length of one transcription call and is never written to disk by the bridge. | by construction; not independently audited |
| Agent approves its own privileged action | The bridge never calls Hermes's approval endpoint. | yes |
| Markup injection from an agent answer into the phone page | The page is built with `textContent` only. | by construction |
@@ -48,14 +51,19 @@ Stated so they are not mistaken for protections.
encrypted, and the public SDK offers nothing better. The mitigation is that the credential is
narrow, expiring and revocable, not that it is safe at rest. Anyone with the unlocked phone, or
with developer access to the app's storage, can use it until it is revoked.
1a. **Pairing brute force is bounded by entropy and a per-address limit, not by a lockout.** A
distributed attacker is limited only by how fast the bridge answers. That is still far short
of a useful chance (see the table), but it is a deliberate trade against letting anyone
cancel the owner's code.
2. **Renewal needs only the current token.** A thief who renews before the owner notices keeps
access until revoked or until the 90-day pairing lifetime ends.
3. **Audio leaves the phone for the bridge host.** With the default built-in speech model it
goes no further. With `STT_PROVIDER=openai-compatible` it is sent to that provider, whose
retention is outside our control.
3a. **The built-in model's files are downloaded from the Hugging Face hub on first start** and
are not pinned to a revision or checked against a known hash. A compromised hub account or
path could serve different weights. Pinning a revision is a follow-up.
3a. **The pinned hashes are only as trustworthy as the moment they were recorded.** They were
taken from the hub on 2026-11-18. They prove the files have not changed since; they do not
prove the files were benign then. The verified-then-loaded sequence also has a small window
between check and use, which a read-only model directory closes.
3b. **The speech model runs in a worker thread of the bridge process**, not a separate
sandboxed process. It no longer stalls the bridge (measured 3 ms), but a crash inside the
native runtime could still take the bridge down; systemd restarts it and in-flight turns are