Giter VIP home page Giter VIP logo

hardlupa's People

Contributors

campadrenalin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hardlupa's Issues

Add "globals" and "table" properties to wrapper.

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.

Deprivelege the external process

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.

Add globalflush() function for actual Lua-level hardening

Here's the real safety gold. Write a function globalflush(LuaRuntime x, list names = safe_set, dict values = {}) such that:

  • Returns a dict of all preserved globals.
  • Deletes any globals that are not preserved from the global namespace.
  • Running it with no extra arguments assumes the standard "safe" set of names for globals.
  • If values is empty, use the existing values for every global named in names.
  • If 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.

Move sandboxing logic into a separate class

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.