I'm building a data processing system where users can submit hooks to execute on incoming data.
The hooks are untrusted and should execute in a sandbox with access only to a limited API that I expose – essentially like a DSL. Ideally, users write hooks in ES6 or Python. The code should preferably be executable from most runtimes, but definitely from Python.
From my perspective, I'm looking for this workflow:
- Users submits source code for a hook, which I compile and store
- I retrieve the compiled code and execute it
- Only calls to the predefined APIs have side-effects
What technologies do you recommend to achieve this?
These are the ideas I'm currently exploring:
Users write hooks in TypeScript, which is compiled to WebAssembly with AssemblyScript. I have not found any guidelines on the feasibility, security or overhead of running sandboxed WebAssembly in Python.
I check user-submitted code for imports and system/networking calls and then eval it in the current process. I have not found any guidelines on exactly which checks are necessary to securely eval Python and/or ES6.