Emails 0.1.23: Sign-in and reset links no longer land in the email log
Emails 0.1.23 is a security fix: the one-time tokens in password reset, confirmation, magic link and invitation emails are no longer stored in the email log.
PhoenixKit keeps only a hash of each emailed token, so the link in the email was its only copy. With email bodies saved, the log stored it in plain text. Anyone with the emails permission, which the Admin role has by default, could request a password reset for any address and open the working link from /admin/emails. The module now replaces the token with [REDACTED] before the log row is written, while keeping the link itself, so the log still shows what was sent. This covers every auth link core sends, in the path or in a query parameter such as ?invitation=, and works on long bodies and on routes with capital letters. Queued messages keep the real link, since the queue delivers it.
Upgrading
Update the dependency. Emails logged before the update still hold their tokens.
Full release notes: Emails 0.1.23
0.1.23 · 7 August 2026
Security
- Single-use auth tokens no longer reach the email log. PhoenixKit stores only a SHA-256 hash of every emailed token, so the raw token existed in exactly one place — the message sent to the user. Logging the body put it back in the database in plaintext, behind the
emailspermission that the Admin role holds by default. That turned the log into a credential store: request a password reset for any address on the public forgot-password page, then read the working link out of/admin/emailsand use it, never touching the target’s mailbox. The newSecretScrubberreplaces the token with[REDACTED]on the way IN, before the row is written, so exports, S3 archival, backups and support dumps are all covered by the one control. It covers every auth URL core emails — reset, confirmation, email change, magic link, magic-link registration (path segment) and organisation invitation (?invitation=) — and leaves the link itself in place, so the row still shows what was sent and where it pointed. The send queue is deliberately excluded:Queue.serialize/1args are the message in transit, and redacting there would mail the recipient a dead link. (#27)
Fixed
- The scrubber could silently fail open on a slash-heavy body. Its URL pattern reached the auth segment through two overlapping lazy quantifiers that both consume
/-delimited path segments, giving a quadratic number of ways to split the path at every start position. Past roughly 20 KB of such text PCRE hit its internal backtracking limit — andString.replace/3signals nothing on that, it returns the subject unchanged. A real token further down the same body was then written to the log in plaintext while the row looked scrubbed, which is worse than not scrubbing at all, because nothing downstream can tell the difference. The pattern now anchors on/<auth-segment>/instead of onhttps?://…and has no quantifier that spans a path separator, so matching is linear: the 82 KB case went from 105 ms and leaking to 1.4 ms and redacted. Nothing is lost — every auth route core emails puts the token immediately after the segment, and the locale and host-app prefixes the old middle group was written for sit before the segment, not between. (#27) - The path pattern is case-insensitive, matching the query pattern, which already was. A host app that mounts its routes with any uppercase in the path had the query form scrubbed and the path form leaked. (#27)
Internal
- Post-merge review of #27:
dev_docs/pull_requests/2026/27-scrub-single-use-auth-tokens/CLAUDE_REVIEW.md. Cross-checked the segment whitelist against every:tokenroute core registers and every URL its notifiers actually send — the whitelist is complete, and the three uncovered token routes (on-screen QR login, the post-verify redirect, signed asset URLs) are correctly out of scope. The route-enumeration test gainedconfirm-email, the one whitelist entry that is a prefix collision with another (confirm) and so only matched by backtracking; the alternation now lists it first. Rows written before this release still hold their tokens — not backfilled, and why not is recorded in the review.
Emails 0.1.23. Install or update: {:phoenix_kit_emails, "~> 0.1"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.