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>
3.2 KiB
3.2 KiB
Handoff for Cody, Round 5
From: Claude (implementation). Date: 2026-11-18.
Not reviewed. Cody's Round 4 verdict applies to 1507cea only.
| Item | Value |
|---|---|
| Repository | git@git.xylo.gg:Xylo-Digital/hermeven.git |
| Branch | cody/slice-1-review |
| Reviewed in Round 4 | 1507cea077838852bfa3658a0d6ef5f419fd8437 |
main |
0c9dcd864f16782097471e5bbf57cbd701c26616 (unchanged; nothing merged) |
| New head for Round 5 | the tip of cody/slice-1-review after this push; exact SHA in the push report |
CODY-006: foreign-owned state directory
| Required correction | What was done |
|---|---|
| 1. Final owner equals the bridge's effective uid, or a configured trusted-owner model | The owner must equal process.geteuid(). No trusted-owner option was added. |
2. Reject foreign ownership with StateDirectoryError before SQLite creates or opens any file |
The ownership check is the first check after "is a directory", inside secureStateDir(), which openDb() calls before it creates the file or constructs the database. |
| 3. Preserve exact 0700 enforcement | Unchanged; runs after the ownership check, and ownership is checked once more after any chmod. |
| 4. Preserve the deployment command | install -d -m 0700 -o hermeven -g hermeven /var/lib/hermeven is unchanged in docs/deploy-droplet.md; the paragraph after it now states that ownership is enforced and why -o matters. |
| 5. Actionable error, refused directory not mutated | The message names the directory, its owner uid, the bridge's uid, the required mode and the install command. A refused directory is not chmod-ed, even when its mode is loose. |
Changed files: services/bridge/src/db.ts, services/bridge/test/units.test.ts,
docs/deploy-droplet.md, docs/security.md, docs/test-evidence.md, this file.
openDb() gained an optional { effectiveUid } argument so the refusal can be tested
deterministically on any machine. Production code never passes it. The same refusal is also tested
without it, against the real /root and inside a user namespace.
Checks
| Check | Result |
|---|---|
npm run typecheck |
exit 0 |
npm test |
198 passed, 0 failed (was 194) |
npm run client:build |
built |
npm run test:real-stt |
11 passed, 0 failed |
npm run test:real-hermes |
9 passed, 0 failed |
npm run test:simulator |
6 passed, 0 failed |
git diff --check |
clean |
No check was omitted. CODY-003's tests (tests/integration/durableRequestId.test.ts) and the
other resolved findings' tests are unchanged and passing.
Things the author is unsure about
- A bridge run as root against a directory owned by a service user is also refused, since the
owner is not the process's own uid. That is the strict reading of the finding; it means the
operator CLI must be run as the service user (as the deployment guide already does for
pair). - On a platform without POSIX uids the ownership check is skipped. The bridge is only documented for Linux.
- The check and the later file creation are separate steps; a directory replaced in between by someone with write access to its parent would not be noticed.
Not claimed
No physical device, no droplet, no deployment, no production change. Nothing merged to main.