Filing this so it's on our radar as a potential project. It's a nice to have, but more suited towards a GSoC/TSoP project than anything else IMO.
FreeBSD has a sandboxing/capabilities framework called capsicum(4) (https://www.freebsd.org/cgi/man.cgi?query=capsicum&sektion=4). It would be good for tor to support this in addition to seccomp2, just so people aren't out of luck on non-Linux systems wrt sandboxing.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items
0
Link issues together to show that they're related.
Learn more.
Tor has an existing abstraction layer for accessing seccomp'd syscalls on Linux, using a bunch of functions prefixed with sandbox_.
Is it possible to extend or modify that abstraction layer, rather than adding a separate interface for FreeBSD?
That would make it easier to maintain once it's merged.
The problem is that seccomp2 uses a filtering approach. Essentially, once you've whitelisted the things you want to access, you can call open(2), socket(2), etc. at will and on demand.
Note that the code I've written in the Tor codebase has diverged quite a bit from the PoC. The PoC is ugly code meant to serve as a brain dump and code testing area.
This work is nearing completion for a milestone 1. I've diverged quite a bit from the original PoC. How should I proceed from here in getting the code reviewed and merged upstream?
The only known issue is that when sandbox mode is enabled on FreeBSD/HardenedBSD, transparent proxy mode breaks. I'm researching the breakage. Given that transparent proxy mode is not the primary use case nor is widely used, I feel like the current work can go in (pending code review and adjustments resulting from the review) with an errata patch later on.
I'm going to bring this work up-to-date with the latest master branch. It has a few merge conflicts. @ahf, would you have time to review this work after the merge conflicts are resolved?
Cool. I'll also try to spend some time on the transparent proxy mode. I think I know what's going on there. The /dev/pf file descriptor probably needs ioctl capabilities.
So it turns out that the transproxy issue is with libevent, which creates and maintains its own sockets. I've tested transproxy and it's working, however DNS resolutions fail.
So curl http://4.ifconfig.pro/ fails, but curl http://108.61.202.109/ works (108.61.202.109 is the IP of 4.ifconfig.pro).
Given that this is an issue with libevent and not tor, I believe that Capsicum in tor itself is working as intended. I'll open a bug report with libevent to see if we can figure out how to teach it to be Capsicum-safe. Chances are, it may need a sockets abstraction API. Essentially, you'll register a callback for whenever a socket needs to be created. libevent would call that callback instead of socket(2) directly.
It looks like libevent not being Capsicum-friendly also affects Capsicum support when Tor is used as a relay. We need to fix libevent first before the ORPort and DNSPort options work when Capsicum is enabled via the Sandbox option.
Effectively, that means that this new Capsicum support is only applicable to running client nodes.