Files
hermeven/docs/security.md
DanandClaude Fable 5.2 f02715fb64 Address Cody review round 4: CODY-006 state-directory ownership
The state directory must now be owned by the bridge's effective uid. A
directory owned by anyone else is refused with StateDirectoryError before
any file is created or opened, and is left exactly as found, even when its
mode is already 0700. Mode enforcement (exactly 0700) is unchanged and runs
after the ownership check.

Tests: the real /root as an unprivileged user; a deterministic injected-uid
case proving no database/WAL/SHM is created and the directory is not
mutated; a foreign-owned loose-mode directory left unmodified; a user-
namespace fixture using the unmodified production path.

Checks: typecheck clean; npm test 198 passed; client build ok;
test:real-stt 11 passed; 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>
2026-11-18 20:40:06 -08:00

8.8 KiB

Security and threat model

Scope: the single-user slice. One owner, one bridge, one Hermes profile, one or a few paired devices. Not reviewed by anyone but its author yet; see docs/handoff/.

What is being protected

Asset Why it matters
The Hermes API key It gives full use of the agent, "including terminal commands" per Hermes's docs.
The ability to make the agent act A forged or replayed turn could run tools.
Voice recordings, questions, answers Private by nature.
The STT provider key Billing and access.

Trust boundaries

  1. Phone WebView to bridge. Untrusted network. The client holds only a device credential.
  2. Bridge to Hermes and to STT. The bridge holds the real secrets. Both must be HTTPS unless on loopback; the bridge refuses to start otherwise.
  3. Bridge host. Whoever can run the CLI or read the SQLite file is the owner.

Controls in this slice

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. 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
Blind replay after a timeout A sent-but-unanswered request ends as unknown, never as retryable. yes
Oversized or malformed input 32 kB JSON limit; audio capped at capture length + 1 s; schema validation; only one audio format accepted. yes
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 At every start the directory holding the database must be owned by the bridge's own user (a directory owned by anyone else is refused untouched, whatever its mode) and is set to 0700, whether it was just created or already existed; the bridge refuses to start otherwise. The database is created owner-only before SQLite opens it (so its WAL and SHM files inherit that); the systemd unit sets UMask=0077. yes, under umask 0022, for new and pre-existing directories
A running turn forgotten by the app The request id is stored on the phone before anything is sent, and the request is not sent until the phone has confirmed the write. A write that times out or is refused holds the request back, unsent, for a retry under the same id. yes, with the production Even adapter and a stalled host write
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
Administrative access over the network There is none. Pairing codes and revocation are CLI-only. by construction
Accidental public exposure Binds 127.0.0.1 by default; a non-loopback bind needs an explicit setting. yes

Known gaps and accepted risks

Stated so they are not mistaken for protections.

  1. The device credential is not in secure storage. Even's app storage is not described as 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 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 recovered or failed honestly.
  4. In the simulator, raw audio frames are echoed to the WebView console. Whether the phone does the same is unknown and is on the device checklist. If it does, recordings would be visible to whoever can read that console. 4a. The state directory must be the bridge's own. Because it is forced to 0700, pointing HERMEVEN_DB_PATH into a directory shared with other software will lock that software out; a directory owned by another user is refused.
  5. TLS is not terminated by the bridge. A reverse proxy or private network must provide it. A misconfigured proxy could expose plain HTTP.
  6. Rate limits are in memory and reset on restart. Behind a proxy, per-address limits are only meaningful with HERMEVEN_TRUST_PROXY=true and a proxy that sets the forwarded address.
  7. The 15-minute result cache holds question and answer text in SQLite in clear text, as does the pending request body for the moment between sending and recording the run id.
  8. The SQLite file and .env are protected only by file permissions on the bridge host.
  9. No audit trail of pairings and revocations beyond the log stream.
  10. The network whitelist puts the bridge origin into the packaged app, where anyone with the package can read it. The origin is not a secret and must not be treated as one.
  11. The agent's tool permissions are whatever the Hermes profile allows. Hermeven does not narrow them. Use a read-only or test profile until approval handling is proven on a device.
  12. Dependencies were not audited beyond npm install reporting no known vulnerabilities on 2026-11-18.

Operational rules

  • Keep .env out of git (it is ignored) and out of screenshots.
  • Never put a real key in a tutorial, a build-in-public post or an issue.
  • Revoke a lost device from the bridge host: npm run bridge:cli -- revoke <device-id>.