Files
hermeven/docs/security.md
T
DanandClaude Fable 5.2 6d74f9e121 Build speech-to-text into the bridge; add droplet deployment examples
STT_PROVIDER now defaults to "builtin": Whisper (onnx-community/whisper-base,
q8) runs in the bridge process on the CPU via @huggingface/transformers, so
no provider account is needed and recordings stay on the bridge host. Silent
captures are detected by level before the model runs. The external
OpenAI-compatible adapter remains available.

Tests: 130 unit/integration; 4 scenarios with the real model on a real
speech recording (npm run test:real-stt). Not tested on audio from the
glasses or on a droplet.

deploy/ and docs/deploy-droplet.md are examples that have not been run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-18 18:31:30 -08:00

85 lines
6.4 KiB
Markdown

# 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. | 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 |
| 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 |
| 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.
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.
3b. **While a recording is being transcribed the bridge can pause for a few hundred
milliseconds** (measured about 0.4 s), because the model runs in the same process. Harmless
for one user; a worker thread would remove it.
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.
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>`.