mrminer reports: Lua prerequirements for NPCs: ... #6015

Open
opened 2024-01-19 20:47:11 +00:00 by yourland-report · 5 comments

mrminer reports a bug:

Lua prerequirements for NPCs: e.g. 'return (npc.properties["foo"] * 2) != npc.properties["bar"]'

Player position:

{
	x = 3045.4150390625,
	y = 123.56199645996,
	z = 308.92901611328
}

Player look:

{
	x = 0.89370530843735,
	y = -0.33693096041679,
	z = -0.29625716805458
}

Player information:

{
	avg_jitter = 0.0020000040531158,
	connection_uptime = 470,
	serialization_version = 29,
	patch = 0,
	minor = 7,
	lang_code = "",
	state = "Active",
	protocol_version = 42,
	major = 5,
	formspec_version = 6,
	min_jitter = 0,
	version_string = "5.7.0",
	ip_version = 6,
	min_rtt = 0.11299999803305,
	avg_rtt = 0.11999999731779,
	max_rtt = 1.5930000543594,
	max_jitter = 1.4620000123978
}

Player meta:

{
	fields = {
		["stamina:exhaustion"] = "105.5",
		yl_commons_thankyou = "81",
		jointime = "1646186882",
		bitten = "0",
		["ocean_build.last_warning"] = "1.6733e+09",
		["ocean_build.forbidden"] = "true",
		["ocean_build.ocean_built"] = "12",
		punch_count = "27715",
		hud_state = "on",
		inflicted_damage = "570270",
		["petz:werewolf"] = "0",
		["petz:lycanthropy"] = "0",
		["petz:werewolf_vignette_id"] = "19",
		yl_church = "return {[\"last_death_portal\"] = 1705618734, [\"last_heal\"] = 1677356984, [\"last_death\"] = {[\"x\"] = 3012, [\"y\"] = 109, [\"z\"] = 228}}",
		placed_nodes = "79953",
		partychat = "party",
		played_time = "4386164",
		arenalib_watchID = "0",
		yl_commons_player_joined = "1705696779",
		died = "720",
		crafted = "61656",
		["unified_inventory:bags"] = "return {\"unified_inventory:bag_large\", \"unified_inventory:bag_large\", \"unified_inventory:bag_large\", \"unified_inventory:bag_large\"}",
		["petz:old_override_table"] = "return {[\"new_move\"] = true, [\"jump\"] = 1.5, [\"gravity\"] = 1, [\"sneak_glitch\"] = false, [\"speed\"] = 2, [\"sneak\"] = true}",
		arenalib_infobox_arenaID = "0",
		xp = "75533",
		["signslib:pos"] = "(2934,92,339)",
		["3d_armor_inventory"] = "return {\"shields:shield_crystal 1 48755\", \"3d_armor:helmet_nether 1 48755\", \"3d_armor:boots_crystal 1 48730\", \"3d_armor:leggings_crystal 1 48755\", \"3d_armor:chestplate_crystal 1 3580\", \"\"}",
		yl_commons_player_created = "1646186882",
		["petz:werewolf_clan_idx"] = "4",
		digged_nodes = "187161",
		["hud_manager:choppy:waypoint_enabled"] = "y",
		["stamina:level"] = "6",
		repellant = "0",
		["stamina:poisoned"] = "no"
	}
}

Log identifier


[MOD] yl_report log identifier = 5TYKNhaXvtHBjgcgy5JIsWOQLFBuoytv

Profiler save:

profile-20240119T204711.json_prettyEE

Status:

# Server: version: 5.7.0-yl-thx-tmm | game: Minetest Game | uptime: 2d 4h 33min 26s | max lag: 1.2s | clients (25/52): 473, AliasAlreadyTaken, Bailiff, BLuOXide, Boot, BTS-, Calamity_Jones, daydream, flux, jackofthebean000, Keya, Lupercus, Makk5im, mrminer, Murmel, Pelu, poppyasdan, rewired_X, rheo, Service, Sokomine, STEALTH, tagtraum, thatchristianguy, Tute

Teleport command:

/teleport xyz 3045 124 309

Compass command:

