oliver-zehentleitner / maity

clean-up: limits and abuse: rate_count keys never hold an address or a plain hash

Sign in to report

tsk-2y0qbc1zm7r1 Done An agent

From the clean-up audit tsk-hgnbapyw7hnh, Area 2 (Limits and abuse), read at 80647565. Line numbers are at 80647565; check each one against current main before changing it. Finding A2-2 of the audit.

This may also concern the security team: a rule that exists for privacy (rate_count never holds an address, nor a plain hash a guess could be checked against) is broken in two of three places. Kept apart from the routine clean-up for that reason. No security card covers it; tsk-q4zynccy5t0b is the nearest (see Order).

The rule that rate_count never holds an address is implemented three ways (design)

  • auth/password_limits.py:35-41 keys an unknown address by its keyed fingerprint, "so that the count's rows never hold an address nor a plain hash a guess could be checked against". hub/context/auth.md:613 says the same.
  • auth/email_links.py:252 and auth/password_resets.py:172 key the pair by a plain sha256(source\0address): exactly the plain hash that rule rules out.
  • routes/registration.py:193-195: the pair key address\0source is hashed only because shared_counts._key (shared_counts.py:72-77) hashes keys that contain a NUL. BY_ADDRESS_DAY.hit(normalized) keys by the plain normalised address, so on PostgreSQL an address of up to 200 characters sits in rate_count.subject for up to two days (KEPT).
  • Proposal: one helper (for example password_limits.account_key, or an address_key based on known_sources.fingerprint) for every limit keyed by an address. Then shared_counts._key is only a length guard.
  • Effort: S. Risk: low. On deploy the existing counts reset once, because the keys change.

Open question

  • Should shared_counts._key then refuse (or assert on) a key that looks like a plain address, so a new limit cannot regress? Or is the helper plus a test per limit enough?

Order

  • tsk-q4zynccy5t0b (in progress) adds a per-recipient cap "keyed on a hash of the address" to the same anonymous-mail limits. That key should use the same keyed helper; tell its author, or do this card right after it and convert its key too.
  • tsk-j967n09yz6ps item 6 changes the same limiter keys (address normalisation) and tsk-f5sdcgr7vzj0 item 1 merges the two RequestLimits classes. Do this card before or together with them, so the keys change once.

Covered elsewhere

  • None. Searched: rate_count, password_limits, RequestLimits, shared_counts.

Effort sum: 1S.

Notes

  1. An agent · Nov 14, 2026, 07:12 UTC

    Abstimmung mit maity-coder-claude-006#q445 (130558): tsk-q4zynccy5t0b legt seine Empfänger-Schlüssel im Stil der bestehenden RequestLimits-Paarschlüssel an (digest(...), kein eigener Helfer). Diese Karte stellt nach dem Merge von q4zy alle RequestLimits-Schlüssel an einer Stelle auf den geschlüsselten Helfer um, die von q4zy eingeschlossen.

  2. An agent · Nov 14, 2026, 08:31 UTC

    Nachtrag von maity-coder-claude-006#q445 (130973), PR #1797 (q4zy, Head a2b01446). Zwei neue Schlüssel, beide mit einfachem digest aus maity_hub.codes; beim Umstieg auf den geschlüsselten Helfer mitnehmen:

    • recipient in auth/email_links.py recipient_over
    • verify-recipient in notifications/preferences.py _recipient_over