From f815e39351b713f5f8d9b3accb67f44b2fc606f7 Mon Sep 17 00:00:00 2001 From: JetBoom Date: Tue, 14 Apr 2015 19:47:50 -0400 Subject: [PATCH] Fix deserialize client exploit. --- .../gamemode/sh_serialization.lua | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/gamemodes/zombiesurvival/gamemode/sh_serialization.lua b/gamemodes/zombiesurvival/gamemode/sh_serialization.lua index 984cfce..221c583 100644 --- a/gamemodes/zombiesurvival/gamemode/sh_serialization.lua +++ b/gamemodes/zombiesurvival/gamemode/sh_serialization.lua @@ -1,11 +1,24 @@ +local sandbox_env = {Vector = Vector, Angle = Angle} + function Deserialize(sIn) - SRL = nil + local out = {} - if #sIn == 0 then return {} end + if #sIn == 0 or string.sub(sIn, -1) ~= "}" then return out end - if string.sub(sIn, 1, 4) ~= "SRL=" then sIn = "SRL="..sIn end RunString(sIn) + if string.sub(sIn, 1, 4) ~= "SRL=" then sIn = "SRL="..sIn end - return SRL + if string.sub(sIn, 5, 5) ~= "{" then return out end + + sIn = sIn.." return SRL" + local func = CompileString(sIn, "deserialize", false) + if type(func) == "string" then + print("Deserialization error: "..func) + else + setfenv(func, sandbox_env) + out = func() or out + end + + return out end local allowedtypes = {} @@ -83,4 +96,4 @@ function Serialize(tIn, bRaw) end return "SRL={"..MakeTable(tIn).."}" -end +end \ No newline at end of file