/give_compass Construction 5TYKNhaXvtHBjgcgy5JIsWOQLFBuoytv D2691E 3045 124 309
mrminer reports a bug: > Lua prerequirements for NPCs: e.g. 'return (npc.properties["foo"] * 2) != npc.properties["bar"]' Player position: ``` { x = 3045.4150390625, y = 123.56199645996, z = 308.92901611328 } ``` Player look: ``` { x = 0.89370530843735, y = -0.33693096041679, z = -0.29625716805458 } ``` Player information: ``` { avg_jitter = 0.0020000040531158, connection_uptime = 470, serialization_version = 29, patch = 0, minor = 7, lang_code = "", state = "Active", protocol_version = 42, major = 5, formspec_version = 6, min_jitter = 0, version_string = "5.7.0", ip_version = 6, min_rtt = 0.11299999803305, avg_rtt = 0.11999999731779, max_rtt = 1.5930000543594, max_jitter = 1.4620000123978 } ``` Player meta: ``` { fields = { ["stamina:exhaustion"] = "105.5", yl_commons_thankyou = "81", jointime = "1646186882", bitten = "0", ["ocean_build.last_warning"] = "1.6733e+09", ["ocean_build.forbidden"] = "true", ["ocean_build.ocean_built"] = "12", punch_count = "27715", hud_state = "on", inflicted_damage = "570270", ["petz:werewolf"] = "0", ["petz:lycanthropy"] = "0", ["petz:werewolf_vignette_id"] = "19", yl_church = "return {[\"last_death_portal\"] = 1705618734, [\"last_heal\"] = 1677356984, [\"last_death\"] = {[\"x\"] = 3012, [\"y\"] = 109, [\"z\"] = 228}}", placed_nodes = "79953", partychat = "party", played_time = "4386164", arenalib_watchID = "0", yl_commons_player_joined = "1705696779", died = "720", crafted = "61656", ["unified_inventory:bags"] = "return {\"unified_inventory:bag_large\", \"unified_inventory:bag_large\", \"unified_inventory:bag_large\", \"unified_inventory:bag_large\"}", ["petz:old_override_table"] = "return {[\"new_move\"] = true, [\"jump\"] = 1.5, [\"gravity\"] = 1, [\"sneak_glitch\"] = false, [\"speed\"] = 2, [\"sneak\"] = true}", arenalib_infobox_arenaID = "0", xp = "75533", ["signslib:pos"] = "(2934,92,339)", ["3d_armor_inventory"] = "return {\"shields:shield_crystal 1 48755\", \"3d_armor:helmet_nether 1 48755\", \"3d_armor:boots_crystal 1 48730\", \"3d_armor:leggings_crystal 1 48755\", \"3d_armor:chestplate_crystal 1 3580\", \"\"}", yl_commons_player_created = "1646186882", ["petz:werewolf_clan_idx"] = "4", digged_nodes = "187161", ["hud_manager:choppy:waypoint_enabled"] = "y", ["stamina:level"] = "6", repellant = "0", ["stamina:poisoned"] = "no" } } ``` Log identifier ``` [MOD] yl_report log identifier = 5TYKNhaXvtHBjgcgy5JIsWOQLFBuoytv ``` Profiler save: ``` profile-20240119T204711.json_prettyEE ``` Status: ``` # Server: version: 5.7.0-yl-thx-tmm | game: Minetest Game | uptime: 2d 4h 33min 26s | max lag: 1.2s | clients (25/52): 473, AliasAlreadyTaken, Bailiff, BLuOXide, Boot, BTS-, Calamity_Jones, daydream, flux, jackofthebean000, Keya, Lupercus, Makk5im, mrminer, Murmel, Pelu, poppyasdan, rewired_X, rheo, Service, Sokomine, STEALTH, tagtraum, thatchristianguy, Tute ``` Teleport command: ``` /teleport xyz 3045 124 309 ``` Compass command: ``` /give_compass Construction 5TYKNhaXvtHBjgcgy5JIsWOQLFBuoytv D2691E 3045 124 309 ```
AliasAlreadyTaken was assigned by yourland-report 2024-01-19 20:47:11 +00:00

Could be used to execute any code, right?

Could be used to execute any code, right?
Member

Any code in the same way as luac can execute any code. So it's doable.

Any code in the same way as luac can execute any code. So it's doable.
AliasAlreadyTaken added the
1. kind/enhancement
label 2024-01-20 02:38:59 +00:00
Member

Could be used to execute any code, right?
Any code in the same way as luac can execute any code. So it's doable.

luacs only have access to a very limited subset of the lua public libraries that minetest has built in. also, they are coded to limit the execution time of individual luacs - but i'm not too sure how they do that. but i know they do it, or it'd be trivial to DOS a server (while true do a = 1 end).

luacs can execute arbitrary code that's written in that specific luac, but they don't have access to all the lua libraries, and their input is also limited.

> Could be used to execute any code, right? > Any code in the same way as luac can execute any code. So it's doable. luacs only have access to a very limited subset of the lua public libraries that minetest has built in. also, they are coded to limit the execution time of individual luacs - but i'm not too sure how they do that. but i know they do it, or it'd be trivial to DOS a server (`while true do a = 1 end`). luacs can execute arbitrary code that's written in that specific luac, but they don't have access to all the lua libraries, and their input is also limited.
Member

Luacs limit execution time by using a debug hook that gets called after a number of "events" (basically lua bytecode instructions):
debug.sethook(timeout, "", MAXEVENTS) (you also need to disable jit compilation for this to work).
It's not perfect for limiting execution time (because it's possible to use expensive bytecode instructions in a loop, and this counts the number of them, not actual execution time).

And yes, lua allows to fully control the environment in which the code gets executed - you can throw away or override any functions you don't need or add some npc-specific functions.

Luacs limit execution time by using a debug hook that gets called after a number of "events" (basically lua bytecode instructions): `debug.sethook(timeout, "", MAXEVENTS)` (you also need to disable jit compilation for this to work). It's not perfect for limiting execution time (because it's possible to use expensive bytecode instructions in a loop, and this counts the number of them, not actual execution time). And yes, lua allows to fully control the environment in which the code gets executed - you can throw away or override any functions you don't need or add some npc-specific functions.
Member

It's not perfect for limiting execution time (because it's possible to use expensive bytecode instructions in a loop, and this counts the number of them, not actual execution time).

another good example is that string.match can have near-exponential run-time with certain carefully crafted patterns, (presumably only using 1 lua "event"), so that's not available on the luac.

> It's not perfect for limiting execution time (because it's possible to use expensive bytecode instructions in a loop, and this counts the number of them, not actual execution time). another good example is that string.match can have near-exponential run-time with certain carefully crafted patterns, (presumably only using 1 lua "event"), so that's not available on the luac.
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: your-land/bugtracker#6015
No description provided.