Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scripting/exploit): Redefine os.system to prevent command execution on the server. #2891

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ekaliclua
Copy link

Redefine os.execute to prevent command execution on the server

Goal of this PR

The goal of this PR is to redefine the os.execute function to prevent it from being used to execute commands on the server. This is done to enhance security by ensuring that no arbitrary system commands can be run through this function.

How is this PR achieving the goal

This PR achieves the goal by redefining the os.execute function to raise an error with a message indicating that the function has been disabled for security reasons. This prevents any attempt to use os.system to execute commands.

This PR applies to the following area(s)

  • Server
  • ScRT: Lua

Successfully tested on

Game builds: Latest stable build

Platforms: Windows, Linux

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Fixes issues

/

@github-actions github-actions bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Oct 30, 2024
@FabianTerhorst
Copy link
Contributor

Can you make it depend on a ConVar? We can't do this by default without breaking preexisting scripts.

@p1u3o
Copy link

p1u3o commented Oct 30, 2024

Can this not be tied to some kind of ace permission similar to ExecuteCommand?

Saying that, the current implementation of this can by bypassed by the various io.* functions

@AvarianKnight
Copy link
Contributor

AvarianKnight commented Oct 30, 2024

Would it not make more sense to just have a ConVar to turn on the use of a 'minimal lua os library' (only have access to clock, date, difftime, locale, and time) and another to completely disable the IO library (sv_minimalLuaOSLibrary and sv_disableLuaIOLibary) this would block a lot of "harmful" behavior (though the IO block can be worked around by other means, this would stop the possibility to abuse it in the most common runtime)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Requires changes before it's considered valid and can be (re)triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants