Security
What the game trusts, what each secret protects, and what is still open. The project is in development: the gaps at the end are known and deferred, not forgotten.
Trust boundaries
untrusted | internal network (Docker network, LAN)
|
game client --HTTPS----------->| ApiServer (8080) --X-Worker-Key--> DbWorker (8085) --> PostgreSQL
--UDP (LiteNetLib)>| Gateway (from 7100) --GatewayKey--> GameServer (UDP 7001)
| Orchestrator (8090), Redis (6379), Telemetry (8095) --> ClickHouse (8123)
admin browser --HTTPS--------->| Monitor (8091, password)
- Client ↔ ApiServer: HTTP (HTTPS on the dev server, through the NAS's Traefik). A player is identified by its JWT (
Authorization: Bearer), checked on each call. - Client ↔ Gateway: UDP. The client sends its JWT in
Auth; the Gateway checks it, loads the character from the DbWorker and the account's roles with it. A client cannot connect to a GameServer port: the connection keys differ (NetKeys), and only Gateway ports are published (DockerProvider). - Internal network: the Orchestrator, DbWorker, Telemetry, Redis, ClickHouse and the GameServers. Only the ApiServer (8080), the Orchestrator (8090, on 127.0.0.1), the Monitor (8091), the doc site (8081) and the Gateways' UDP ports are published by
docker-compose.yml; on a server with its own HTTPS (Caddy, Another server inDeploy.md) the first three listen on 127.0.0.1 only (BIND_ADDRESS) and Caddy publishes 80 and 443.
Device sessions
How an account stays signed in on a device (2026-11-29), never with its password saved:
- A login or a new account from the game (
AuthRequest.Remember; the bots do not ask) gives, with the account's JWT, a device token: 32 random bytes (DeviceSessions.NewToken, URL-safe base64). The ApiServer hands it to the client once and stores only its SHA-256 (DeviceSessions.Hash) through the DbWorker (tableDeviceSessions: account, hash, created, last used, expires;/db/device-sessions*). A copy of the database opens no session. - The client keeps only that token (
device_tokenin its settings file, one per build profile,Settings.DeviceToken), never the password, and never the account's JWT (in memory only). The guest accounts' saved passwords are gone (2026-11-29): the file is written again without them. - At each start the client trades it (
POST /api/auth/session) for a new account JWT (12 h, as a login's) and the session lives 30 days from then (DeviceSessions.Lifetime, pushed back at each use). The ApiServer decides: unknown, revoked or past its expiry → 401 (an expired one is deleted), and the game shows its first screen (Log in / Create an account). - Revoked by Switch account on the character screen (
POST /api/auth/logout: the row deleted; 204 also for an unknown token), and by refusing the terms of use. The client forgets its token first: offline, the server's row simply expires. The game's Log out ends only the game session (the character's token), not the device's. - The token is never logged (rule 15). Tested in
Tests/Api.Tests/DeviceSessionTests.cs(issued and kept hashed, renewed, expired, revoked, an unknown token refused). - Not yet: a list of one's devices to revoke them one by one, revoking every session at a password change (there is no password change yet; Forgotten password is in
Todo.md).
Test and bot accounts
Who may make them (2026-11-29): only the admin key (ADMIN_KEY, header X-Admin-Key, compared in constant time; the same key as the feedback's admin API): POST /api/admin/test-accounts (a test_ account, random name and password) and POST /api/admin/bot-accounts/{index} (the pool's bot_001..bot_5000, reused). The game never makes them: a player's registration always makes a player account (Accounts.Kind, Shared.Contracts.AccountKind; the DbWorker's /db/accounts/service refuses the kind player, and a name already a player's is never turned into a test or bot account). Each answer holds the password and a session ready (the account's JWT, a device token), so the key is the only secret a test hook or a bot needs (where it goes: Accounts for agents and bots in Development.md). Two more admin routes serve the performance test (Tools/Dev/Perf-Test.ps1, Performance test in Development.md): POST /api/admin/service-wing gives a free wing, with the admin key and a character's token, to a character of a test or bot account only (a player's: 403; the bots' flights), and GET /api/admin/server-metrics answers the servers' load (the Orchestrator's state: each live instance's metrics, the players' count; nothing about who they are).
They never show to the players: a test or bot account is not listed in a player's Players tab (EntityMeta.Service, told by the Gateway from the account at login; a test account still sees the others like it, for the test hooks' screenshots), cannot ask a player to be friends nor invite one into a party, nor be asked (the DbWorker and the ApiServer refuse it, 409), and will be left out of the rankings to come. The Monitor shows their kind. Test accounts are deleted with their characters 3 days after they were made (TestAccounts:LifetimeDays; the ApiServer's TestAccountCleanup, every hour, deletes through /db/accounts/tests/{id}/delete, which deletes test accounts only); players' and bots' never. The old guest accounts (guest_, from before) stay as player accounts nobody logs in to. Every test and bot account has the Bot role (2026-12-01, Roles below): the developer moves and commands without the admin ones, a [bot] tag over its name in the game.
Secrets
All in .env (see .env.example), never committed (rule 15 of AGENTS.md). The dev server's deploy generates them on the node (Deploy.md).
| Secret | Protects |
|---|---|
JWT_KEY |
Signs the players' tokens (HMAC-SHA256, 12 h). The ApiServer issues them; the ApiServer and the Gateways check them. Anyone with it can log in as any account. |
WORKER_KEY |
Header X-Worker-Key: the DbWorker (accounts, characters, gold, contracts), the Telemetry service, and the ApiServer's internal routes POST /api/contracts/notify-defeat and notify-failed (called by the GameServers). |
ADMIN_KEY |
Header X-Admin-Key: the Orchestrator's admin routes (state, add or drain instances, reassign cells, kick), and the ApiServer's (the feedback's, the test and bot accounts'). Used by the Monitor and the Telemetry service, and by the test hooks and bots (NOF_ADMIN_KEY). |
ADMIN_PASSWORD |
The Monitor's login (cookie). The Monitor can kick players and grant the DEV role. |
REDIS_PASSWORD |
Redis: the Orchestrator's cluster state, camp locks, presence, raid lobbies. |
CLICKHOUSE_PASSWORD |
ClickHouse: game events, arena fights, glides, server metrics. |
CAMP_SEED |
Where the camps are (ServerWorldGen). Servers only: a client learns a camp's plateau only when it comes near (CampSite). |
| Gateway ↔ GameServer key | NetKeys.GatewayKey: only a Gateway of the same protocol version connects to a GameServer. Not a secret: it is in the code (see Known gaps). |
What a malicious client can and cannot do
The client is not trusted. What it can do is limited to what a normal player can do, a bit faster or more precisely.
- Combat, health, XP, gold, items: server authority. The GameServer computes hits, damage, deaths, XP and level ups. It measures a shot's charge, overheat and scatter itself (protocol 23), checks ammo and magic, and checks the muzzle is near the player. Gold and inventory move only in the DbWorker, in transactions; the Gateway checks an
Equipwith the DbWorker before the GameServer applies it. - Position: client-authoritative, speed-checked. The client sends its position 15 times a second. The GameServer refuses a move faster than the player's speed (
Rules.SpendMove, 1.6× the speed plus a small slack) and sends aCorrection. A cheater can still move at that speed in any direction (see Known gaps). Under the world: feet more than 3 m under the ground (Rules.IsUnderWorld, whatever the bug) are put back on it: the client at once every frame (FallGuard; lost feet, not a number, go back to the safe zone's arrival), the GameServer keeps its own copy on the ground and sends aCorrection. Nobody falls for ever. The Gateway checks the same before its copy of the state (which places the player at a handoff) takes a position (GatewayMoveCheck). - A lost connection (2026-11-30, Connection lifecycle in
Architecture.md): the character stays in the world 60 s, vulnerable (no invulnerability: cutting the network never escapes a fight or a death); a reconnection needs the same character's token (or this device's session for a fresh one), checked as any login. The away spot in Redis (away:{characterId}) holds only a position. A newer connection of the same character takes it over and closes the older one (AuthErrors.Replaced): whoever has the token can, as before, play the character. - Rate limits: the Gateway drops packets over 512 bytes, unknown ids and messages over their rate (
ClientRateLimiter, see Gateway protections inArchitecture.md), and disconnects a client after 100 dropped packets in 10 s. - Voices, blocks, reports, friends, party: the servers never decode a voice (they copy its slices) and keep none; a block is between accounts, saved by the DbWorker and applied by every Gateway (no voice either way, no friend request); a report goes to the team only (the Monitor's Reports), at most 10 an hour; friend requests and party invitations reach only a player in the game (the presence), never across a block, at most 3 from a player to another an hour (20 friend requests and 30 invitations in all; see Anti-spam in
Architecture.md); a party member's Join is checked by the Gateway (same party, in Redis) and the GameServer (no ghost, no fight); blocks and reports are rate-limited at the Gateway. The dictation runs on the player's PC (its model downloaded once from Hugging Face): nothing said is sent. The social events (who did what to whom) are kept 90 days in the telemetry, both names (see Social inTelemetry.md). - Terms of use: a character plays only once its account accepted the current terms (the ApiServer checks it at each play; see
Terms.md). - Roles (
Shared.Contracts.AccountRoles, on the account; the Gateway reads them from the database at login, not from the token, and tells the GameServer:PlayerStateMsg.Dev/Bot). One check decides what each may do,Server.Core.DevRights:- DEV: dev flight, any speed, teleport, the DEV tab and all its developer commands, the admin ones too (set the gold, give items). Only the Monitor grants it (Grant DEV).
- Bot (
BOT, 2026-12-01): what the bots and test hooks need, on every environment: dev flight, any speed, teleport (--fly,--goto), and the commands on the character (level, speeds, mob aggro off, arena tests, dirt, wear). No admin command (the Gateway refusesSetGoldandGiveItemsto a bot: "A bot account may not give itself gold or items"), no DEV tab, no Monitor action. The others see a small [bot] over its name (EntityMeta.Bot, the nameplate's title line,plate.bot); its fights are kept out of the players' numbers (FightDto.Bot; its arena fights recorded asDev). Given automatically to every account made with the admin key (test and bot accounts, below: the DbWorker adds it at eachPOST /db/accounts/service, so an older bot gets it at its next run), byTools/Dev/New-BotAccount.ps1(the admin key), or from the Monitor (Grant Bot). A player never gets it from the game. - A normal player has neither: a dev move gets a
Correction, aDevCommandis refused.
- Raid board and forge: the ApiServer checks the token, that the player is online and, for the board, in the safe zone.
- Version: a client of another protocol version is refused (426 at the ApiServer, refused at the Gateway).
Known gaps
Deferred while the project is in development. Each one is a task before opening the game to the public.
- Orchestrator instance routes have no key.
POST /api/instances/register, the heartbeat,/api/cells/claim, the directory,/api/gateway/best,/api/camps/{id}/reserve,/api/raids/startand/api/noticesare open: they count on the internal network. Since 2026-11-25docker-compose.ymlpublishes port 8090 on the node itself only (127.0.0.1:8090: its own tools,deploy.sh), andregistergives camp seed 0 while the camps are off. Left: a key for instances. - An empty
AdminKeyturns admin auth off (OrchestratorOptions.AdminKey: "Empty = open (dev)"), on a developer's machine only: withNOF_PRODUCTIONthe Orchestrator refuses to start without a key of its own (2026-11-25). - Dev default secrets as fallbacks. Every service falls back to a known value when its setting is missing (
Shared.Contracts.DevSecrets), so a local machine runs without.env. Fixed for real servers (2026-11-25): withNOF_PRODUCTION=true(written bydeploy/deploy.sh, passed bydocker-compose.ymlto the services, the gateways and game servers), a missing, empty or development secret (JWT_KEY,WORKER_KEY,ADMIN_KEY,ADMIN_PASSWORD,POSTGRES_PASSWORD,CLICKHOUSE_PASSWORD) stops the service at its start. Left: Redis's password andCAMP_SEEDare not checked. - Login: fixed 2026-11-25. Ten wrong passwords for one account within 5 minutes lock it 5 minutes (
LoginThrottle, per account: behind the HTTPS proxy every player has the same address; only failures count, so a crowd logging in is never slowed); the Monitor's password is compared in constant time and 5 wrong ones lock its login 5 minutes. A new password needs 8 characters (UsernameRules.MinPasswordLength, was 4; older accounts keep theirs). In memory: a restart forgets the counts. - Unsigned auto-update. The client checks the SHA-256 of a downloaded build, but that hash comes from the same server (
/api/client/latest). Whoever controls the server, or the connection without HTTPS, can ship any build. Planned: Signed client builds inTodo.md. - JWT over UDP in clear, not revocable. LiteNetLib does not encrypt: the token in
Authcan be read on the network path and reused for its 12 hours. There is no way to revoke a token (a changed password or a ban does not end it). - Move check: moves are not checked against obstacles: a cheater can walk through walls and trees. (Fixed 2026-11-25: one position update covers at most
Rules.MaxMoveSeconds, 1 s, so a client silent for a while cannot then jump as far as its speed allowed for all that time; and the Gateway checks a move with the same rule before its copy of the state takes it,GatewayMoveCheck, so a position sent while the player is on no GameServer is no teleport at a handoff.) - The Gateway key is hard-coded (
NetKeys.GatewayKey). Anyone who reaches a GameServer's UDP port can connect as a Gateway and sendPlayerEnterwith any state. Only the internal network protects it. - Workflow inputs interpolated in scripts.
.gitea/workflows/*.ymlput${{ github.event.inputs.* }}directly into PowerShell (ci.ymlforce,release.ymlversionandcommit,deploy.ymlversion). Someone allowed to run a workflow could inject commands. Fix: pass them through environment variables. - No per-user limit on
/api/flights. A logged-in client can post glides as fast as it wants; each one goes to the Telemetry service (traces are cut toFlightRoutes.MaxTracepoints).