Skip to content

Commit

Permalink
[MIRROR] Fixes a variety of input stalling exploits (#1933) (#2852)
Browse files Browse the repository at this point in the history
* Fixes a variety of input stalling exploits (#82577)

## About The Pull Request

Fixes the following input stalling exploits (maybe missed some): 

- Changing GPS tag 
- Setting teleporter destination
- Request Console Reply
- Various AI law board interactions
- Note, I used `is_holding` but technically this means these fail with
telekinesis. I can swap them to `can_perform_action(...)`, which allows
TK, but I noticed some places explicitly deny TK interactions with Ai
law boards. Not sure which is preferred.
- Borg Rename Board
- Plumbing Machines and Ducts
- APCs and SMES terminal placements
- Stargazers Telepathy
- Go Go Gadget Hat

## Changelog

:cl: Melbert
fix: You can't change the GPS tag of something unless you can actually
use the GPS
fix: You can't set the teleporter to a location unless you can actually
use the teleporter
fix: You can't reply to request console requests unless you can actually
use the console
fix: You can't update AI lawboards unless you're actually holding them 
fix: You can't update a borg rename board unless you're actually holding
it
fix: You can't mess with plumbing machines unless you can actually use
them
fix: You can't recolor / relayer ducts unless you're actually holding
them
fix: You can't magically wire APCs and SMESs unless you're right by them
fix: You can't use Stargazer Telepathy on people who you can't see
fix: You can't configure the Inspector Hat unless you can actually use
it
/:cl:

* Fixes a variety of input stalling exploits

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: MrMelbert <[email protected]>
  • Loading branch information
3 people authored Apr 13, 2024
1 parent 0c733be commit 5b141e4
Show file tree
Hide file tree
Showing 25 changed files with 147 additions and 102 deletions.
5 changes: 3 additions & 2 deletions code/datums/components/gps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ GLOBAL_LIST_EMPTY(GPS_list)
data["signals"] = signals
return data

/datum/component/gps/item/ui_act(action, params)
/datum/component/gps/item/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
Expand All @@ -162,7 +162,8 @@ GLOBAL_LIST_EMPTY(GPS_list)
if("rename")
var/atom/parentasatom = parent
var/a = tgui_input_text(usr, "Enter the desired tag", "GPS Tag", gpstag, 20)

if (QDELETED(ui) || ui.status != UI_INTERACTIVE)
return
if (!a)
return

Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/computer/teleporter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@

if (regime_set == "Teleporter")
var/desc = tgui_input_list(usr, "Select a location to lock in", "Locking Computer", sort_list(targets))
if(isnull(desc))
if(isnull(desc) || !user.can_perform_action(src))
return
set_teleport_target(targets[desc])
user.log_message("set the teleporter target to [targets[desc]].]", LOG_GAME)
Expand All @@ -211,7 +211,7 @@
return

var/desc = tgui_input_list(usr, "Select a station to lock in", "Locking Computer", sort_list(targets))
if(isnull(desc))
if(isnull(desc)|| !user.can_perform_action(src))
return
var/obj/machinery/teleport/station/target_station = targets[desc]
if(!target_station || !target_station.teleporter_hub)
Expand Down
5 changes: 3 additions & 2 deletions code/game/machinery/requests_console.dm
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ GLOBAL_LIST_EMPTY(req_console_ckey_departments)
ui.set_autoupdate(FALSE)
ui.open()

/obj/machinery/requests_console/ui_act(action, params)
/obj/machinery/requests_console/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
Expand Down Expand Up @@ -213,7 +213,8 @@ GLOBAL_LIST_EMPTY(req_console_ckey_departments)
var/recipient = params["reply_recipient"]

var/reply_message = reject_bad_text(tgui_input_text(usr, "Write a quick reply to [recipient]", "Awaiting Input"), ascii_only = FALSE)

if(QDELETED(ui) || ui.status != UI_INTERACTIVE)
return
if(!reply_message)
has_mail_send_error = TRUE
playsound(src, 'sound/machines/buzz-two.ogg', 50, TRUE)
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/AI_modules/freeform.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/obj/item/ai_module/core/freeformcore/attack_self(mob/user)
var/targName = tgui_input_text(user, "Enter a new core law for the AI.", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len), TRUE)
if(!targName)
if(!targName || !user.is_holding(src))
return
if(is_ic_filtered(targName))
to_chat(user, span_warning("Error: Law contains invalid text."))
Expand All @@ -34,11 +34,11 @@

/obj/item/ai_module/supplied/freeform/attack_self(mob/user)
var/newpos = tgui_input_number(user, "Please enter the priority for your new law. Can only write to law sectors 15 and above.", "Law Priority ", lawpos, 50, 15)
if(!newpos || QDELETED(user) || QDELETED(src) || !usr.can_perform_action(src, FORBID_TELEKINESIS_REACH))
if(!newpos || !user.is_holding(src) || !usr.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return
lawpos = newpos
var/targName = tgui_input_text(user, "Enter a new law for the AI.", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len), TRUE)
if(!targName)
if(!targName || !user.is_holding(src))
return
if(is_ic_filtered(targName))
to_chat(user, span_warning("Error: Law contains invalid text.")) // AI LAW 2 SAY U W U WITHOUT THE SPACES
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/AI_modules/full_lawsets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

/obj/item/ai_module/core/full/asimov/attack_self(mob/user as mob)
var/targName = tgui_input_text(user, "Enter a new subject that Asimov is concerned with.", "Asimov", subject, MAX_NAME_LEN)
if(!targName)
if(!targName || !user.is_holding(src))
return
subject = targName
laws = list("You may not injure a [subject] or, through inaction, allow a [subject] to come to harm.",\
Expand All @@ -73,7 +73,7 @@

/obj/item/ai_module/core/full/asimovpp/attack_self(mob/user)
var/target_name = tgui_input_text(user, "Enter a new subject that Asimov++ is concerned with.", "Asimov++", subject, MAX_NAME_LEN)
if(!target_name)
if(!target_name || !user.is_holding(src))
return
laws.Cut()
var/datum/ai_laws/asimovpp/lawset = new
Expand Down
3 changes: 1 addition & 2 deletions code/game/objects/items/AI_modules/hacked.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/obj/item/ai_module/syndicate/attack_self(mob/user)
var/targName = tgui_input_text(user, "Enter a new law for the AI", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len), TRUE)
if(!targName)
if(!targName || !user.is_holding(src))
return
if(is_ic_filtered(targName)) // not even the syndicate can uwu
to_chat(user, span_warning("Error: Law contains invalid text."))
Expand Down Expand Up @@ -77,4 +77,3 @@

/obj/item/ai_module/malf/display_laws()
return

2 changes: 1 addition & 1 deletion code/game/objects/items/AI_modules/supplied.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

/obj/item/ai_module/supplied/safeguard/attack_self(mob/user)
var/targName = tgui_input_text(user, "Subject to safeguard.", "Safeguard", user.name, MAX_NAME_LEN)
if(!targName)
if(!targName || !user.is_holding(src))
return
targetName = targName
laws[1] = "Safeguard [targetName]. Individuals that threaten [targetName] are not human and must be eliminated."
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/AI_modules/zeroth.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/obj/item/ai_module/zeroth/onehuman/attack_self(mob/user)
var/targName = tgui_input_text(user, "Enter the subject who is the only human.", "One Human", user.real_name, MAX_NAME_LEN)
if(!targName)
if(!targName || !user.is_holding(src))
return
targetName = targName
laws[1] = "Only [targetName] is human"
Expand Down
5 changes: 4 additions & 1 deletion code/game/objects/items/robot/robot_upgrades.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
one_use = TRUE

/obj/item/borg/upgrade/rename/attack_self(mob/user)
heldname = sanitize_name(tgui_input_text(user, "Enter new robot name", "Cyborg Reclassification", heldname, MAX_NAME_LEN), allow_numbers = TRUE)
var/new_heldname = sanitize_name(tgui_input_text(user, "Enter new robot name", "Cyborg Reclassification", heldname, MAX_NAME_LEN), allow_numbers = TRUE)
if(!new_heldname || !user.is_holding(src))
return
heldname = new_heldname
user.log_message("set \"[heldname]\" as a name in a cyborg reclassification board at [loc_name(user)]", LOG_GAME)

/obj/item/borg/upgrade/rename/action(mob/living/silicon/robot/R, user = usr)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/tcg/tcg_machines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ GLOBAL_LIST_EMPTY(tcgcard_machine_radial_choices)
/obj/machinery/trading_card_holder/attack_hand_secondary(mob/user)
if(isnull(current_summon))
var/card_name = tgui_input_text(user, "Insert card name", "Blank Card Naming", "blank card", MAX_NAME_LEN)
if(isnull(card_name))
if(isnull(card_name) || !user.can_perform_action(src))
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
current_summon = new /obj/structure/trading_card_summon/blank(locate(x + summon_offset_x, y + summon_offset_y, z))
icon_state = "card_holder_active"
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/toys.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@
//Add changing looks when i feel suicidal about making 20 inhands for these.
/obj/item/toy/dummy/attack_self(mob/user)
var/new_name = tgui_input_text(usr, "What would you like to name the dummy?", "Doll Name", doll_name, MAX_NAME_LEN)
if(!new_name)
if(!new_name || !user.is_holding(src))
return
doll_name = new_name
to_chat(user, span_notice("You name the dummy as \"[doll_name]\"."))
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/lavaland/geyser.dm
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
return

var/new_layer = tgui_input_list(user, "Select a layer", "Layer", GLOB.plumbing_layers)
if(isnull(new_layer))
if(isnull(new_layer) || !user.can_perform_action(src))
return
target_layer = GLOB.plumbing_layers[new_layer]

Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/cult/rune_spawn_action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
var/chosen_keyword
if(initial(rune_type.req_keyword))
chosen_keyword = tgui_input_text(owner, "Enter a keyword for the new rune.", "Words of Power", max_length = MAX_NAME_LEN)
if(!chosen_keyword)
if(!chosen_keyword || !turf_check(T))
return
//the outer ring is always the same across all runes
var/obj/effect/temp_visual/cult/rune_spawn/R1 = new(T, scribe_time, rune_color)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/cult/runes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ structure_check() searches for nearby cultist structures required for the invoca
fail_invoke()
return
var/obj/effect/rune/teleport/actual_selected_rune = potential_runes[input_rune_key] //what rune does that key correspond to?
if(!Adjacent(user) || !src || QDELETED(src) || user.incapacitated() || !actual_selected_rune)
if(!Adjacent(user) || QDELETED(src) || user.incapacitated() || !actual_selected_rune)
fail_invoke()
return

Expand Down
4 changes: 2 additions & 2 deletions code/modules/bitrunning/objects/disks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
names += initial(thing.name)

var/choice = tgui_input_list(user, message = "Select an ability", title = "Bitrunning Program", items = names)
if(isnull(choice))
if(isnull(choice) || !user.is_holding(src))
return

for(var/datum/action/thing as anything in selectable_actions)
Expand Down Expand Up @@ -105,7 +105,7 @@
names += initial(thing.name)

var/choice = tgui_input_list(user, message = "Select an ability", title = "Bitrunning Program", items = names)
if(isnull(choice))
if(isnull(choice) || !user.is_holding(src))
return

for(var/obj/thing as anything in selectable_items)
Expand Down
8 changes: 5 additions & 3 deletions code/modules/clothing/head/jobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
return

var/input = tgui_input_text(user, "What is the activation phrase?", "Activation phrase", "gadget", max_length = 26)
if(!input)
if(!input || !user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return
if(input in items_by_phrase)
balloon_alert(user, "already used!")
Expand All @@ -293,14 +293,16 @@
/obj/item/clothing/head/fedora/inspector_hat/attack_self(mob/user)
. = ..()
var/phrase = tgui_input_list(user, "What item do you want to remove by phrase?", "Item Removal", items_by_phrase)
if(!phrase)
if(!phrase || !user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return
user.put_in_inactive_hand(items_by_phrase[phrase])

/obj/item/clothing/head/fedora/inspector_hat/AltClick(mob/user)
. = ..()
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return
var/new_prefix = tgui_input_text(user, "What should be the new prefix?", "Activation prefix", prefix, max_length = 24)
if(!new_prefix)
if(!new_prefix || !user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return
prefix = new_prefix

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,13 @@
to_chat(telepath, span_warning("You don't see anyone to send your thought to."))
return
var/mob/living/recipient = tgui_input_list(telepath, "Choose a telepathic message recipient", "Telepathy", sort_names(recipient_options))
if(isnull(recipient))
if(isnull(recipient) || telepath.stat == DEAD || !is_species(telepath, /datum/species/jelly/stargazer))
return
var/msg = tgui_input_text(telepath, title = "Telepathy")
if(isnull(msg))
if(isnull(msg) || telepath.stat == DEAD || !is_species(telepath, /datum/species/jelly/stargazer))
return
if(!(recipient in oview(telepath)))
to_chat(telepath, span_warning("You can't see [recipient] anymore!"))
return
if(recipient.can_block_magic(MAGIC_RESISTANCE_MIND, charge_cost = 0))
to_chat(telepath, span_warning("As you reach into [recipient]'s mind, you are stopped by a mental blockage. It seems you've been foiled."))
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/simple_animal/bot/floorbot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
return data

// Actions received from TGUI
/mob/living/simple_animal/bot/floorbot/ui_act(action, params)
/mob/living/simple_animal/bot/floorbot/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(. || (bot_cover_flags & BOT_COVER_LOCKED && !HAS_SILICON_ACCESS(usr)))
return
Expand All @@ -161,7 +161,7 @@
tilestack.forceMove(drop_location())
if("line_mode")
var/setdir = tgui_input_list(usr, "Select construction direction", "Direction", list("north", "east", "south", "west", "disable"))
if(isnull(setdir))
if(isnull(setdir) || QDELETED(ui) || ui.status != UI_INTERACTIVE)
return
switch(setdir)
if("north")
Expand Down
2 changes: 2 additions & 0 deletions code/modules/mod/mod_link.dm
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@

/obj/item/clothing/neck/link_scryer/attack_self(mob/user, modifiers)
var/new_label = reject_bad_text(tgui_input_text(user, "Change the visible name", "Set Name", label, MAX_NAME_LEN))
if(!user.is_holding(src))
return
if(!new_label)
balloon_alert(user, "invalid name!")
return
Expand Down
8 changes: 4 additions & 4 deletions code/modules/photography/camera/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@
to_chat(user, span_notice("[pictures_left] photos left."))

if(can_customise)
var/customise = tgui_alert(user, "Do you want to customize the photo?", "Customization", list("Yes", "No"))
var/customise = user.is_holding(new_photo) && tgui_alert(user, "Do you want to customize the photo?", "Customization", list("Yes", "No"))
if(customise == "Yes")
var/name1 = tgui_input_text(user, "Set a name for this photo, or leave blank.", "Name", max_length = 32)
var/desc1 = tgui_input_text(user, "Set a description to add to photo, or leave blank.", "Description", max_length = 128)
var/caption = tgui_input_text(user, "Set a caption for this photo, or leave blank.", "Caption", max_length = 256)
var/name1 = user.is_holding(new_photo) && tgui_input_text(user, "Set a name for this photo, or leave blank.", "Name", max_length = 32)
var/desc1 = user.is_holding(new_photo) && tgui_input_text(user, "Set a description to add to photo, or leave blank.", "Description", max_length = 128)
var/caption = user.is_holding(new_photo) && tgui_input_text(user, "Set a caption for this photo, or leave blank.", "Caption", max_length = 256)
if(name1)
picture.picture_name = name1
if(desc1)
Expand Down
4 changes: 4 additions & 0 deletions code/modules/plumbing/ducts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,13 @@ All the important duct code:

/obj/item/stack/ducts/attack_self(mob/user)
var/new_layer = tgui_input_list(user, "Select a layer", "Layer", GLOB.plumbing_layers, duct_layer)
if(!user.is_holding(src))
return
if(new_layer)
duct_layer = new_layer
var/new_color = tgui_input_list(user, "Select a color", "Color", GLOB.pipe_paint_colors, duct_color)
if(!user.is_holding(src))
return
if(new_color)
duct_color = new_color
add_atom_colour(GLOB.pipe_paint_colors[new_color], FIXED_COLOUR_PRIORITY)
Expand Down
6 changes: 3 additions & 3 deletions code/modules/plumbing/plumbers/filter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
data["right"] = english_right
return data

/obj/machinery/plumbing/filter/ui_act(action, params)
/obj/machinery/plumbing/filter/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
Expand All @@ -42,6 +42,8 @@
var/selected_reagent = tgui_input_list(usr, "Select [which] reagent", "Reagent", GLOB.name2reagent)
if(!selected_reagent)
return TRUE
if(QDELETED(ui) || ui.status != UI_INTERACTIVE)
return FALSE

var/datum/reagent/chem_id = GLOB.name2reagent[selected_reagent]
if(!chem_id)
Expand Down Expand Up @@ -69,5 +71,3 @@
if(english_right.Find(chem_name))
english_right -= chem_name
right -= chem_id


2 changes: 2 additions & 0 deletions code/modules/plumbing/plumbers/reaction_chamber.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
var/selected_reagent = tgui_input_list(ui.user, "Select reagent", "Reagent", GLOB.name2reagent)
if(!selected_reagent)
return FALSE
if(QDELETED(ui) || ui.status != UI_INTERACTIVE)
return FALSE

var/datum/reagent/input_reagent = GLOB.name2reagent[selected_reagent]
if(!input_reagent)
Expand Down
Loading

0 comments on commit 5b141e4

Please sign in to comment.