fix: harden the vault before release

Require a private passphrase and loopback-or-token admin auth. New vaults use Argon2id; existing PBKDF2 vaults still open, and new snapshot metadata is encrypted. Wormhole tokens survive restart, offset uploads seal into the vault, and client-certificate uploads are real. Reject the command provider and keep Postgres passwords off the process arguments. Keep the interruptible canvas motion.
This commit is contained in:
2026-11-10 09:53:06 +07:00
parent 60ba8fed88
commit 95778d54e4
46 changed files with 2311 additions and 415 deletions

View File

@@ -10,24 +10,28 @@ cd web && npm ci && npm run build && cd ..
cargo build --release -p tessera-hub
export TESSERA_DATA_DIR=./data
export TESSERA_VAULT_PASSPHRASE=dev-vault-key
export TESSERA_VAULT_PASSPHRASE='choose a long private passphrase'
./target/release/tessera-hub
```
Open [http://127.0.0.1:8787](http://127.0.0.1:8787) — API docs at `/swagger-ui`.
The hub listens on **127.0.0.1:8787** unless `TESSERA_LISTEN` is set. Open [http://127.0.0.1:8787](http://127.0.0.1:8787). The OpenAPI document is at `/api-doc/openapi.json`. There is no default passphrase, and new vaults refuse the old published value `dev-vault-key`. Leave `TESSERA_SEED_DEMO` unset; `TESSERA_SEED_DEMO=1` writes demo backup history into the data directory.
`TESSERA_ADMIN_TOKEN` is optional. When it is unset, the hub logs that snapshot, orbit, reconstitute, and pairing routes are open to loopback clients only. When it is set, every client, including loopback, must send `Authorization: Bearer <token>` or `X-Tessera-Admin-Token`. `/health`, the OpenAPI document, wormhole claim, and wormhole upload stay outside that check: claim uses the pairing code, and upload uses the upload token. The canvas does not send an admin token. A Docker-published connection is not loopback inside the container, so those backup routes answer 401 there until you set a token and call them with it.
### Docker Compose
```bash
export TESSERA_VAULT_PASSPHRASE='choose a long private passphrase'
docker compose up --build
```
Hub listens on **8787**.
Compose publishes **127.0.0.1:8787** only. The process inside the container listens on `0.0.0.0:8787` so that published port can reach it. The image includes `pg_dump` via `postgresql-client`.
### CLI
```bash
cargo build --release -p tessera-cli
export TESSERA_VAULT_PASSPHRASE='choose a long private passphrase'
./target/release/tessera init
./target/release/tessera orbit nightly --path ./docs --dry-run
./target/release/tessera snap
@@ -41,9 +45,12 @@ See [docs/SPEC.md](docs/SPEC.md). Rust workspace crates: `tessera-core`, `tesser
## Limitations (v1)
- Vault engine uses a **restic-compatible directory layout** with Tessera’s own chunk encryption (Rust 1.83 cannot yet depend on `rustic_core` 0.13+). Emergency tooling may use external `rustic`/`restic` as formats converge.
- Wormhole uploads are **token-authenticated**; mTLS is optional via env hook (`TESSERA_WORMHOLE_MTLS`) without bundled CA generation.
- Postgres provider requires `pg_dump` on `PATH`.
- OIDC admin auth is stubbed; v1 uses open local API when hub is bound to localhost.
- New vaults derive the key with Argon2id (19 MiB, 2 iterations, parallelism 1) and record `keys/kdf.json`. A vault that already has a salt and no `kdf.json` still opens with PBKDF2-HMAC-SHA256, 100,000 iterations. New snapshot metadata is written as `{id}.json.enc`. Existing `{id}.json` files still list and restore.
- Wormhole pairing codes and upload tokens are stored in SQLite and survive a hub restart. Chunks are written at the given offset. When the bytes cover `total_bytes`, the hub seals them into the vault and deletes the `.part` file. `total_bytes` is required.
- Set `TESSERA_WORMHOLE_MTLS` to `1` or `true` to open a client-certificate listener. It also needs `TESSERA_WORMHOLE_CERT`, `TESSERA_WORMHOLE_KEY`, and `TESSERA_WORMHOLE_CLIENT_CA`. `TESSERA_WORMHOLE_LISTEN` defaults to `127.0.0.1:8788`. While that listener is up, plain HTTP upload routes answer 403. An agent that uses `https://` needs `TESSERA_WORMHOLE_CA`, `TESSERA_WORMHOLE_CLIENT_CERT`, and `TESSERA_WORMHOLE_CLIENT_KEY`.
- Postgres capture shells out to `pg_dump`. The connection URL is parsed and the password is written to a mode `0600` pgpass file (`PGPASSFILE`); it is not placed on the process argument list. The release image installs `pg_dump`; a hub built from source needs it on `PATH`.
- The command provider is outside this release. Creating a command orbit and running it returns `command provider is outside this release; use filesystem or postgres`.
- OIDC is not implemented. The canvas does not attach `TESSERA_ADMIN_TOKEN`.
## License