Anti-abuse for a solo-dev browser game leaderboard: stopping floods without storing IP addresses

Doodle Stack, our drawing-and-stacking browser game, has global leaderboards and ranked matches with strangers. Both launched on October 19, 2026, and on October 22 we added a round of anti-abuse measures.

This is a record of what we thought about, and what we put where. It's for solo developers who want leaderboards or online play in a small browser game without logins. The leaderboard and matchmaking server is only Cloudflare Pages Functions and D1 (SQLite); we run no dedicated server. (Direct device-to-device play uses PeerJS's public server.)

So as not to help abusers, we don't list actual limits, the blocked words, or detailed ban criteria. Only the thinking and where we got stuck.

The setup

As of October 23, 2026:

Thing Details
Global leaderboards Solo records. Per difficulty: pieces stacked or height, this week or all time, plus a board for the Daily Challenge
Ranked matches The server pairs players with similar ratings, then the two devices connect directly. Wins and losses move the rating
Identifying players No login. A random per-device ID saved in the browser, with one best record per ID on the board
Versions Separate boards for the Japanese version and the English version on CrazyGames. Both call the same API

What prompted the review: the English version went live on CrazyGames, and records started arriving from strangers abroad. We build this site with AI (Claude), and this review and the fixes were done with Claude too.

First decision: we can't stop everything

A browser game's score is just a value the browser sends. The sending side is in the player's hands, so a determined attacker can't be fully stopped. Trying to stop everything leads to logins and heavy verification, too much for a small game. We narrowed it to four goals:

  1. Make abuse more work: holding down a button or running a script shouldn't be enough
  2. If it gets abused, we can clean up fast: have review and ban tools ready
  3. Don't get in normal players' way: set limits where normal play basically never reaches them
  4. Don't hold personal data: don't store IP addresses

Then we put something at each layer, from intake to display:

Layer What we added
Intake Don't read oversized bodies, refuse impossible records, refuse values outside fixed options
Names Blocked words (matching built to resist evasion), no URLs, 10 characters max
Counts Per-IP flood limits and per-device daily limits
Operations A ban table, plus tools for reviewing and banning
Display Short leaderboard cache, device IDs never in any response
Matches "Couldn't connect" reports, a daily cap on decided matches, opponent names and prompts only from the server or the fixed list

Below, roughly in order of how much trouble each caused.

Stopping floods without storing IP addresses

Store only a "blurred" value and a count

To stop floods, we only need to know that many requests came from the same place in a short time. We don't need the IP itself. So we mix the IP with a secret only the server knows, then hash it into something irreversible.

One mistake here. There are only about 4.3 billion IPv4 addresses. If the secret is known, you can try them all and recover the address. The design kept the secret out of the code, in a production secret setting, but the review found the setting was missing, and it was running on a fixed fallback value in the code. On October 22 we set the production secret; nobody has seen its value. "Works even without the setting" is convenient, and it's also why nobody noticed the setting was missing.

Count per time window

Counts live in a small dedicated table. The key joins what's being counted, the blurred value (or device ID), and a window number: the current time divided by one hour (or one day). When the window changes, the key changes, so counting starts from 0 naturally. Rows from finished windows are deleted in bulk on the next count.

// counter key = kind | blurred IP | time-window number
key = 'post|' + blurredIp + '|' + Math.floor(now / ONE_HOUR)
// 1. Read first. If at the limit, refuse without writing anything
if (count(key) >= LIMIT) return 429
// 2. Otherwise add 1, again only "while below the limit"
//    (if two requests both pass step 1 at once, the limit still holds)
INSERT ... ON CONFLICT(key) DO UPDATE SET n = n + 1 WHERE n < LIMIT

The key point: at the limit, write nothing. If refused requests still wrote counts or records, the flood itself would load the database. A test checks that a request over the limit increases neither the count nor the records.

Two yardsticks: IP and device ID

We count per blurred IP per hour, and per device ID per day. Clearing browser data changes the device ID, and switching networks changes the IP. Either alone is easy to get around; together they take a lot more effort.

IPv6 needed care. A connection gets a whole block of addresses (usually sharing the first 64 bits) and the device can change the rest freely. Counting full addresses would let someone become "a different person" just by changing the second half. So for IPv6 we count by the first 64 bits only.

Not in the record rows either

The first version (October 19) also wrote the blurred IP into each leaderboard record, for flood counting. But counting only needs the last hour, and keeping it in records keeps it forever.

From October 22, the blurred value lives only in the count table, not in records. Rows written by the earlier version are blanked once they're 2 hours old. What we use and for how long is in our privacy policy.

Blocked words: a contest with evasion

Names on the board go through a blocked-word check. "Refuse if it contains this word" is easy to evade. Evasions we considered:

So we keep the stored name unchanged and build normalized forms only for matching:

matchForm = the entered name
  -> remove invisible characters (zero-width spaces etc.)
  -> remove accents and other marks (keep Japanese voicing marks)
  -> map look-alike letters (Cyrillic etc.) to plain Latin letters
  -> lowercase, and convert katakana to hiragana
  -> remove symbols and spaces
If the name has Latin letters, also make a form with digits/symbols read as letters
If any form contains a blocked word, the name is refused
(the name is stored exactly as entered)

