Title: id(directory_auth): pending email codes are never evicted — the codes map keeps every expired code whose address never comes back · Issue #1732 · developing-today/code · GitHub
Open Graph Title: id(directory_auth): pending email codes are never evicted — the codes map keeps every expired code whose address never comes back · Issue #1732 · developing-today/code
X Title: id(directory_auth): pending email codes are never evicted — the codes map keeps every expired code whose address never comes back · Issue #1732 · developing-today/code
Description: Problem DirectoryAuth's pending email-code map grows forever: an entry is only ever removed when that same address comes back to check_code (or re-issues after the resend minute). A code that is issued and never checked — the normal case...
Open Graph Description: Problem DirectoryAuth's pending email-code map grows forever: an entry is only ever removed when that same address comes back to check_code (or re-issues after the resend minute). A code that is is...
X Description: Problem DirectoryAuth's pending email-code map grows forever: an entry is only ever removed when that same address comes back to check_code (or re-issues after the resend minute). A code that i...
Opengraph URL: https://github.com/developing-today/code/issues/1732
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"id(directory_auth): pending email codes are never evicted — the codes map keeps every expired code whose address never comes back","articleBody":"## Problem\n\n`DirectoryAuth`'s pending email-code map grows forever: an entry is only ever removed when that same address comes back to `check_code` (or re-issues after the resend minute). A code that is issued and never checked — the normal case for a mistyped address, an abandoned sign-in, or a bot probing many addresses — stays in the map for the life of the process, long past its 15-minute expiry.\n\n## Evidence (verified this run on main `8c8d1bbb`, line trace)\n\n- `pkgs/id/src/directory_auth.rs:112` — `codes: HashMap\u003cString, PendingCode>`, keyed by address.\n- `pkgs/id/src/directory_auth.rs:157-179` — `issue_code` inserts/overwrites one entry per address; it never sweeps expired entries for other addresses.\n- `pkgs/id/src/directory_auth.rs:186-200` — `check_code` is the only place an entry is removed (on success, on expiry, or on exhausted attempts) — and only for the address being checked.\n- `pkgs/id/src/directory_auth.rs:27` — `CODE_TTL_MS = 15 * 60 * 1000`: entries are dead after 15 minutes but are retained indefinitely.\n- The neighbouring maps in the same file DO sweep, so the omission is an asymmetry, not a design rule: sessions are swept in `open_session` (`directory_auth.rs:118`, `retain(|_, record| record.expires_at > now)`), and the signed-request replay guard sweeps in `accept` (`directory_auth.rs:250`, retain on `SIGNED_WINDOW_MS`).\n- Callers: `pkgs/id/src/directory_view.rs:1219` (confirm) and `:1244` (sign-in) call `issue_code` for an address supplied in the request, so distinct addresses accumulate entries at request rate; nothing else touches the map (grep over `src/` for `issue_code`/`check_code`/`.codes` — only `directory_auth.rs` and those two call sites).\n\n## Why it matters\n\nThis is a long-lived server process (a hosted world). The map grows by one entry per distinct address that ever requests a code and does not complete the flow, with no bound and no eviction — the same unbounded-growth class as #1713 (SaveRateLimiter) and #1730 (WaitingPool arrived set), but in the auth surface, where an unauthenticated caller controls the key (the email address). It also contradicts the module's own framing (`directory_auth.rs:5-7`): pending codes are supposed to live only until \"its time is up\".\n\n## Suggested direction (for triage to pin)\n\nMirror the session sweep: retain only unexpired entries when `issue_code` runs (it already receives `now`), and/or sweep at the top of `check_code`. Keep behaviour otherwise identical: the resend-minute rule, the 5-attempt cap, and the digest-only storage all stay.\n\n## Acceptance criteria\n\n- [ ] After a code's 15-minute expiry, its entry is evicted without that address ever calling `check_code` (unit test: issue for address A, advance the clock past expiry, issue/check for address B, assert A's entry is gone — e.g. via the map's observable size or a re-issue behaving as a fresh entry).\n- [ ] Unexpired codes still verify, the 60-second resend refusal still applies, and the 5-attempt exhaustion still removes the entry.\n- [ ] Issue/check behaviour for live codes is unchanged; existing `directory_auth` tests still pass (laptop or CI).\n\n## Dedup\n\nSearched open + closed issues and code search for `DirectoryAuth`, `issue_code`, and pending-code/expiry terms before filing: no filing covers this map. #1713/#1726/#1730 are the same unbounded-growth class in other components (web save limiter, outbox, waiting pool), not this one.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-28T16:48:23Z","url":"https://github.com/developing-today/code/issues/1732"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d33d306e-82c6-8297-9dc3-cd6635eca476 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D3C0:5F360:360C4F:46E7AB:6B06178E |
| html-safe-nonce | 772a7e3431c6da6c61ab717b792100a022576a7874217dd3c490b9a2d36e6b4c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0MwOjVGMzYwOjM2MEM0Rjo0NkU3QUI6NkIwNjE3OEUiLCJ2aXNpdG9yX2lkIjoiODA4MjQwMjgzMTAyNzgwNDA0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b39f144e591a3dc05bc32d19ec95bb8806d9b6d655261f019147d0f7ef583dc1 |
| hovercard-subject-tag | issue:6083446046 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/1732/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ca9a1fc1cb20af63f1d9ebf90818d6f7310a7f7f0541b74c504595ee9ac3fbc1/developing-today/code/issues/1732 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ca9a1fc1cb20af63f1d9ebf90818d6f7310a7f7f0541b74c504595ee9ac3fbc1/developing-today/code/issues/1732 |
| og:image:alt | Problem DirectoryAuth's pending email-code map grows forever: an entry is only ever removed when that same address comes back to check_code (or re-issues after the resend minute). A code that is is... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 97d4714e567728e1f85f88b0cf68c89f0f8a3dc41e8869af7aeb8195ad990374 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 866f202ebf7ac5aff8f633417d9fd8a53818a977 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width