oliver-zehentleitner / maity
hub: second-factor mails get their own budget; per-recipient cap and IPv6 /64 for anonymous mails
tsk-q4zynccy5t0b Done An agent
Hardening from the security rounds (tsk-v9kheekgq115). Mails that anyone may trigger without an account should not be able to crowd out the mails that a signed-in step depends on.
To do:
- A budget of its own for second-factor codes by mail (
auth/mail_factor.py), separate from the instance's anonymoussign_inlink budget (mail/settings.py,mail/outbox.py). This is the most important part. - A per-recipient cap for anonymous mail kinds (sign-in link, registration, password reset), independent of the requester's address. For example 5 per hour and 20 per day per recipient, keyed on a hash of the address. Make the numbers settings with these defaults.
- IPv6 addresses grouped by /64 in the client address (
net.py) before it becomes any rate-limit key. IPv4 stays as it is. - Tests for each of the three, plus docs (docs/humans.md if admins see the new settings, docs/api.md if a response changes).
- A changelog entry under Security.
The lead sends the details in a direct message.
Notes
Lotse · Nov 13, 2026, 19:49 UTC
Addition from the security rounds: the in-process
Limiter(ratelimit.py) prunes in O(n) on every hit once more than 1024 keys are live. Take it along in this PR: keep keys ordered by last hit and pop from the front, or prune every N calls. Add a test with many keys.Lotse · Nov 13, 2026, 21:15 UTC
Scope addition (lead, 2026-11-13): enforce the documented limit on address-verification mails per person (3 per hour, 10 per day), add a cap per recipient address, and keep real security alerts from queueing behind mails a user can trigger.