4 ms·
I'm wondering if it's possible to get a simpler/better attempt at sandboxing by just inspecting the generated bytecode, instead of focusing on the .py text file
by zzleeper 12y ago
I'm wondering if it's possible to get a simpler/better attempt at sandboxing by just inspecting the generated bytecode, instead of focusing on the .py text file..
- mrfusion 12y agoThat's a really good point. I'm eager to hear a response. It certainly seems like you could just ban a bunch of byte codes and easily detect them. I must be missing something.
- nl 12y agoGenerally speaking it's the data associated with the calls that is risky, not the bytecode itself. The way the JVM works is by having specific permission checks at points within the code, and they are enforced by the JVM. I think the CLR works in a similar fashion. You can run Python on top of the JVM and take advantage of this, but I think the version of Python (JYthon) is pretty old.
- deckiedan 12y agoThere's an in-between step, the "AST" (Abstract Syntax Tree), which is a better place to do this stuff than in the actual byte code. You still have context and a lot more useful information at that point, and can re-write the AST to use workarounds, etc. That's the approach I took with https://github.com/danthedeckie/simpleeval https://github.com/danthedeckie/simpleeval .