feat: store Outpost credentials as digests and rate limit public endpoints (auth M4)
Credentials - pairing codes and Outpost upload tokens are stored only as SHA-256 digests; the token is minted at claim (256-bit OsRng) and returned once - the old clear-text wormhole_tokens table is migrated in place and dropped with secure_delete; active tokens keep working with a fresh lifetime - admin rotate (with grace window) and revoke endpoints, audited; a revoked Outpost is refused on its next request - optional end date for the shared admin token (TESSERA_ADMIN_TOKEN_EXPIRES) Limits - governor per-source limits for emergency login, pairing claim and SSO start/callback; X-Forwarded-For only from TESSERA_TRUSTED_PROXIES; IPv6 by /64 - at most two concurrent Argon2 verifications, refused immediately when busy - denials audited at most once a minute per source - the mTLS listener now supplies the peer address to handlers Existing hubs: rotate every Outpost token after upgrading; old database copies still contain the clear-text tokens. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -213,3 +213,49 @@ Behaviour to know about:
|
||||
- No IdP token is stored or sent to the browser; the browser only receives the
|
||||
Tessera session cookie.
|
||||
|
||||
## Outpost credentials, rotation and request limits
|
||||
|
||||
**Storage.** The hub keeps only SHA-256 digests of pairing codes and Outpost upload
|
||||
tokens. A pairing code is shown once (10 minute lifetime, single use). The upload
|
||||
token does not exist until the agent claims the code; it is returned once and never
|
||||
stored or logged. Tokens are 256-bit random values. They expire after
|
||||
`TESSERA_OUTPOST_TOKEN_DAYS` days (default 365).
|
||||
|
||||
**Upgrading an existing hub.** On first start the old clear-text `wormhole_tokens`
|
||||
table is moved to digests and dropped, with `secure_delete` on so freed pages are
|
||||
zeroed. Paired agents keep working with their current token and get a fresh
|
||||
lifetime from the migration (the old `expires_at` was the pairing code's expiry).
|
||||
Copies and backups of the old database still contain the clear-text tokens:
|
||||
**rotate every Outpost token after upgrading** and treat old backups as sensitive.
|
||||
Do not downgrade to a binary that predates this change; it would not understand the
|
||||
new tables. Back up `tessera.db` first and rehearse on a copy.
|
||||
|
||||
**Rotate** (admin only). `POST /api/v1/wormhole/outposts/{id}/rotate?grace_minutes=60`
|
||||
returns the new `upload_token` once. The previous token keeps working for the grace
|
||||
period (default 60, maximum 1440, `0` cuts it at once) so you can put the new value
|
||||
in the agent's `TESSERA_UPLOAD_TOKEN` and restart it. There is no agent
|
||||
self-rotation yet: the operator delivers the new token.
|
||||
**Revoke** (admin only). `POST /api/v1/wormhole/outposts/{id}/revoke` refuses every
|
||||
token of that Outpost on its next request; it must be paired again. Both actions are
|
||||
audited (`outpost.credential_rotate`, `outpost.credential_revoke`).
|
||||
|
||||
**Limits.** Unauthenticated and expensive endpoints are limited per source with
|
||||
`governor`: emergency login (5 burst, 10/min per source, plus a looser 60/min account
|
||||
ceiling), pairing claim (5 burst, 10/min per source, 120/min overall), SSO start and
|
||||
callback. At most 2 Argon2 verifications run at once; further attempts get `429`
|
||||
immediately. A denial is written to the audit log at most once a minute per source.
|
||||
|
||||
- The source is the TCP peer address. `X-Forwarded-For` is only used when the peer
|
||||
is listed in `TESSERA_TRUSTED_PROXIES` (comma-separated IPs), read right to left
|
||||
past trusted hops. Behind a reverse proxy **set this**, otherwise every user
|
||||
shares the proxy's budget. IPv6 sources are keyed by /64.
|
||||
- The account ceiling is deliberately looser than the per-source limit. With one
|
||||
break-glass account, a tight account lock would let anyone lock the operator out.
|
||||
- Limiter state is in memory: it resets when the hub restarts and is not shared
|
||||
between hub processes.
|
||||
|
||||
**Shared admin token.** `TESSERA_ADMIN_TOKEN` is a transition aid. Set
|
||||
`TESSERA_ADMIN_TOKEN_EXPIRES` (`YYYY-MM-DD`, end of that day UTC, or an RFC 3339
|
||||
timestamp) and the hub refuses the token after that time. Without it the hub logs a
|
||||
warning at start. Every use is audited as the `legacy-admin-token` service principal.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user