security fix

This commit is contained in:
quotefox
2020-01-04 00:50:52 +00:00
parent 7de4ab8475
commit 411d23c1ef
4 changed files with 60 additions and 5 deletions
+21
View File
@@ -1,4 +1,6 @@
#define RESTART_COUNTER_PATH "data/round_counter.txt"
#define TOPIC_LENGTH_LIMIT 8192 //The reason why this is so large is to allow TGS topic calls to function without issue.
#define TOPIC_COOLDOWN 1 //90% sure there isnt anything that does multiple topic calls in a single decisecond.
GLOBAL_VAR(restart_counter)
@@ -140,6 +142,25 @@ GLOBAL_VAR(restart_counter)
log_runtime(GLOB.revdata.get_log_message())
/world/Topic(T, addr, master, key)
var/static/list/bannedsourceaddrs = list()
var/static/list/lasttimeaddr = list()
if(addr in bannedsourceaddrs)
return
if(length(T) >= TOPIC_LENGTH_LIMIT)
log_topic("Oversized topic, banning address. from:[addr]")
bannedsourceaddrs |= addr
return
if(addr in lasttimeaddr && world.time < (lasttimeaddr["[addr]"] + TOPIC_COOLDOWN))
log_topic("Too many topic calls from address in [TOPIC_COOLDOWN] ds, banning address. from:[addr]")
bannedsourceaddrs |= addr
return
lasttimeaddr["[addr]"] = world.time
TGS_TOPIC //redirect to server tools if necessary
var/static/list/topic_handlers = TopicHandlers()