Answer the question
In order to leave comments, you need to log in
How to isolate unsafe code in a dotnet core application?
Good afternoon. I am developing an application that uses built-in lua scripts. Because with the condition of the specifics of the task, dotnet core is needed, the choice fell on NeoLua. But I can't restrict the rights of the script code being executed. As an example - read access from files. If we abstract from Lua, then the task comes down to a simple question: How to isolate unsafe code in a dotnet core application?
The .NET Framework had an AppDomain but
.NET Core does not support AppDomains or sandboxing:
Free of problematic tech. .NET Core doesn't include certain technologies we decided to discontinue because we found them to be problematic, for instance AppDomain and sandboxing. If the scenario still makes sense for .NET Core, our plan is to have replacements. For example, AssemblyLoadContext replaces AppDomains for loading and isolating assemblies.
public static void Main(string[] args)
{
//Sandbox for deny read files acess
{
var text = string.Empty;
using (var reader = new StreamReader("test.txt"))
{
text = reader.ReadToEnd();
}
}
}
Answer the question
In order to leave comments, you need to log in
The list of implementations is here lua-users.org/wiki/LuaImplementations
For example, this is https://github.com/chkn/AluminumLua
You can not add any libraries to your context at all and add your own methods in your code that will be called on functions in lua.
ps of the open source library, you can always fix the code in the place where the file opens.
try using docker, although this is also a sieve, but perhaps better customized than nothing
https://security.stackexchange.com/questions/29378...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question