implement 'complain mode' in seccomp for developer mode with snaps
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
snapd |
Fix Released
|
Medium
|
Tyler Hicks | ||
libseccomp (Ubuntu) |
Fix Released
|
Undecided
|
Tyler Hicks | ||
Xenial |
Fix Released
|
Undecided
|
Tyler Hicks | ||
Zesty |
Fix Released
|
Undecided
|
Tyler Hicks | ||
linux (Ubuntu) |
Fix Released
|
Undecided
|
Tyler Hicks | ||
Xenial |
Fix Released
|
Undecided
|
Tyler Hicks | ||
Zesty |
Fix Released
|
Undecided
|
Tyler Hicks |
Bug Description
A requirement for snappy is that a snap may be placed in developer mode which will put the security sandbox in complain mode such that violations against policy are logged, but permitted. In this manner learning tools can be written to parse the logs, etc and make developing on snappy easier.
Unfortunately with seccomp only SCMP_ACT_KILL logs to dmesg and while we can set complain mode to permit all calls, they are not logged at this time. I've discussed this with upstream and we are working together on the approach. This may require a kernel patch and an update to libseccomp, to filing this bug for now as a placeholder and we'll add other tasks as necessary.
UPDATE: ubuntu-
[Impact]
Snapd needs a way to log seccomp actions without blocking any syscalls in order to have a more useful complain mode. Such functionality has been acked upstream and patches are on their way into the Linux 4.14 kernel (backported to 4.12.0-13.14 in artful).
The corresponding libseccomp changes are still undergoing review (https:/
[libseccomp Test Case]
A large number of tests are ran as part of the libseccomp build. However, the "live" tests which test libseccomp with actual kernel enforcement are not ran at that time. They can be manually exercised to help catch any regressions. Note that on Artful, there's an existing test failure (20-live-
$ sudo apt build-dep -y libseccomp
$ sudo apt install -y cython
$ apt source libseccomp
$ cd libseccomp-*
$ autoreconf -ivf && ./configure --enable-python && make check-build
$ (cd tests && ./regression -T live)
All tests should pass on zesty (12 tests) and xenial (10 tests). On artful, you'll see one pre-existing failure:
...
Test 20-live-
...
Regression Test Summary
tests run: 12
tests skipped: 0
tests passed: 11
tests failed: 1
tests errored: 0
=======
-------
Now we can build and run a small test program to test the SCMP_ACT_LOG action in the way that snapd wants to use it for developer mode:
$ sudo apt install -y libseccomp-dev
$ gcc -o lp1567597-test lp1567597-test.c -lseccomp
$ ./lp1567597-test
With a kernel that contains the logging patches and an updated libseccomp, the exit code should be 0 and you should have an entry in the system log that looks like this:
audit: type=1326 audit(150585963
If you have an updated libseccomp with an old kernel, you'll see that seccomp_init() fails due to the added compatibility check inside of libseccomp determines that the kernel doesn't have proper support for the new log action:
$ ./lp1567597-test
ERROR: seccomp_init: Invalid argument
[Linux Kernel Test Case]
All of the libseccomp test cases apply here.
-------
Running the seccomp kernel selftests is also a great to exercise seccomp and the kernel patch set proposed for the SRU includes additional seccomp selftests. To build, enter into the root of the kernel source tree and build the seccomp test binary:
$ make -C tools/testing/
Now you can execute tools/testing/
-------
Now we can run a single test to verify that SECCOMP_RET_LOG is logged when the seccomp BPF evaluates to that action. First, verify that "log" is listed in the actions_logged sysctl:
$ cat /proc/sys/
kill trap errno trace log
Now, build and run the test program:
$ gcc -o lp1567597-
$ ./1567597-
SUCCESS!
It should have generated a message like this in /var/log/syslog:
audit: type=1326 audit(150726341
Disable "log" logging in the sysctl:
$ echo kill trap errno trace | sudo tee /proc/sys/
kill trap errno trace
Rerun the test program and ensure that nothing was logged this time.
[Regression Potential]
Relatively small for libseccomp since the core logic is in the kernel and we're only exposing the new action through libseccomp. The changes include smarts to query the kernel to see if the action is available in the kernel. Calling applications will not be able to use the action on older kernels that don't support it.
The kernel patches received a lot of review between Kees and some others interested in improved seccomp logging. I authored the patches and feel comfortable/
CVE References
Changed in snappy: | |
status: | New → Confirmed |
summary: |
- support 'complain mode' for developer mode with snaps + implement 'complain mode' in seccomp for developer mode with snaps |
description: | updated |
Changed in snappy: | |
importance: | Undecided → Medium |
Changed in libseccomp (Ubuntu): | |
status: | New → Confirmed |
Changed in linux (Ubuntu): | |
status: | New → In Progress |
assignee: | nobody → Tyler Hicks (tyhicks) |
Changed in libseccomp (Ubuntu): | |
assignee: | nobody → Tyler Hicks (tyhicks) |
Changed in libseccomp (Ubuntu): | |
status: | In Progress → New |
description: | updated |
summary: |
- [FFe] implement 'complain mode' in seccomp for developer mode with snaps + implement 'complain mode' in seccomp for developer mode with snaps |
Changed in libseccomp (Ubuntu Xenial): | |
assignee: | nobody → Tyler Hicks (tyhicks) |
Changed in libseccomp (Ubuntu Zesty): | |
assignee: | nobody → Tyler Hicks (tyhicks) |
Changed in libseccomp (Ubuntu Xenial): | |
status: | New → In Progress |
Changed in libseccomp (Ubuntu Zesty): | |
status: | New → In Progress |
Changed in linux (Ubuntu Xenial): | |
assignee: | nobody → Tyler Hicks (tyhicks) |
Changed in linux (Ubuntu Zesty): | |
assignee: | nobody → Tyler Hicks (tyhicks) |
Changed in linux (Ubuntu Xenial): | |
status: | New → In Progress |
Changed in linux (Ubuntu Zesty): | |
status: | New → In Progress |
description: | updated |
description: | updated |
Changed in snappy: | |
status: | Confirmed → In Progress |
description: | updated |
description: | updated |
Changed in linux (Ubuntu Xenial): | |
status: | In Progress → Fix Committed |
Changed in linux (Ubuntu Zesty): | |
status: | In Progress → Fix Committed |
tags: | added: cscc |
What's the benefit of a complain mode for seccomp in snappyland? AppArmor denials can usually be addressed by changing ./configure flags or hardcoded paths or something, but there's not much to be done for "this application uses syscalls we forbid" except eliding the syscalls from the source, right?
Allowing it to run without trouble feels like it provides a false sense of progress or control when none is intended.
Thanks