I just had a very troubling thought. I’ve been working on a project for a while… and we know we’d like to have mod support.
One of the ways we think we could give mod support is letting the users compile their own assemblies against an exposed API… and then loading their assemblies.
But this got me to thinking… does this create a major security risk. Not for us… but for our users.
Could someone upload a mod for our game onto steam workshop that contained malicious code and then use it to install malware on a user’s machine or something?
Yep, unless you sandbox their code somehow. There are some mechanisms in .NET for ‘untrusted’ code, but I don’t know how much they apply to this situation, or whether they’re usable in a Unity environment.
if you let them load their own assemblies yes, but if you provided scripting support with a limited api no. I would try and expose lua or maybe a subset of python, where it can only use basic language features or interact with your api.
yeah out of the box python can do a lot of damage, never tried to used python with unity before, but i know in more embedded uses of it like in nuke or maya it has more or less full privileges, with all modules available including sys, os and subprocess.
reaallyy?? how??
seriously couldnt find much information about making a moddable game in unity… really like NO INFO at all
so the only thing i could figure out was asset bundles
.obj and .ogg or .wav can be made read as text files im guessing??
Even Microsoft has mostly given up on sandboxing support at the framework level.
As of .NET 3.5 the new-hotness was Code Access Security; no idea if this works in Mono:
But fast-forward to the current version of that guidance and you get stern warnings that CAS is probably insufficient:
Eventually everything will move to some .NET Core flavor, which completely drops AppDomain and sandbox support in favor of AssemblyLoadContext (and OS-specific security features, which they mentioned in a .NET Core blog post last year but not in any detail).
Worse, AssemblyLoadContext is currently undocumented (but shipping).