Textualize / textual-serve

Serve Textual apps locally
MIT License
162 stars 6 forks source link

Discussion: Subprocess isolation #5

Closed patha454 closed 2 months ago

patha454 commented 2 months ago

Hi Will and the Textual team...

I've just noticed textual-serve, and I'm interested in using it for some in-house projects. I'm interested in improving the security of the served subprocesses, and I'd like to know if you're open to PRs in the direction I have in mind...

I see you're currently creating a new subprocess running the target program or each connection. This is pretty lightweight - good enough for a beta and hobby use. I'm concerned about the security implications for industrial use - I'm thinking about isolating each subprocess inside a lightweight microVM, such as Firecracker, to isolate each subprocess against privileged escalation attacks or malicious users escaping into the shell.

I had considered running textual-serve inside a single microVM, without any changes to the code. Running a single microVM would not isolate processes against each other. I'm interested in isolating each subprocess inside a microVM. Using a microVM per connection/subprocess would require us to modify textual-serve a bit.

If we go ahead with isolation processes in microVMs, would you be interested in a PR to merge the code back to the mainline? If so, are there any considerations you have in mind?

willmcgugan commented 2 months ago

It's not possible to escape in to the shell with textual-serve. We use a custom protocol, and don't simply proxy a shell session.

Serving Textual apps is at least as secure (likely more so) as any other web application server. But I would of course be keen to support any additional security requirements beyond that. You might want to keep me informed of your progress as this project is still being actively worked on.

patha454 commented 2 months ago

Thanks for the clarification, Will.

I'm (vaguely) aware of the custom protocol - I saw the JSON metadata and data packets being encoded, but I still need to spend some time studying how they're handled on the Textual driver end of things. I agree it's not simply proxying a shell session, but sooner or later Python is running and I'm wary of injection attracts. That's not a flaw in your software - I appreciate the quality of your work here, especially Rich - just a requirement of my use case.

We'll do some more security analysis on them both. If we find anything serious, would contacting you via the email address on https://www.textualize.io/contact/ be acceptable? - I wouldn't want to post any vulnerabilities publicly, of course.

willmcgugan commented 2 months ago

You could send them directly to me if you like. Will at Textualize.io