Compliance

Phase 1, Phase 2, then keep it running

A fixed-price gap analysis, remediation through to your audit, and upkeep after it. All in a workspace you keep.

All compliance
Security

Find it before a buyer does

Testing, assessments and security leadership, run by the researcher who found the Mirai botnet kill switch.

All security
Industries

Prove you are secure

To the people you sell to, raise from or answer to.

All industries
Resources

Learn the space

Original research, free tools and plain-language guides, from a published security researcher.

Read the blog
Security

FiveM Server Event Security: Validating What the Client Sends

On this page, 7 sections
  1. Why server events are the weak point
  2. The five checks every sensitive handler needs
  3. What a validated handler looks like
  4. Patterns to avoid
  5. Reviewing a server you already run
  6. Using events to catch cheaters
  7. Common questions

FiveM server event security means treating every network event a client can trigger as untrusted input: confirm who is calling from the server's own record, check the player is allowed to do this right now, validate every value's type and range, look up prices and rewards on the server, rate limit, and log refused calls. Events that skip these checks are how most FiveM economies get drained.

This post is for server owners and script developers who already know what a server event is and want to stop theirs being abused. It explains the defensive patterns, how to review existing handlers, and how to tell from your logs that someone is probing. It does not explain how to attack an event, and you will not need that to fix yours.

Why server events are the weak point

In FiveM, a resource registers network events on the server, and the client triggers them with arguments. That is how a job script pays a player, a shop sells an item, or a garage spawns a car. The mechanism is fine. The problem is an assumption that creeps into scripts: that only the script's own client code will ever trigger the event, and only with sensible values.

That assumption fails the moment a player runs a modified client. A modified client can trigger any registered network event, as often as it likes, with any arguments it likes. It does not need to open the shop, stand at the job site or pass any check the client code performs. If the server handler trusts the arguments, the attacker writes their own payout.

When we ran the security side of a FiveM anti-cheat engine, server event validation got more attention than any other heuristic for exactly this reason: it is where most real damage happens. The details are in our FiveM anti-cheat case study.

The five checks every sensitive handler needs

Not every event is sensitive. One that plays an animation for nearby players matters less than one that moves money. Start with any event that changes money, items, vehicles, jobs, permissions or another player's state, and give each one these checks before it does anything.

1. Identity from the server, not the arguments

The server knows which player triggered an event. Use that value. Never accept a player ID, character ID or account ID passed in the arguments as the person acting. A handler that pays "the player in argument one" will pay whoever the attacker names, including themselves on another account.

2. Authorization for this action, now

Does this player hold the job, rank, item or permission the action requires? Are they near the location where it can happen? Are they in a state where it makes sense, alive, not cuffed, not already mid-transaction? Checks the client code performs before triggering the event do not count, because a modified client skips them.

3. Values validated and looked up server-side

Check types, ranges and lengths for every argument. Better still, do not accept values the server can work out itself. A purchase event should send an item name and a quantity; the server looks up the price. A job payout should send nothing more than "I finished"; the server decides whether that is true and what it pays.

4. A sane rate

Every sensitive event should have a per-player rate limit that matches what real play can produce. A delivery job that takes three minutes cannot legitimately pay out every two seconds. A rate limit alone does not stop abuse, but it caps the damage while your other checks catch up.

5. Refuse and log with evidence

When any check fails, refuse the action and log it: the event name, the full payload, the player's identifiers, their position and the time. In the anti-cheat work, failed calls were logged with the full payload so staff could see exactly what was attempted. That log is how you find the script being targeted, and it is the evidence you need before you remove anyone.

What a validated handler looks like

Here is the shape of a defensive handler for a shop purchase, written in Lua. The helper functions stand in for whatever your framework provides.

RegisterNetEvent('shop:buy', function(itemName, qty)
    local src = source                      -- identity from the server
    if type(itemName) ~= 'string' or type(qty) ~= 'number' then
        return logRefused(src, 'shop:buy', 'bad types', itemName, qty)
    end
    qty = math.floor(qty)
    if qty < 1 or qty > 10 then
        return logRefused(src, 'shop:buy', 'qty out of range', itemName, qty)
    end
    local item = ShopItems[itemName]        -- server-side price list
    if not item then
        return logRefused(src, 'shop:buy', 'unknown item', itemName, qty)
    end
    if not isNearShop(src, item.shop) then  -- server reads position
        return logRefused(src, 'shop:buy', 'not at shop', itemName, qty)
    end
    if rateLimited(src, 'shop:buy', 5, 10) then
        return logRefused(src, 'shop:buy', 'rate', itemName, qty)
    end
    local cost = item.price * qty
    if not removeMoney(src, cost) then return end
    addItem(src, itemName, qty)
end)

