Secures Roblox RemoteEvent and RemoteFunction pipelines against client exploits using strict server authority, unknown argument validation (NaN, infinity, spoofed instances, UTF-8 length), per-player token-bucket rate limiting, context checks, and zero-leak cleanup. Use whenever creating remotes, handling OnServerEvent/OnServerInvoke, or building shop, combat, or economy systems.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of roblox-remote-security?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/jamorant404-roblox-remote-security)
---
name: roblox-remote-security
description: >-
Secures Roblox RemoteEvent and RemoteFunction pipelines against client exploits using strict
server authority, unknown argument validation (NaN, infinity, spoofed instances, UTF-8 length),
per-player token-bucket rate limiting, context checks, and zero-leak cleanup. Use whenever
creating remotes, handling OnServerEvent/OnServerInvoke, or building shop, combat, or economy
systems.
---
# Roblox RemoteEvent Security (Anti-Exploit Guide)
Exploiters have complete control over their client environment: they can fire any `RemoteEvent` at any frequency with arbitrary, forged, or malformed arguments (`NaN`, `math.huge`, negative numbers, oversized strings, fake instance tables, or objects outside expected folders). **All real security lives on the server.**
## 1. Core Security Principles
1. **Client Sends Intent, Server Computes Results:**
- **Never** accept price, damage, reward amount, currency delta, or cooldown duration from the client.
- Client sends `itemId` or `targetAction`; server looks up authoritative data in `ServerScriptService.Service` / frozen server tables.
2. **Treat Every Argument After `player` as `unknown`:**
- The first parameter of `OnServerEvent(player, ...)` is populated by Roblox and cannot be spoofed.
- Every parameter after `player` must be typed `unknown` and validated before use.
3. **Never Call `RemoteFunction:InvokeClient()`:**
- If a client errors, yields forever, or exploits the callback, the server thread hangs indefinitely. Use `RemoteEvent:FireClient()` instead.
4. **Rate-Limit Every Remote:**
- Enforce per-player cooldowns or token buckets on the server using `os.clock()`.
- Always delete player entries on `Players.PlayerRemoving` to avoid memory leaks.
5. **Validate Gameplay Context:**
- Check that the player's character is alive (`Humanoid.Health > 0`), within valid distance, owns the tool/item, and is not stunned/locked.
---
## 2. Where Remotes & Handlers Live
- **Shared Remote Registry:** `game.ReplicatedStorage.Modules.Remotes` (creates/exposes typed `RemoteEvent`s once on server, waits for them on client).
- **Server Handlers:** `game.ServerScriptService.Service.*` (never inside `Workspace` or `ReplicatedStorage`).
- **Validation Module:** `game.ServerScriptService.Service.RemoteValidator` (or `Validate`).
---
## 3. Argument Validation Toolkit (`--!strict` + `const`/`local`)
```luau
--!strict
-- game.ServerScriptService.Service.RemoteValidator
const RemoteValidator = {}
function RemoteValidator.number(value: unknown, minValue: number, maxValue: number): number?
if typeof(value) ~= "number" or not math.isfinite(value) then
return nil -- Rejects NaN, +inf, -inf
end
if value < minValue or value > maxValue then
return nil
end
return value
end
function RemoteValidator.integer(value: unknown, minValue: number, maxValue: number): number?
const num = RemoteValidator.number(value, minValue, maxValue)
if not num or num ~= math.floor(num) then
return nil
end
return num
end
function RemoteValidator.safeString(value: unknown, maxBytes: number): string?
if typeof(value) ~= "string" or #value == 0 or #value > maxBytes then
return nil
end
if utf8.len(value) == nil then
return nil -- Rejects invalid UTF-8 sequences
end
return value
end
function RemoteValidator.vector3(value: unknown, maxMagnitude: number): Vector3?
if typeof(value) ~= "Vector3" then
return nil
end
if not (math.isfinite(value.X) and math.isfinite(value.Y) and math.isfinite(value.Z)) then
return nil
end
if value.Magnitude > maxMagnitude then
return nil
end
return value
end
function RemoteValidator.instanceIn(value: unknown, className: string, root: Instance): Instance?
if typeof(value) ~= "Instance" or not value:IsA(className) or not value:IsDescendantOf(root) then
return nil -- Rejects spoofed tables and instances outside trusted containers
end
return value
end
return RemoteValidator
```
---
## 4. Per-Player Rate Limiter (`const` + `local`)
```luau
--!strict
const Players = game:GetService("Players")
export type RateLimiter = (player: Player) -> boolean
const function createRateLimiter(minIntervalSeconds: number): RateLimiter
const lastFiredAt: { [Player]: number } = {}
Players.PlayerRemoving:Connect(function(player: Player)
lastFiredAt[player] = nil
end)
return function(player: Player): boolean
const now: number = os.clock()
local previous: number = lastFiredAt[player] or 0
if now - previous < minIntervalSeconds then
return false
end
lastFiredAt[player] = now
return true
end
end
return createRateLimiter
```
---
## 5. Secure `OnServerEvent` Checklist
Before shipping any `RemoteEvent` handler, verify:
1. Rate limit runs **first** before any heavy lookup or allocation.
2. Every client argument is typed `unknown` and validated with `RemoteValidator`.
3. Prices, cooldowns, rewards, and damage are read exclusively from **server** frozen tables (`const ... = table.freeze(...)`).
4. World interactions check character existence, `Humanoid.Health > 0`, and server-side distance `(rootPos - targetPos).Magnitude <= MAX_DISTANCE`.
5. `Players.PlayerRemoving` cleans up all per-player rate-limit and session state.
See [references/remote-patterns.md](./references/remote-patterns.md) for a complete secure Shop & Combat `RemoteEvent` implementation.