Skip to content

Security findings M2–M4: email cap with digest, submission clean-up, rate limit address - #56

Merged
nicolasmesser merged 2 commits into
mainfrom
claude/project-thread-vpgvb6
Nov 29, 2026
Merged

nicolasmesser merged 2 commits into
mainfrom
claude/project-thread-vpgvb6

Conversation

@nicolasmesser

@nicolasmesser nicolasmesser commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Fixes M2 and M4 from the security review. M3 (the rate limit address) follows in this PR once the header check is done. M5 needs no code.

M2: protect the shared email budget

  • Review email cap: notify-submission sends at most settings.review_emails_per_day (default 20) review emails a day (UTC). Later submissions get no email of their own.
  • Evening digest: a pg_cron job at 19:00 UTC calls the function with {"type": "DIGEST"}. Every pending submission that hasn't been emailed goes into one email, which also points to the submissions_open emergency switch.
  • Tracking: a new column event_submissions.review_email_sent_at records when each submission was emailed. Existing rows are backfilled.
  • Sign-in message: a separate message when Supabase's site-wide email limit (over_email_send_rate_limit) is hit: "try again later or tomorrow, or write to swim-events@proton.me". The per-visitor "wait a few minutes" message stays.
  • Dashboard setting (Nico): Authentication, then Rate Limits, set to 10 sign-in emails per hour.

M4: clean-up promised in the privacy policy

  • Daily job: pg_cron at 02:00 UTC deletes spam submissions after 7 days, and rejected or withdrawn ones after 30 days. Withdrawals count from when they were sent.
  • Privacy policy: rejected or withdrawn submissions are now kept 30 days instead of 90, and the "last updated" date is changed.
  • Blocked accounts stay blocked, because the block lives on the profile.

Database

  • Migration: supabase/migrations/20261129000000_email_cap_and_cleanup.sql turns on pg_cron, adds both columns, and schedules both jobs.
  • Vault secret: the digest job reads the webhook secret from Vault (notify_webhook_secret), so it never appears in the repository. It's created once before the migration is applied.

Tested

  • deno test for the functions: 8 passed, including a new digest email test.
  • astro check and eslint pass.

After merging

  • Apply the migration and deploy notify-submission. Claude does this, after the Vault secret exists.
  • Nico: set the sign-in email limit to 10 per hour.
  • Check that cron.job lists review-digest and submissions-cleanup, and that the first runs succeed (cron.job_run_details).

Generated by Claude Code

- notify-submission sends at most settings.review_emails_per_day (20) review
  emails a day; later submissions go into one evening digest (pg_cron)
- Daily clean-up job: spam after 7 days, rejected and withdrawn after 30
- Privacy policy: rejected and withdrawn submissions kept 30 days
- Sign-in: its own message when the site-wide email limit is reached

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BtKM4TZ917FEo7VwVUDwjU
@netlify

netlify Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for swim-events ready!

Name Link
🔨 Latest commit b5425b5
🔍 Latest deploy log https://app.netlify.com/projects/swim-events/deploys/6b0c4c233f59731f106396e6
😎 Deploy Preview https://deploy-preview-56--swim-events.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Tested on the live function: a faked X-Forwarded-For was replaced by the
gateway, and a request with its own CF-Connecting-IP got 403 from Cloudflare.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BtKM4TZ917FEo7VwVUDwjU
@nicolasmesser
nicolasmesser marked this pull request as ready for review November 29, 2026 16:01
@nicolasmesser
nicolasmesser merged commit ba488b3 into main Nov 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants