Rotation principles
For a planned rotation:- Generate a new high-entropy value.
- Store it in the intended secret manager before deployment.
- Add the new credential while the old one still works, when overlap is supported.
- Verify the new credential through the real request path.
- Move every client, operator, or service to the new value.
- Remove or revoke the old credential.
- Confirm that the old value no longer authenticates.
- Record the time, owner, scope, and verification result.
Rotate a static client key
Static client keys are stored as SHA-256 hashes inauth.yaml. The safest rotation keeps both entries active for a short overlap period.
1. Generate the replacement
auth.yaml.
Use the exact lowercase hash printed by the generator or sha256sum.
2. Keep both keys temporarily
3. Reload the file
4. Test the new key
- the intended models are visible
- the intended model can be invoked
- quotas are correct
- audit records use the expected owner; static keys do not populate a stable
key_id
5. Move applications to the new key
Update every application, job, SDK, proxy, and secret reference that uses the old value. Keep the overlap only as long as necessary. Two active credentials increase the number of values that can be exposed.6. Remove the old entry
Delete the old key fromauth.yaml, send SIGHUP again, and verify that it now returns:
Rotate a dynamic client key
Dynamic keys live in the in-memory registry and take effect immediately after a successful administration API mutation.Safer overlap with two IDs
Create a second registry entry with a new ID and hash:Immediate replacement under one ID
Updating an existing ID with a new hash removes the old hash mapping immediately. This is useful for emergency revocation, but it does not provide an overlap period. Applications still using the old raw key begin receiving401 as soon as the mutation succeeds.
Restart behavior
Dynamic registry state is memory-only. After a router restart, repopulate the complete current registry before expecting client authentication to work. Use:Rotate administrator keys
Administrator keys come from the comma-separated environment variable:- Restart or recreate the router so the process receives both values.
- Test the new key against
/admin/health. - Update operators and control services.
- Change the environment to contain only the new key.
- Restart or recreate the router again.
- Verify that the old key returns
401.
Hivenet Router can rebuild the administrator provider on
SIGHUP, but it reads the environment of the already running process.Editing a systemd EnvironmentFile, Docker .env file, Kubernetes Secret, or shell configuration does not change that process environment. In normal deployments, restart or recreate the router after changing HIVENET_ROUTER_ADMIN_API_KEYS.Rotate the agent JWT secret
The router and every agent use one shared secret for:- HMAC-SHA256 agent JWTs
- the deterministic gRPC TLS identity pinned by agents
--jwt-secret-file is configured, it takes precedence over HIVENET_ROUTER_JWT_SECRET. Rotate the source each process actually loads.
Agent-secret rotation requires a coordinated maintenance operation.A router using the new secret cannot authenticate agents still using the old secret. An agent using the new secret cannot authenticate with a router still using the old one.
Planned rotation
- Generate the replacement:
- Distribute the new file securely to the router and every agent host without restarting the running processes.
- Confirm the deployed file hashes without printing the secret:
- Drain or pause client traffic when interruption is unacceptable.
- Replace the configured secret file on the router and agents.
- Restart the router.
- Restart all agents promptly so they load the new secret and reconnect.
- Verify agent registration through
/admin/healthand/admin/routing-table. - Resume traffic after sufficient capacity is healthy.
- Remove old secret material from hosts and deployment systems according to your retention policy.
Higher-availability option
When the deployment cannot tolerate this control-plane interruption, build a separate replacement deployment with its own router, secret, and agent fleet, validate it, then move client traffic to it. The current single-router architecture does not provide an in-place zero-downtime dual-secret rotation.Rollback
Keep the old secret protected until the new fleet is verified. To roll back, restore the old value on the router and every agent and restart them again. Do not leave hosts on different secret generations.Rotate provider API keys
Provider fallback credentials are read by the router at startup:- Create the new credential in the provider account.
- Update the router secret or environment.
- Restart the router.
- Force a controlled provider-fallback request.
- Confirm the expected provider, model, usage, and audit result.
- Revoke the old provider credential in the provider account.
Respond to a suspected compromise
After containment:
- inspect audit records and authentication metrics
- identify affected tenants, models, and time ranges
- review unexpected dynamic-registry or policy changes after an admin-key exposure
- inspect registered agents after an agent-secret exposure
- review provider usage and billing after a provider-key exposure
- rotate related credentials only when there is a plausible path to their compromise
Verify a completed rotation
Client key
401 after revocation.
Administrator key
Agent secret
Provider key
Use a temporary policy or controlled condition that exhausts local routing, then confirm:Troubleshooting
The new static key returns 401
Check that:
- the application sends the raw key, not its SHA-256 hash
- the hash in
auth.yamlwas generated from the exact raw value - the successful
SIGHUPreload appears in router logs - the key has not already expired
- the request reaches the intended router
The old static key still works
Confirm that its entry was removed from the file that the running router actually loads, then sendSIGHUP again.
A failed reload leaves the previous provider active.
A dynamic mutation returns 409 stale version
Read the current version:
The new administrator key returns 401
The running process probably still has the old environment.
Restart or recreate the router after updating HIVENET_ROUTER_ADMIN_API_KEYS.
Agents do not reconnect after secret rotation
Check that:- the router and every agent loaded the same new secret
- the secret contains at least 32 bytes
- agents can reach the router’s gRPC and libp2p ports
- all affected processes were restarted
- no host still references an older secret file or secret version
Provider fallback fails after rotation
Confirm that:- the router was restarted
- the active policy still declares the provider
- the new credential can access the configured provider model
- provider billing or project limits permit the request
- the test request uses the supported non-streaming fallback path
Rotation checklist
- identify the credential type and every consumer
- choose overlap or immediate revocation
- generate and store the replacement securely
- preserve model restrictions and quota ownership for client keys
- use a strictly newer dynamic registry version
- account for router restarts where required
- account for quota-reset behavior during static-auth reloads
- test the new credential before removing the old one when risk allows
- verify that the old credential no longer authenticates
- check audit records and metrics after the change
- remove temporary overlap values and files
- document the outcome and next scheduled rotation
Next steps
API keys
Review static and dynamic client-key configuration and persistence.
Authentication overview
Understand the separate trust boundaries behind each credential.
Audit logging
Correlate credential use, denials, tenants, models, and request outcomes.

