From 7fb827ce6205232572d43f93e196da56e02653ad Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 27 Nov 2026 00:30:01 +0300 Subject: [PATCH 1/2] Deduplicate wire paths net messages + validate them To avoig getting netspammed by malicious net messages --- lua/weapons/gmod_tool/stools/wire_adv.lua | 12 ++++++++--- lua/wire/wire_paths.lua | 26 +++++++++++++++++------ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/lua/weapons/gmod_tool/stools/wire_adv.lua b/lua/weapons/gmod_tool/stools/wire_adv.lua index eac5686a26..97cb3491ea 100644 --- a/lua/weapons/gmod_tool/stools/wire_adv.lua +++ b/lua/weapons/gmod_tool/stools/wire_adv.lua @@ -150,6 +150,10 @@ if SERVER then for i=1,#wirings do local wiring = wirings[i] + if not istable(wiring) then continue end + + local nodes = wiring[4] + if not istable(nodes) or #nodes > 128 then continue end local inputentity = wiring[3] local outputentity = wiring[5] @@ -161,9 +165,11 @@ if SERVER then local inputname = wiring[1] local inputpos = wiring[2] if WireLib.Link_Start( uid, inputentity, inputpos, inputname, material, color, width ) then - for i=1,#wiring[4] do - local node = wiring[4][i] - WireLib.Link_Node( uid, node[1], node[2] ) + for j=1,#nodes do + local node = nodes[j] + if istable(node) and isvector(node[2]) then + WireLib.Link_Node( uid, node[1], node[2] ) + end end local outputpos = wiring[6] local outputname = wiring[7] diff --git a/lua/wire/wire_paths.lua b/lua/wire/wire_paths.lua index 1516538592..43affcfbdb 100644 --- a/lua/wire/wire_paths.lua +++ b/lua/wire/wire_paths.lua @@ -42,7 +42,6 @@ if CLIENT then end WireLib.Paths = {} -local transmit_queues = WireLib.RegisterPlayerTable(setmetatable({}, { __index = function(t,p) t[p] = {} return t[p] end })) util.AddNetworkString("WireLib.Paths.RequestPaths") util.AddNetworkString("WireLib.Paths.TransmitPath") @@ -78,17 +77,31 @@ local function TransmitPath(input, ply) net.Send(ply) end +local transmit_queues = WireLib.RegisterPlayerTable(setmetatable({}, { __index = function(t, p) t[p] = {} return t[p] end })) +local queued = WireLib.RegisterPlayerTable(setmetatable({}, { __index = function(t, p) t[p] = {} return t[p] end })) + +local function Enqueue(ply, input) + local set = queued[ply] + if set[input] then return end + + set[input] = true + table.insert(transmit_queues[ply], input) +end + local function ProcessQueue() for ply, queue in pairs(transmit_queues) do if ply:IsValid() then local nextinqueue = table.remove(queue, 1) if nextinqueue then + queued[ply][nextinqueue] = nil TransmitPath(nextinqueue, ply) else transmit_queues[ply] = nil + queued[ply] = nil end else transmit_queues[ply] = nil + queued[ply] = nil end end if not next(transmit_queues) then @@ -97,14 +110,15 @@ local function ProcessQueue() end -- Add a path to every player's transmit queue -function WireLib.Paths.Add(input, ply) - if ply then - table.insert(transmit_queues[ply], input) +function WireLib.Paths.Add(input, add_ply) + if add_ply then + Enqueue(add_ply, input) else - for _, player in player.Iterator() do - table.insert(transmit_queues[player], input) + for _, ply in player.Iterator() do + Enqueue(ply, input) end end + if not timer.Exists("WireLib.Paths.ProcessQueue") then timer.Create("WireLib.Paths.ProcessQueue", 0, 0, ProcessQueue) end From 118ca5a318b599b286ae823c38bb035ae0242ab3 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 27 Nov 2026 01:03:29 +0300 Subject: [PATCH 2/2] Lower to 64 --- lua/weapons/gmod_tool/stools/wire_adv.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/weapons/gmod_tool/stools/wire_adv.lua b/lua/weapons/gmod_tool/stools/wire_adv.lua index 97cb3491ea..96fd51f56f 100644 --- a/lua/weapons/gmod_tool/stools/wire_adv.lua +++ b/lua/weapons/gmod_tool/stools/wire_adv.lua @@ -153,7 +153,7 @@ if SERVER then if not istable(wiring) then continue end local nodes = wiring[4] - if not istable(nodes) or #nodes > 128 then continue end + if not istable(nodes) or #nodes > 64 then continue end local inputentity = wiring[3] local outputentity = wiring[5]