Skip to content

Security ​

np_minigames' job is to let a resource trust a minigame's result. This page lists what it checks and what it can't.

The replay model ​

  1. A game is a pure function of (seed, params, raw input). The server builds the puzzle with make(params, rng(seed)) and sends the client only the public part.
  2. The client sends what the player did, never "I won". Picks, press times, hold intervals, input events.
  3. The server replays it. verify(puzzle, answer) runs the same rules (shared/games/<id>.lua) and decides the outcome. Hidden state (solution paths, the fish's behaviour, sweet spots, decoys) comes from the seed, so a client can't steer it.
  4. The same rules run everywhere. The Lua game files run on the server, the client and in the tests; the NUI has a TypeScript port of each rule set, and parity tests check that both give the same verdict on the same answers.

Timing ​

Each game reports the fastest fair solve (minMs) and a hard cap (maxMs) for a puzzle. All times are measured on the server clock:

Check Reason Config
A win faster than minMs × timedTolerance too_fast (implausible = true) Security.timedTolerance (0.8)
A win slower than maxMs + graceMs timeout Security.graceMs (3000)
The answer's own clock runs ahead of the server's clock (implausible = true) Security.clockSlackMs (1500)
The game is never shown not_shown Security.startTimeoutMs (15000)

Position, state and sessions ​

  • maxMove: the distance from coords (default: where the player stood) is checked every second and on submit; further away ends the game with moved.
  • Death and cuffs end a game with dead / interrupted.
  • One session per player. A second start fails with busy unless the caller passes replace = true. Session tokens are bound to the player.
  • Rate limit: a token bucket per player on every NUI → server call (Security.rateLimit), and a cooldown between practice runs.
  • Every end path runs once. Drops, stops, cancels and timeouts all end the session through the same code, so the phone block and the HUD claims are always released, and items are never used up on dropped, api or replaced.

Client-driven flows ​

Profiles fix the game, difficulty and params on the server. The outcome comes back as a receipt that works once, for one player, for 120 s (Security.receiptTtlMs). A forged, replayed or foreign receipt is refused by Redeem (no_receipt, used, expired, wrong_player, wrong_profile).

Items ​

Items are checked before the start and used up on the server after the verdict, by rule and chance. A client can't keep an item by disconnecting mid-game and get the outcome anyway: a dropped session has no outcome.

Staff ​

With np_admin:

  • implausible answers (too_fast, clock) are logged under the category minigames;
  • a run of Security.flagPerfectStreak (12) perfect grades in a row notifies staff and is logged;
  • staff can send any game to a player with Send a minigame and watch the result.

Local sessions ​

The client exports (Play, PlayAsync, Chain, SkillCheck on the client) make and judge the puzzle on the client. A modified client can fake them. Use them only for cosmetic or low-stakes gates; for anything that pays out or opens a door use the server exports or a profile.

Known limits ​

  • A perfect bot is still possible. The replay proves that what the client claims was physically possible within the rules and the clock. It can't rule out a program that plays perfectly in real time, for example by pressing at the exact moment.
  • Memory and feedback games have to send what the player sees to the client: the lit cells of thermite, the pattern of the pattern lock, sweet spots, the sway path.
  • Progress is cosmetic. It comes from the client. Never pay out on it.
  • Difficulty tuning is untested with real players. The presets come from the source resources and from simulated policies.