mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
The Apple Health batch endpoint accepted 500-row payloads with no per-user write cap. A leaked wildcard iOS token could sustain unbounded inserts (500 rows × N batches/sec) and degrade the database for every other user on the host. Gate the write path with the shared `checkRateLimit` helper at 60 batches/min/user — generous for legitimate iOS sync (the HealthKit observer coalesces well below one batch/minute on a quiet device, and 60/min × 500 rows = 30 000 rows/min headroom) and tight enough that a misbehaving client bottoms out within a minute. Returns 429 with an unambiguous message so the iOS client can back off and retry rather than assume the row landed. Integration test exercises the over-limit path by pre-seeding the `rate_limits` counter at the cap.