Notice what the client does not send: the price, the shop it is at, or who is buying. Every one of those is something the server knows or can check for itself.

Free weekly email

Get The Compliance Brief every Tuesday

One email a week from Jacob Masse: the security and compliance stories that changed something that week, and what each one means if you sell software to enterprise buyers. Five stories, a take on each, five minutes to read.

Free. Unsubscribe in one click, and replies reach Jacob directly. Read the latest issue or browse the archive.

Patterns to avoid

When reviewing existing scripts, these are the patterns that get flagged most often:

  • Amount in the arguments. Any event that adds money or items in the amount the client sent.
  • Target in the arguments with no check. Events that act on another player named by the caller, such as reviving, jailing, paying or searching, without confirming the caller has the job and is near the target.
  • Client-only permission checks. An admin menu that checks permissions when it opens on the client, then calls server events that do not check again.
  • Generic "do anything" events. A single event that takes a function name or a database query from the client and runs it. These should not exist.
  • Events left over from testing. Debug payouts and give-item helpers that were never removed.

If your server runs bought or leaked resources, assume none of them were written with these checks until you have read them. Reviewing third-party code is a separate job, covered in our guide on finding backdoors in resources, and the broader principle is the same one we apply in code security reviews for software companies.

Reviewing a server you already run

Most server owners inherit dozens of resources and cannot rewrite them all at once. A practical order:

  • List every registered network event. Search your resources for event registrations on the server side. You will probably find more than you expected.
  • Rank by impact. Money, items, vehicles, jobs and permissions first. Cosmetic events last.
  • Review the top of the list against the five checks. Fix the handler or wrap it with validation before it runs.
  • Turn on logging for refused calls. Within days you will see which events are being probed, which tells you where to look next.
  • Repeat when you add a resource. Every new script adds events. Review them before they go live, not after the economy is broken.

Using events to catch cheaters

Validation stops the damage. It also produces signals. A player whose calls keep failing range checks, who triggers events from impossible locations, or who fires them at rates no human produces is very likely running a modified client. Those signals feed a score rather than an instant ban, because one odd reading can be lag or a misbehaving script.

Decoy events add a stronger signal. Mod menus often scan a server for events with tempting names and call them blindly. An event that exists only as a trap, which no legitimate script ever calls, gives a near-certain detection with almost no false positive risk.

The same input validation principles apply well beyond game servers. If you also run web panels, stores or APIs for your community, our post on API security best practices covers them.

Common questions

Can I stop cheaters from triggering server events at all?

Not reliably. A modified client can trigger any registered network event. The defence is making the handler safe to call with any input: identity from the server, authorization checked, values validated, rate limited and logged.

Is obfuscating event names a good defence?

It slows casual abuse but is not a defence on its own, because event names can be discovered from the client. Validate the handler properly; treat renaming as a minor extra at most.

How do I know which events are being abused?

Log every refused call with the event name, payload, player identifiers and time. Patterns appear quickly: the same event refused many times, from many players, with out-of-range values, is the one being targeted.

Should a failed validation ban the player immediately?

Usually not on its own. Refuse the action, log it and add to the player's score. Ban on high confidence evidence, such as repeated impossible calls or a trap event, and keep the evidence so staff can review it.

If you want a second pair of eyes on your server's event handlers, or a penetration test of the server and the services around it, book a free call. We will tell you where to look first.

Server events your players could abuse? Penetration testing starts from $3,500 for one app or API.

See penetration testingOr book a free call

Before you go

Want the rest of this by email?

If this was useful, I send a few short notes on security posture. Unsubscribe in one click, and replies reach me directly.

From Jacob Masse, Principal of TrazTech: the files by email, then a few short notes over the next month. No spam, unsubscribe in one click.