Hi All, I'm taking a classic graduate course from MIT https://pdos.csail.mit.edu/6.824/ on my own (I'm not enrolled, just doing the course independently). There are 4 different labs in Go lang I plan to redo in Scala (MapReduce, Raft, Fault-tolerant Key/Value Service, Sharded Key/Value Service). There is also a bunch of lectures available on YouTube: https://pdos.csail.mit.edu/6.824/schedule.html. I would like to know if there is any interest in forming a study group to motivate each other to complete this course and work on the labs together. (Not necessarily in Scala/Go lang).
In terms of timeline, I'm starting right now. It's to get a head start on the official course schedule. Where it normally starts at the beginning of February and ends in late May.
It does and you are root. You are evaluating inside a docker container. It's not a bulletproof method but it will stop a few. The instances evaluating your code is also on a network not accessible from the internet. I'm not an expert in security, if you have any advice on how we can improve our defence please tell us.
I am not a pentesting expert. My first reaction is to leave everything as is, as it is a very cool to play with root access to docker containers (I managed to reboot one, but a new one immediately appeared on page reload).
My worst concern now would be network security. With root access, it is trivial to e.g. install spambots in all your containers (just checked, command execution works, and external network access is enabled). I think it is a good idea to at least disable networking. (Update: and use a minimal Docker image like Alpine Linux).
I agree with this. What's to stop me from opening a bunch of the containers and using them to DDOS someone or to send out spam emails? I'm already playing around with system commands and they seem to be entirely unrestricted.
Basically I can run any bash script, as is, with
import sys.process._
"BASH_COMMAND" !!
And I seem to be able to at least cause the containers to endlessly restart quite simply.
Yeah disabling networking was an idea. I prefer to leave it open so you can try http client/libraries that access the web. To limit spam, if it becomes an issue we could throttle the connection.
The general rule is that you want as many layers of security as you can get away with without making things impractically inconvenient. In this case, the first step is probably not letting the user's code run as root in the container. Gaining container-root is going to be the first step in many, many exploits and by letting code just run that way, you are giving a potential attacker that step for free.
Disclaimer: Absolutely not a security expert, just someone who is somewhat on the hook for security!
Please don't misunderstand this. I know from reading your postings on /r/scala that you are a humble person. Originally I actually didn't even knew if there was a contributor to the security section besides you and only wanted to tease. :D
Maybe Jessica McKellar's "Building and Breaking a Python Sandbox" talk can bring some ideas. (But maybe not! It might be too Python-specific or too language-level whereas you want to remain at a higher level with just Docker)
Congrats Guillaume! How much of ScalaKata code is in there? Sorry if I missed it in the post, but is Scastie open source? I'd love to finally fix scalatutorials.com :)
p.s. did you guys consider using a "serverless" architecture to isolate runners instead of docker? Also, are you running it with java -Djava.security.manager? If not then why?
The security manager can be disabled using reflection. If you don't allow you loose some libraries like Akka. The main thing that is missing from ScalaKata is autocompletion and it will be implemented in the summer during the GSOC. AWS lambda could be worth investigating. We don't expose an API for evaluating but others have expressed this need. Can you create an issue on GitHub for that?
In terms of timeline, I'm starting right now. It's to get a head start on the official course schedule. Where it normally starts at the beginning of February and ends in late May.