A caller can name any id it likes — so the server has to prove who owns it before the row behind that id counts for anything.
There is one trust boundary where the claim itself is the value. Everywhere else a client sends a number and the server re-derives it. Here the client sends an identity — "I am this " — and there is no number to look up, because the identity is the thing in question. Get this boundary wrong and every other wall becomes decorative: an attacker who can claim someone else's identity inherits everything that identity was ever allowed to do.
A learner plays without an account. Their row on the weekly board belongs to an anonymous id their browser keeps. Somebody else — with no account either, no password to steal, nothing to guess — sends that same id and claims the row.
-- the honest device, once, on first launch
local guestId = "7f3a91c4-..." -- a local id it generated itself
-- the attacker's device, moments later
local guestId = "7f3a91c4-..." -- the same string, typed in
From the server's side of the boundary those two requests are identical. Both are a machine saying a string. The whole design question of this lesson is: what would have to be true for the second one to fail while the first one succeeds?
A client sends guestId=abcdef123. What has it proven to the server?
If the server answers an identity request by echoing whatever it was handed, it has turned the identity into a client-owned value — the one thing a boundary is supposed to prevent. Two consequences follow, and both are worse than they look.
The obvious one: a stranger can read someone's id and post as them, raising their XP, renaming their row, or poisoning it.
The quiet one: the server has now signed off on a lie. Even if the row is harmless today, every future feature keyed on that id inherits the false ownership — a muted list, a claimed daily reward, a saved inventory. The id is the root of the trust tree, so a forged root means every branch under it is forged too.
So the server needs two things it currently has neither of: a way to issue identities itself, and a way to recognize one it issued. That recognition is a token.
The server may only re-sign an id for a caller that presents a token the server itself for that id.
Here is the design decision that keeps this from turning into a login screen. Demanding proof for every id would punish every honest device — a returning who cleared their browser storage, a first-time visitor, a switching from phone to laptop. None of them is attacking anything.
So the requirement is conditional, and the is data:
That last detail matters: the response to a failed proof is a new identity, not an error. A rejected identity shouldn't break a game for an honest who genuinely lost their token; it just means they begin again with a clean row.
Which request must be rejected?
Two endpoints, one rule. The first hands out an identity; the second only accepts work from an identity that already proved itself.
-- identity issuance (GET): the caller offers what it already has
local requested = query.guestId -- a claim
local token = headers["x-guest-token"] -- the caller's proof, if any
local guestId
if not isValidId(requested) then
guestId = newId() -- nonsense: mint a fresh one
elseif proven(requested, token) then -- our own signature, for that id
guestId = requested -- welcome back, same row
elseif idHasData(requested) then -- belongs to somebody else
guestId = newId() -- stranger starts over, row untouched
else
guestId = requested -- unclaimed: free to adopt
end
return { guestId = guestId, token = sign(guestId) }
-- posting XP (POST): no token, no write
if not verifySignature(body.guestId, body.token) then
return reject(401) -- never reuse someone else's row
end
Read the shape of it: the write path has exactly one identity check and it happens before any data is touched. Issuance is generous — it is supposed to hand out identities freely, because the only thing it refuses is taking a live one.
The XP handler has verified the payload's shape but not its identity. Fill in the guard that refuses the write unless the caller's token proves it owns guestId.
weeklyXpEvent.OnServerEvent:Connect(function(player, body)
-- the token must prove this caller owns this id
saveWeeklyXp(body.guestId, body.xp)
end)A token is a credential, so treat it like one — the same way you would treat a password. The rule that catches people is not about cryptography: it is about where the value ends up after the request is done.
Referer headers sent to third parties. A credential on the wire that way is a credential you have published.A bearer token belongs in a request on a read and in the body on a write, because a URL is copied into logs, history, and referrers.
Nine lines, and this boundary is closed for good:
The ownership requirement only bites where there is data to protect, and that is exactly why it costs honest nothing. The moment you demand proof for a fresh id — or worse, tie an identity to an IP address or a fingerprint — you have rebuilt a login system badly, and you have taught attackers to rotate addresses instead of tokens.
Next up: the security audit lab — walking a finished game boundary by boundary and writing down what you find.