Repository navigation
fix(student): limit verification codes to five a day per person - #88
lorenzocorallo wants to merge 1 commit into
Conversation
Each new code reset the five-guess limit and only a 60-second cooldown applied, so one account could guess about 7,200 codes and send 1,440 emails a day. Count sent codes per person in a new table and refuse a sixth within 24 hours.
|
No actionable comments were generated in the recent review. WalkthroughStudent verification requests now have a per-user limit of five sends in a rolling 24-hour window. The change adds send-record storage, rejects requests at the limit, and adds integration tests and audit documentation. ChangesStudent verification send limit
Change: Bug fix Merge Risk:
|
Before
To prove you are a student, you ask for a six-digit code at your
@mail.polimi.itaddress. Each code allows 5 wrong guesses. The only limit on asking for codes was 60 seconds between requests. Each new code started again from 0 guesses.Anyone can make an account with Google. So:
Now
One person can ask for at most 5 codes in any 24 hours. The sixth gets a 429 with "You asked for too many codes. Try again tomorrow." and no email is sent. That is 25 guesses a day (0.0025%) and 5 emails a day per account.
student_verification_send, with one row per code. It is not on the challenge row, so a new code, a confirmation, a failed email, or another account asking for the same address does not reset it.on delete cascade).This adds migration
0025_student_verification_daily_limit(made withvp run db:generate). The audit doc now mentions the daily limit.Tests
New tests in
src/auth/student-verification.integration.test.mjs:Run against a fresh PostgreSQL 18 in Docker:
vp check: passvp test: passvp run db:migrateandscripts/migrate.mjs, anddb:generateafterwards finds no changesNote: the commit is not signed, because the 1Password signing agent refused in this session.