Skip to content

feat(server): protect verification hash and delete token at rest - #164

Merged
dillonstreator merged 1 commit into
mainfrom
claude/issue-69-investigation-ec1af4
Nov 6, 2026
Merged

dillonstreator merged 1 commit into
mainfrom
claude/issue-69-investigation-ec1af4

Conversation

@dillonstreator

@dillonstreator dillonstreator commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Closes #69

Problem

Redis stored the verification hash h and delete token dt in plaintext. Someone holding a dump but not ENCRYPTION_KEY could:

  • send h to GET /vault/:id, using up a read or burning the secret and firing a false READ webhook
  • use dt to delete any secret
  • on legacy links, guess a password at one SHA-512 per attempt, if they also had the URL key

Changes

  • h: stored as hm1: + HMAC-SHA256, keyed through HKDF from ENCRYPTION_KEY and bound to the vault ID. The digest is deterministic, so the Lua script is unchanged and reads stay atomic. No distributed lock is needed.
  • dt: encrypted with machine.encrypt, not digested, because webhook payloads return the original value to the creator.
  • Docs: updated the spec, README and field descriptions. Verification hash descriptions were out of date (SHA-256/SHA-512 only, with no mention of Argon2id).

The API and clients are unchanged.

Review notes

  • Stolen digests: the stored format selects the comparison, never the request, so a digest from a dump can't be submitted as h.
  • Existing entries: plaintext h and dt keep working until they expire. The fallback can be removed once this has been deployed for the 7-day max TTL.
  • Changing ENCRYPTION_KEY: every unexpired entry written after this change now returns a 500 until it expires or the old key is restored, not only those with IP or webhook options. Attempts aren't counted, so nothing burns.

Not covered

  • A compromised API server still exposes ENCRYPTION_KEY.
  • c, m, cd, ttl, the counters and wh.n stay in plaintext. A dump plus the URL key still allows password guessing against c, at the content layer's Argon2id cost.

Testing

  • Server: 15 of 15 pass, 7 of them new, covering storage format, digest and token replay, legacy entries, webhook dt and key changes.
  • Core: 51 of 51 pass, run directly with --testMatch because pnpm test found no tests in this Windows worktree path.
  • Typecheck passes for core and server. Lint has no errors.
  • pnpm test:e2e was not run locally.

One local server run failed after about 34 seconds, and the reason was cut off by filtered output. A later run hit ECONNRESET after the local Redis container was restarted on the same port, and 7 further runs passed. A connection problem is likely but unconfirmed for the first failure.

A Redis dump exposed `h` and `dt` in plaintext, which was enough to burn or
delete a secret and gave legacy password links a fast offline guessing oracle.

Store `h` as an HMAC-SHA256 digest keyed from ENCRYPTION_KEY and bound to the
vault ID. The digest is deterministic, so the Lua script still compares
atomically and no distributed lock is needed. The stored format selects the
comparison, so a stolen digest can't be submitted as `h`.

Encrypt `dt` rather than digesting it because webhook payloads return the
original value to the creator.

Existing entries keep working until they expire.

Closes #69
@dillonstreator
dillonstreator force-pushed the claude/issue-69-investigation-ec1af4 branch from 56b7183 to 1ff0ad8 Compare November 6, 2026 22:24
@dillonstreator
dillonstreator merged commit 58cc940 into main Nov 6, 2026
8 checks passed
@dillonstreator
dillonstreator deleted the claude/issue-69-investigation-ec1af4 branch November 6, 2026 22:28
@github-actions github-actions Bot mentioned this pull request Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Encrypt hash at rest

1 participant