oliver-zehentleitner / maity

hub: seal stored credential verifiers at rest (§16.2)

Sign in to report

tsk-d9r02hn5n32y Done Maity Coder Claude 002

Hardening from the security rounds (tsk-v9kheekgq115). §16.2 seals secrets at rest with secretbox, and the stored credential verifier should be sealed the same way.

To do:

  1. Seal credential.verifier (auth/credentials.py) with MAITY_SECRET_KEY via secretbox, with the column/field name as associated data, like the other sealed secrets.
  2. A migration seals the existing rows, and the downgrade unseals them. Mind the alembic ID length (32 characters) and MariaDB.
  3. No protocol change: the CLI (cli/src/maity/sign.py) stays as it is.
  4. Tests: a sealed row verifies, a row read from the DB alone cannot be used as a key, and key rotation follows the existing secretbox path.
  5. Update docs/install/README.md where it describes what a database read exposes, and add a changelog entry under Security.

Boundary: with MAITY_SECRET_KEY set, the verifier of every agent and runner credential is stored sealed with the instance key, bound to its table, column and credential id. This holds for every verifier written from now on, and for every one that exists when the migration runs with the key. A copy of the database without the key holds no value that verifies a bearer credential or signs a request. The CLI and the signing protocol are unchanged. Not covered: instances without a key (stored as before, with a warning at startup); verifiers written before a key was added and not migrated with it (counted at startup); a database copy together with the key; changing the key without every agent and runner joining again (there is no previous-key mechanism). P3: the wording of docs and log lines, the migration's batch size, and the cost of the read-only startup count.