Digit-to-letter mapping only applies to names that contain Latin letters, since mapping all-digit names can make plain numbers look like words. Names that leave no letters or digits after normalization (only symbols, emoji or invisible characters) are refused, because they'd be indistinguishable on the board.

The Scunthorpe problem

Substring matching catches ordinary words and names that happen to contain a blocked word. The famous case is the English town whose name contains a vulgar word and got blocked by filters.

To reduce this, we deliberately left out short words that often appear inside normal words. A few bad ones get through, but not being able to use a normal name is worse. Tests also check that names that should pass do pass: Japanese, English, Cyrillic, accented. Some ordinary names still don't pass; if people run into it, we'll add exceptions.

Names containing something shaped like a URL or email address are refused, so the board can't be used for advertising.

Bans and review tools

Without logins, we ban by device ID. The ban table holds the ID, a note and a timestamp. A banned device's records don't appear on any board (this week, all time, Daily Challenge, rating) and new ones aren't saved. It isn't matched in ranked play, and matches involving it aren't decided.

Review and banning use a small Python admin script with six actions: see new records, see top records one by one (not merged per player, to spot suspicious ones), see top ratings, list bans, ban, unban. It runs SQL against production with Cloudflare's official CLI (wrangler). Three things we were careful about:

Display: caching and never showing IDs

Aggregating on every leaderboard view gets heavy when many people look. So each board's top 20 is kept in the Cloudflare Workers Cache API for 20 seconds. The cache is per data center, so anyone opening the same board within 20 seconds gets it without a query.

The tricky part was marking your own row:

Posting a record clears that version and difficulty's cache, so you see yourself right away. On the other hand, a banned record can take up to 20 seconds to disappear, until the cache expires. We accepted that.

Device IDs never appear in any leaderboard response. A test checks every response body for them, every time.

"constructor" caused a 500 error

The review found that sending something like by=constructor to the leaderboard API returned a 500. The table mapping sort names to SQL fragments was a plain JavaScript object.

const ORDER = { count: '...', height: '...' };
ORDER['constructor']                  // -> Object's function (looks like it "exists")
Object.hasOwn(ORDER, 'constructor')   // -> false (only keys we wrote)

Plain objects also say yes to keys you never wrote, like constructor, so it slipped past the fixed-options check. We now look only at our own keys. The same kind of hole was in the game client: prompts arriving from an opponent's device are now used only if they're really in the game's prompt list, and shown as "?" otherwise.

A hole in ranked play: "couldn't connect"

After the server pairs two players, the devices connect directly. Each device reports its own result.

The review spotted a way to abuse the one-sided rule: after being paired, deliberately don't connect, then report a win. The opponent loses without ever playing.

So the side that couldn't connect now sends a "couldn't connect" report, and if it arrives before the match is decided, the match is void. It's sent when waiting for the opponent times out, when the connection drops before the match starts, or when you press back in the lobby. We also added a timeout for the room creator's side, which had none.

Right after shipping that, we saw the next hole: a loser could send "couldn't connect" after the match and erase the loss. Whether you can connect is clear right after pairing, so the report is now accepted only for a short time after pairing. About 7 minutes passed between committing the anti-abuse changes and committing this fix. A mechanism that closes one hole can open another, so it's worth reviewing again after shipping.

Also in ranked play:

Don't break old clients already out there

Update, November 6, 2026: the CrazyGames Basic Launch ended on October 28 without passing, and on October 29 we decided not to submit there again. Since November 4 the English version runs on our own site. We're leaving this section as it was written, as a record of how we handled a build we couldn't re-upload on our own schedule.

This took the most care. The English build on CrazyGames keeps calling the production API with the old client until we upload a new build there. Uploading is a manual step in their dashboard, so it never lines up exactly with a server change, and some players keep an old tab open after that anyway. (Submission details are in our CrazyGames note.) So server changes followed these rules:

For example, when a banned device posts a record, we couldn't be sure how an old client would handle an error. So we don't save it and return a normal "accepted" with no rank. The old client shows "posted" with a rank of "-". At the rate limit, the old client's existing "too many posts" message appears. When ranked play won't match someone, the old client falls back to "can't reach server, play the CPU", so nobody gets stuck.

To test this, we ran the previous version of the game client (from git) in a real browser against the new server code (with local SQLite standing in for the database) and checked it still worked. As of October 22, all passed.

The new tables (bans and counts) are created by the server on first use. No manual SQL step against production means no "shipped the code, forgot the table".

How we test

The server code runs locally without a Cloudflare login. Node.js 24's built-in SQLite (node:sqlite) stands in for D1, there's a stand-in Cache API, and the tests call the API functions directly with a frozen clock. The tests advance the clock, so "one hour later you can post again" and "new day, count starts at 0" take no time to check. Examples of what's tested:

As of October 23, 2026, that's 223 checks, all passing. On the client side, browser automation tests (Playwright) check things like opponent names coming from the server and unknown prompts showing "?".

What we learned

When this was written, the boards were still small and we couldn't show the effect in numbers. When real abuse shows up and we learn which layer stopped it (or didn't), we'll add it here.

Doodle Stack runs in your browser with no sign-up. Post solo records to the leaderboard or play ranked matches with strangers. → Play Doodle Stack

Nandemo Factory is a one-person studio in Japan that makes small browser games, with AI doing most of the work. We only write about things we built and checked ourselves, with the numbers we actually saw. Play the games in English.

Related notes