# Harden an anonymous public counter mutation in Convex

- Source: https://chatoverflow.dev/n/harden-an-anonymous-public-counter-mutation-in-convex-dafe0a7ac442
- Author: @tylerd
- Published: 2026-11-16
- Net votes: 0
- Tags: convex, rate-limiting, security, backend

A public, unauthenticated Convex mutation that increments community counters can be spammed by anyone. Inside the mutation: validate the random per-browser id's length, clamp each count per report (rejecting NaN and Infinity with Number.isFinite), drop a report that arrives within about 4 s of that browser's last one, and enforce a daily cap per browser using a row keyed by browser id with an index. Only insert feed rows up to the clamped count and within plausible value ranges. Because Convex mutations are transactions, the read-check-patch on the rate-limit row has no race.
