Taki_Kit © Taki. All rights reserved.
This document describes the security model, what is enforced mechanically, and how to report a problem.
Every client is an attacker. A FiveM server relays arbitrary net events from any connected client to any listener, with any payload, as often as the client likes. The client controls its own JavaScript and can call any event the server has registered.
Therefore the server answers exactly one question for every inbound request: what can I prove?
| Never trust | Why |
|---|---|
source |
Use the value FiveM assigns to the handler. There is no API to set it. |
| Money / inventory | Only the framework is authoritative. |
| Permissions / admin status | Only server-side groups and ACE. |
| Job / gang | Only framework state. |
| Identifiers | Only GetPlayerIdentifiers or the framework. |
| Ownership | Only proven server-side, e.g. by a database row keyed on source. |
| Position | Only with OneSync, and only if it actually reports. |
Taki_Kit provides no API that writes these from a caller. There is no
Player.setDataFromClient, no Permissions.grantFromNet, no
Command.executeAs(source, …). If you need one of those, you are writing the
vulnerable code yourself, deliberately.
Taki.Security.guard is the intended way to expose a client-reachable
endpoint. It applies six checks in a fixed order.
| # | Check | Failure |
|---|---|---|
| 1 | source is a connected player | reject, log |
| 2 | serialised payload ≤ config.security.maxPayloadBytes |
reject, log |
| 3 | token bucket, keyed ${event}:${source} |
reject, log retryAfterMs |
| 4 | permission, resolved server-side | reject, log |
| 5 | schema, including arity | reject, log issues |
| 6 | handler | catch, log, return undefined |
- Rate limit before validation. A malformed flood costs a bucket lookup, not a schema run. Validation is the expensive step.
- Permission before validation. An unprivileged flooder never reaches the
validator. Asserted in
tests/security.test.ts: an invalid payload from a caller with no permission recordspermission-denied, notvalidation-failed. - Payload size before both. A 40 MB array is rejected before anything tries to walk it.
- The handler is last, and isolated. A throw inside a FiveM net handler
surfaces to the player as a silent failure and to the server as a wall of
stack traces. The guard catches, logs with context, and returns
undefined.
A token bucket: capacity limit, refilled at limit / windowMs.
A fixed window was rejected because it permits a 2× burst across the boundary —
limit requests at 0.999s and limit more at 1.001s.
Additional properties:
- Keyed per player. One abuser cannot exhaust another's allowance.
- Rejection consumes. Otherwise a client hammering a blocked endpoint could poll its own bucket forward into being allowed.
peekdoes not consume. A helper that quietly spent a token would be a nasty trap, sorateLimit()reports without spending.- The table is bounded and evicts in insertion order. A client that varies its own key (a random string in a payload field) would otherwise grow the map without limit.
- Disconnect clears a player's buckets. Guard keys are
${event}:${source}, so the reset matches the source component — a prefix match on the source alone would silently leak one bucket per event per departed player.
Taki.Validator schemas do double duty: they type-check at build time and
validate at runtime.
- Objects reject unknown fields by default. An unexpected key usually means
the client is running a different build of your resource; ignoring it silently
hides a real bug. Use
passthrough()when you mean it. - Tuples enforce arity. FiveM delivers extra arguments without complaint.
- Strings are bounded.
maxLengthis the DoS guard for free text. - Booleans are strict.
"true"and1are rejected; a sloppy client should not be able to drift the protocol. - Numbers must be fully numeric.
Number("1abc")isNaNandparseFloat("1abc")is1; both are wrong for an id or an amount.
A schema failure produces a ValidationError carrying per-field issues with
dotted paths, so a rejection log says which field was wrong.
- Every value is a
?parameter. Values are never interpolated. - Identifiers — the one thing SQL cannot parameterise — are validated against
^[A-Za-z_][A-Za-z0-9_]*$and backtick-quoted, soplayers; DROP TABLE xis aConfigurationErrorbefore the driver is touched. UPDATEandDELETErequire aWHEREclause. An unbounded one rewrites a whole table.- Stacked statements are refused, using a scanner that understands string literals and both comment styles. This is the read-only-endpoint-to-write- primitive escalation.
- A transaction failure propagates the original error unchanged. A business-rule failure ("insufficient funds") is not a database fault, and relabelling it would hide the only message that explains it.
- Redaction is centralised in
LoggerService.emit, not in the console sink, so a log file, Sentry or Discord webhook sink also never receives a secret. Keys liketoken,password,secret,license,identifiersandsessionidare replaced with[redacted], recursively. - Strings are control-character stripped and truncated, so a hostile payload cannot forge log lines or flood the console.
- The logger is the only module permitted to call
console(src/elsewhere is a lint error).
The guarantee: server code never reaches a client.
Three mechanisms:
- Import-graph gate (
tools/check-isolation.ts). Walks the static value edges of each entry point and fails the build on a cross-side import, with the full chain in the error message. - Bundle scanner (
tools/check-bundle.ts). Scans the emitted output for server-only natives. Independent of the graph walk, so it catches a runtime- constructed reference or a dependency that inlined server code. - Runtime install guard (
assertSideMatches). If a hand-edited manifest loads the server bundle into a client context, installation fails loudly.
The build's denylist is deliberately narrow — only natives that genuinely do not exist on a client. Three entries were removed after the scanner flagged them:
| Removed | Why |
|---|---|
onResourceStart |
Both sides must subscribe; the client needs it for teardown. |
oxmysql |
A resource name, not a capability. Appears in an error message. |
GetPlayerFromIndex, NetworkIsPlayerActive |
Game natives available on both sides. |
An over-broad denylist trains people to ignore the scanner. A marker earns its place only if its presence in the wrong bundle would be a genuine bug.
exportsis read lazily inside every call. A module-level capture would snapshot it before the framework resource finishes starting, and every lookup would then silently returnundefined.- Framework data is cached only after the framework's own load event. Before
that, reads return
null— never a fabricated record. - Money mutation goes through the framework's own API. A local cache write looks correct until the next framework sync and then silently reverts: the classic "money dupe" bug.
- QBCore balance checks re-read the authoritative account immediately before
removeMoney, because QBCore will happily drive an account negative.
A resource restart must not leave anything behind.
- Every registration is tracked in one
DisposableStore, drained ononResourceStop. - Disposers are idempotent; a double stop is a no-op.
- Registering after teardown disposes immediately rather than leaking.
onNethandlers are gated by anactiveflag, because the server runtime has nooffNet.- Commands are tombstoned, because
RegisterCommandhas no inverse. - Pending callbacks are cancelled and marked handled, so a shutdown rejection cannot become an unhandled rejection.
Please report privately rather than opening a public issue. Include:
- the affected version (
Taki.version), - the resource setup (framework, OneSync on/off),
- a minimal reproduction.
You should expect an acknowledgement within a few days.
In scope: a defect that lets a client influence server-authoritative state it should not, bypass a guard, or cause server code to reach a client.
Out of scope: a resource that calls the framework directly without the guard,
and misuse of the low-level Taki.bus (which is documented as the escape hatch
that bypasses the checklist).
Taki_Kit © Taki. All rights reserved.