Skip to content

Issue 32-character password reset codes - #1552

Draft
w3irdrobot wants to merge 2 commits into
masterfrom
feat/reset-code-32
Draft

w3irdrobot wants to merge 2 commits into
masterfrom
feat/reset-code-32

Conversation

@w3irdrobot

@w3irdrobot w3irdrobot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Password reset codes (both user and platform) go from 8 to 32 uppercase alphanumeric characters ([A-Z0-9]).
  • A submitted reset code is now matched without regard to case or whitespace. The backend strips all whitespace and ASCII-uppercases the code before lookup, on both the user and platform paths. Before this, lookup was by the exact string, so a code retyped in lowercase or pasted with stray whitespace failed and spent one of the reset request's attempts. This is the backend half of Research password reset: reset-code regex is too strict (rejects lowercase) #1580; the Research form half is Loosen the Research reset-code check to non-empty input #1598.
  • generate_alphanumeric_code moves out of AppState into a free function, since it never used self. The new normalize_password_reset_code sits next to it, and both are unit-tested.
  • In the Maple password-reset email, the code was shown at 34px with 9px letter spacing (.code-lg), so a 32-character code would overflow the email. It now renders at 18px monospace with word-break: break-all, and the unused .code-lg rules are gone.

Email verification codes are unchanged. They are already UUIDv4s (32 hex digits).

Behavior to be aware of

  • Normalization removes only whitespace and changes only ASCII letter case. Any other character (a hyphen, for example) is kept, so the lookup misses and the attempt is spent as before.
  • Uppercasing is only correct while issued codes are uppercase-only. If the code format ever gains lowercase letters, the normalizer has to change with the generator.
  • There is still no length or charset validation on the submitted field; the lookup is the check.

Rollout

Validation

In services/opensecret through the pinned Nix shell, on the current head (rebased onto master):

  • cargo fmt --all -- --check: pass
  • cargo clippy --locked --all-targets --all-features -- -D warnings: pass
  • cargo test --locked --all-features: 1197 passed, 0 failed, 106 ignored
  • Disposable-Postgres suite (disposable_db_tests.sh): 102 passed, none skipped, including a /password-reset/v2/options route test that submits lowercase and spaced codes

Not run: an end-to-end reset in a local stack, an EIF build, or rendering the email in a real mail client.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@w3irdrobot

Copy link
Copy Markdown
Contributor Author

this builds on #1550. we should allow our frontends to be updated for a while before starting to dole our 32 character codes

@AnthonyRonning AnthonyRonning left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on hold for a few weeks at least

@AnthonyRonning
AnthonyRonning marked this pull request as draft November 10, 2026 19:40
w3irdrobot and others added 2 commits November 12, 2026 20:39
Raise emailed password reset codes (user and platform) from 8 to 32
uppercase alphanumeric characters. Move the generator out of AppState
since it never used self, and add a unit test for length and charset.

The Maple reset email showed the code with large, widely spaced type
that a 32-character code would overflow. Render it at 18px with
break-all wrapping instead, and drop the now-unused .code-lg rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reset codes are looked up by the exact string submitted, so a code
retyped in lowercase or pasted with stray whitespace missed and spent
one of the reset request's attempts. Only the Research form cleaned the
code up; other SDK clients sent it as typed.

Strip whitespace and ASCII-uppercase the submitted code before lookup on
both the user and platform paths. Issued codes are uppercase A-Z0-9, so
they are unchanged by this and codes already issued stay valid.

Refs #1580

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@w3irdrobot

w3irdrobot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Heads up: this branch was force-pushed. It is rebased onto current master, and it now carries a second commit.

  • 329df6f7 is the original 32-character change, replayed onto master with no content changes.
  • dbf482d4 is new: the backend strips whitespace and ASCII-uppercases a submitted reset code before lookup, on both the user and platform paths. This is the backend half of Research password reset: reset-code regex is too strict (rejects lowercase) #1580, which asked for reset codes to stop being case-sensitive. A code retyped in lowercase or pasted with stray whitespace now matches instead of failing and spending an attempt.

It sits here because it is an enclave change and this PR already needs an EIF build and PCR approval. The Research form half of #1580 is in a separate frontend PR.

Issued codes are uppercase A–Z0–9, so normalization leaves them unchanged and 8-character codes issued before the deploy keep working.

Validation on the rebased tree, in services/opensecret through the pinned Nix shell:

  • cargo fmt --all -- --check: pass
  • cargo clippy --locked --all-targets --all-features -- -D warnings: pass
  • cargo test --locked --all-features: 1197 passed, 0 failed, 106 ignored
  • Disposable-Postgres suite (disposable_db_tests.sh): 102 passed, none skipped, including a /password-reset/v2/options route test that submits lowercase and spaced codes

Not run: an end-to-end reset in a local stack, or an EIF build.

The "deploy only after #1550 is live" note in the description is out of date: #1470 replaced that form, and the form on master already accepts 8 to 32 characters (any non-empty code once #1598 merges).

This branch has not been deployed

No deployments
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.

2 participants