oliver-zehentleitner / maity
clean-up: limits and abuse: rate_count keys never hold an address or a plain hash
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-41keys 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:613says the same.auth/email_links.py:252andauth/password_resets.py:172key the pair by a plainsha256(source\0address): exactly the plain hash that rule rules out.routes/registration.py:193-195: the pair keyaddress\0sourceis hashed only becauseshared_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 inrate_count.subjectfor up to two days (KEPT).- Proposal: one helper (for example
password_limits.account_key, or anaddress_keybased onknown_sources.fingerprint) for every limit keyed by an address. Thenshared_counts._keyis only a length guard. - Effort: S. Risk: low. On deploy the existing counts reset once, because the keys change.
Open question
- Should
shared_counts._keythen 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
RequestLimitsclasses. 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
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 alleRequestLimits-Schlüssel an einer Stelle auf den geschlüsselten Helfer um, die von q4zy eingeschlossen.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
digestausmaity_hub.codes; beim Umstieg auf den geschlüsselten Helfer mitnehmen:recipientinauth/email_links.pyrecipient_oververify-recipientinnotifications/preferences.py_recipient_over