campadrenalin / hardlupa Goto Github PK
View Code? Open in Web Editor NEWA wrapper that increases security of a Lupa runtime with process sandboxing and disabled Lua libs.
A wrapper that increases security of a Lupa runtime with process sandboxing and disabled Lua libs.
These are methods of lupa.LuaRuntime that we need to replicate over to the safer HardLupa interface. LuaRuntime.require, however, will never be ported for safety reasons, so we don't have to worry about that.
The Python-level sandbox should immediately upon creation revoke all its access to the filesystem and any sensitive modules, in a way that cannot be undone from the inside. Instant permanent permissions drop before a single character of foreign code is processed. That way, if the Lua-level safeguards fail, you still have process-level safety in the sandbox to break out of.
Here's the real safety gold. Write a function globalflush(LuaRuntime x, list names = safe_set, dict values = {})
such that:
values
is empty, use the existing values for every global named in names
.values
is not empty, erase all globals and replace them with the contents of the values
dict.Thus, you can run globalflush once at the start of the runtime with no arguments to collect up all the standard libraries deemed safe (the list is defined as a constant in the hardlupa module), cache the result, and call globalflush with that result at any time to restore the runtime to a fresh state.
There's a definite performance hit running each Runtime in a separate process. Some situations might call for running a pool of runtimes in the sandbox, or in less paranoid situations, running in the same process as the Python logic. Separating the multiprocessing code into a Sandbox class should provide that kind of flexibility, which is essential (at the very least) for the project I'm going to be using this project for (which will create a lot of Runtimes but is injection-risky enough to still warrant process isolation).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.