Guide

Server-side security: why you must not trust client data

Why FiveM servers must validate every client-sent value, check permissions and limit event rates on the server, and never trust what the client sends.

Anything a client sends your server is input, not fact. Event arguments, item counts, prices and target IDs can all be changed on the player's machine. Check them on the server against data the server owns, and reject the request when they do not match.

Short answer

Never let the client decide how much money a player gets, how many items they receive, or whether they are allowed to act. The server should calculate or look up those values itself, check permissions on every sensitive action, and limit how often a player can trigger each event.

Why the client cannot be trusted

FiveM's scripting reference says client data should always be verified, and that as much logic as possible should run server-side so clients cannot manipulate it. The Secure Your Events guide adds that cheats can let a client trigger events in any context, through TriggerServerEvent or TriggerEvent, and that client-side checks can be overridden by cheating clients.

Client code runs on a machine you do not control. A check that exists only in client Lua is a helpful message for honest players, not a security control.

Bad patterns to avoid

These are described in general terms. Each one matches a mistake the official docs warn about or that the Cfx forum has discussed repeatedly:

  • A server event that takes an item name and a count from the client and adds them to the inventory without checking what the player owns or earned.
  • A payment or sale event that accepts an amount from the client and moves money, instead of the server working out the price itself.
  • A server event that clients can call directly, even though only the server should trigger it. The docs call registering the wrong event type a common mistake.
  • Distance, cooldown or permission checks that run only in client code, with nothing repeated on the server.

The defensive pattern

For each server event that changes game state, the handler should do the following:

  1. Identify the player from the event source, not from an ID the client includes in its arguments.
  2. Read the values that matter, such as price, item count, job, position and permissions, from server-side data.
  3. If the client sent a value at all, compare it with the server's copy and reject the request on a mismatch.
  4. Check permission on the server for every action, including admin-only ones.
  5. Apply the change only after every check passes, and mark one-time state, such as a reward flag, on the server immediately.

The Secure Your Events guide follows this approach in its safer example. It tracks active jobs on the server, checks the player's position, caps item counts and resets job data after use.

Rate-limit events

The official security page does not include a dedicated rate-limiting section, so treat this as general practice rather than a documented FiveM rule. Keep a per-player timestamp or counter on the server for each sensitive event, and drop calls that arrive too fast. Escalate only after repeated violations, because a lag spike can cause a legitimate burst.

Log suspicious events

When a check fails, record the resource name, the event name, the player's source, the identifiers your server already uses, and the values that were rejected. Keep these logs apart from normal chat logs and review them regularly. A spike of failed checks from one player is a useful signal, but it can also mean a resource is broken for honest players.

If you find a resource you do not trust, follow the steps in the backdoor check guide before you go further.

What anti-cheat does and does not do

An anti-cheat can detect some client-side behaviour, and it may catch cheats your server code would miss. It does not decide what a player is allowed to do on your server, and it does not repair an event that accepts bad values.

Even with an anti-cheat running, the server must validate every value and every permission. The Cfx forum thread on server event security tokens describes its tokens as an extra layer on top of server-side design, not a replacement for it. This post does not assess any specific anti-cheat product.

FAQ

Is a client-side check enough?

No. A client check can show an error early and reduce mistakes by honest players, but the docs say client-side checks can be overridden. The server check is the one that protects your economy and game state.

Which events need server checks?

Any server event that changes money, items, job state, rewards, permissions or anything else that matters to the game should validate on the server. Read-only events carry less risk, but if they return private data, still check who is asking.

Do event tokens solve this?

No. Token resources such as salty_tokenizer add per-resource tokens to events. The forum thread describes them as a last-resort extra layer, and the server still needs its own validation.

Sources

Last checked: 29 November 2026

Not confirmed: the docs give no rate-limit value or standard rate-limit pattern, so that section is general practice. The search did not surface an official page on how the event source value is populated. The forum threads are several years old, and this post did not check the current behaviour of salty_tokenizer or any anti-cheat product. Check the official docs before relying on any detail here.

FiveM.tools was founded with sponsorship from Nyru.