Repository navigation
Restrict safe mode containers - #32
Open
daniel-larraz wants to merge 1 commit into
Open
daniel-larraz wants to merge 1 commit into
daniel-larraz wants to merge 1 commit into
Conversation
Safe mode containers ran as root with Docker's default capabilities and a writable file system, and could start any number of processes. Run them as an unprivileged user with no capabilities, no way to gain privileges, a read-only file system with an in-memory /tmp, and a limit on processes and threads. The container's user cannot read files that only their owner can read, so make the interpreter input readable by all users and keep it from other users of the host with a private directory. In safe mode, read a Lustre file in this process and send it over stdin instead of mounting it, so that its permissions still don't matter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Safe mode containers currently run as root with Docker's default capabilities and a writable file system, and can start any number of processes. This PR adds these
docker runflags:--user 65534:65534--cap-drop ALL--security-opt no-new-privileges--read-onlyand--tmpfs /tmp/tmpthat counts toward--memory--pids-limit 1024Breaking change
The Kind 2 executable and solvers must now be readable and executable by all users, for example mode
755. Anything stricter fails at run time. For example, an OpenSMT binary with mode740fails withEACCESincreate_process.Changes needed to keep the interpreter working
The new flags stop the container from reading mounted files that only their owner can read, which would break the interpreter in two ways:
700) temp directory that keeps it from other users of the host.interpret(URI, ...): in safe mode, the API now reads the file and sends it over stdin, asinterpret(String, ...)already does, instead of mounting it. Without this, a mode600file returned an empty trace with no error.Choosing the process limit
The limit also counts threads. On a small test program, SMTInterpol peaked between 427 and 497 because each solver instance is a multi-threaded JVM, and it failed with
java exited with code 1at a limit of 256. The other solvers peaked at about 40. 1024 leaves about twice the observed peak, but larger programs or machines with more CPUs could need more. The limit is a constant for now, so changing it needs a release.Testing
All of this ran on a local rootful Docker daemon with
kind2-safe:latestbuilt from this repo../gradlew testpasses, including a newSafeModeTest.executeinterpret(String, ...)interpret(URI, ...)with mode644and600filesdocker rundirectly, results matched the unhardened runs for Z3, cvc5, Yices2, MathSAT and SMTInterpol. OpenSMT gave the expected results once its binary was world-readable. Bitwuzla failed the same way in both, because it only supports bit-vector logics and the test program uses integers.--ivc,--enable MCS,--testgen,--dump_cexand--compositionalgave the same results as unhardened runs on the same test program, with no errors. I didn't inspect the files those options may generate, so a feature that writes outside/tmpcould still fail.Not tested:
Existing issue, not changed here
Interpreter input temp files are never deleted. They now also leave behind their private directory.
🤖 Generated with Claude Code