Untrusted data should go through a few steps:
- Rate limiting
- Schema validation
- e.g. type assertions
- Sanity checks
- e.g. discarding OOB or nonfinite values
- Optional: Turing tests
- e.g. calling out aimbots
A cool problem that @0xBAADF00D and I ran into yesterday is NaN poisoning. If a malicious user can introduce a NaN into your game’s economy, they might be able to get infinite items for free depending on how your code is structured:
-- Unsafe: NaN balance will award item
if player.balance < price then
print("not enough money!")
else
awardItem()
end
-- Safe: NaN balance won't award item
if player.balance >= price then
awardItem()
else
print("not enough money!")
end