5 ms·
> Sandboxing™ Writing it like this is kind of funny, hoenstly, but not for the reasons you probably think. > give you that pledge+unveil doesn't? Not requiri
by ruthmarx 2y ago
> Sandboxing™
Writing it like this is kind of funny, hoenstly, but not for the reasons you probably think.
> give you that pledge+unveil doesn't?
Not requiring the cooperation of developers to opt-in, for starters.
You really think pledge and unveil are equivalent to sandboxing? Can you refer to any sandboxing solution or technologies that limit themselves to restricting syscalls and hiding file paths? Unveil is a lot more useful as a component in sandboxing, I'll give you that.
Something like linux namespaces or even capabilities would be a hell of a lot better though.
- ori_b 2y agoMost programs require a setup phase, where they want a great deal of access to the environment to set up the resources they use, and a steady state phase, where they need very little access beyond pre-opened file descriptors. An externally imposed sandboxing feature can be useful for namespacing, but is necessarily less restrictive than pledge and unveil. For example, in steady state on OpenBSD, most programs can't even their own configs.
- BSDobelix 2y agoOh look who is here Ori!! How is gefs going and do we have in the next 9Front release?
- ruthmarx 2y ago> An externally imposed sandboxing feature can be useful for namespacing, but is necessarily less restrictive than pledge and unveil. An externally imposed sandboxing feature isn't necessarily less restrictive than pledge and unveil at all, although I'm curious why you think that is the case. To say nothing of the fact that pledge and unveil are wholly dependent on developer opt-in. A good sandboxing solution should be robust and not require the cooperation of the programs that require sandboxing.
- 0x457 2y agoThose are two different kinds of sandboxing. One protects application from itself - "here is what I use, if I try anything else, then it's a bug". Sandboxing you're talking about protects system from the application. You really need both. re: restrictiveness With external sandboxing, you need to restrict to a common denominator of all application states you see youself observing that application. Internal sandbox can adjust itself as it goes.
- ruthmarx 2y ago> Those are two different kinds of sandboxing. I'm arguing that only one example is sandboxing, the other is imposing limitations but doesn't meet the definition of sandboxing.
- yjftsjthsd-h 2y ago> An externally imposed sandboxing feature isn't necessarily less restrictive than pledge and unveil at all, although I'm curious why you think that is the case. With pledge, you can read config files, open a file handle to your logs, and then completely drop the ability to open() files at all for the remaining lifetime of the program. How would you do that from outside the program?
- ruthmarx 2y agoBy monitoring and intercepting what the program is doing?
- yjftsjthsd-h 2y agoI guess technically you could write a dynamic policy that... I guess you'd give it a list of files that the program can access exactly once? But that seems difficult and brittle. Is anyone actually doing that?
- ruthmarx 2y agoNo, I suppose not, but then, is there really an advantage to doing so? I'm much more concerned with blocking write and execute access than I am about a potential hacker being able to read the config files of the program they leveraged to get a shell. I think it's a good approach and part of defense in depth, but if we're comparing approaches I'll tale the former every time.
- ori_b 2y ago> No, I suppose not, but then, is there really an advantage to doing so? A massive one; not reading the config is just a consequence of dropping all file system access once you're done with the initial program setup. You can also set up listening sockets, and then stop the program from making any new network connections, even after a compromise. And so on, with most resources. There are a lot of resources that tend to be needed to set up a program. There tend to be very few needed once the program is running. How would you block all file system access after a program is finished reading its config files, the files they include, and the shared libraries and plugins scattered around the file system? How would you turn off all network access after the listening socket is established? With Pledge, it's trivial: load_config(); load_plugins(); open_sockets(); pledge(NULL, NULL); run(); Pledge makes everything you're talking about work trivially, the only thing that's needed is for the program to opt in to security with one line of code. You don't need to micromanage the permissions and what the program is doing to drop privileges from the outside, with all of the race conditions and fragility that implies.
- tightbookkeeper 2y ago> Not requiring the cooperation of developers to opt-in, for starters. This is a good point. My initial thought is that the developers would know best what features their application needs? Furthermore, it's work that every user benefits from, rather than requiring an IT professional to reconfigure for each use case. What do you see as the downsides?
- yjftsjthsd-h 2y agoI don't think it applies in this exact case (the base OS locking itself down), but in general: > Furthermore, it's work that every user benefits from, rather than requiring an IT professional to reconfigure for each use case. A distro could distribute, say, bubblewrap configs that automatically sandbox packages and every user could likewise benefit from that. > What do you see as the downsides? I think you're right that devs are best placed to lock down their own code, but if you don't have developer buy-in (or if they just don't want to make the effort or aren't available) then externally-imposed sandboxes are a lot easier for distro maintainers or end users to add after the fact than trying to patch the actual program source to do pledge+unveil or such.
- mrweasel 2y ago> What do you see as the downsides? Legacy software, new security issues which has not yet been patched. As the operator you have no way to isolate the application, you just have to wait for the developer for both mitigation and bug-fixes. In the real world I don't see that making much of a difference. Many sandbox solutions aren't really being used anyway, legacy software can go on it's own VM and network. Micro-segmentation of networks are in style for those types of companies anyway. Pledge and Unveil seems like more pragmatic solutions to me, but they do require a certain level of care and engagement from the developers. If you don't have that, then things like SELinux, AppArmor or some type of sandbox that can be applied by the operator can help prevent an attacker from getting a foothold on a server or VM.
- tightbookkeeper 2y ago> you just have to wait for the developer If it’s open source then it can be patched in bsd packages manager. Most usage of pledge is here rather than being upstreamed.
- yjftsjthsd-h 2y ago> Not requiring the cooperation of developers to opt-in, for starters. True, meaningful in the general case, and completely irrelevant in this particular case, which started with specifically the question of OpenBSD applying the protection in question to its own base system. I actually agree that being able to externally impose a sandbox is super useful, but self-imposed restrictions are perfectly applicable in this usecase. > You really think pledge and unveil are equivalent to sandboxing? Can you refer to any sandboxing solution or technologies that limit themselves to restricting syscalls and hiding file paths? Unveil is a lot more useful as a component in sandboxing, I'll give you that. I think that pledge and unveil are a type of sandboxing, certainly. And... I'm struggling to think of any sandboxing tech that does anything but limit syscalls and filesystem access. After rereading https://github.com/containers/bubblewrap?tab=readme-ov-file#sandboxing https://github.com/containers/bubblewrap?tab=readme-ov-file#... a bit, I suppose there's a case for being able to change what a sandboxed process can see rather than only masking (ex. PID 1 is a different process inside and outside the sandbox), but that strikes me as a slight variation rather than a fundamental difference in what is or isn't a "sandbox" per se. Likewise, I could see an argument that OpenBSD's approach is coarser than it could be; ex. I think you could restrict a Linux process to keep your real user and be able to read files but not write them even though they're owned by your user and are 644, but that's more of a convenience thing than a true fundamental difference - an OpenBSD process could open files in read mode, keep the socket open, and then pledge away open() altogether which gives you the same outcome with more legwork.
- ruthmarx 2y ago> which started with specifically the question of OpenBSD applying the protection in question to its own base system. Agreed, my answers did quickly go beyond the original point being claimed. > I think that pledge and unveil are a type of sandboxing, certainly. I think they are limitations and that's about it. They don't fit the metaphor of a sandbox IMO. > but that strikes me as a slight variation rather than a fundamental difference in what is or isn't a "sandbox" per se. Fundamentally I see a sandbox as something that is hard for the sandboxed application to escape, or even communicate out from except via limited well defined channels. I don't think limiting syscalls alone satisfies that. As a test, I think a robust sandbox should be able to apply to any program, no matter what it is doing. Do you think pledge satisfies that? What about a complex piece of software that needs to use a number of syscalls that could be leveraged for an attack frequently, and so can't be meaningfully limited with pledge. If that software has a vulnerability, the attacker now has access to the host system at least to the extent of the user the program was running under. That attacker certainly isn't sandboxed, they don't even have to escape a sandbox because there wasn't really one there, just 'concepts of a sandbox'. Appreciating this discussion by the way!
- shiomiru 2y ago> Can you refer to any sandboxing solution or technologies that limit themselves to restricting syscalls and hiding file paths? FreeBSD has capsicum and Linux has seccomp-bpf & landlock. Of the three, pledge and unveil are the least horrible execution of the same idea (though capsicum is alright, too). Obviously it's not a "run any random machine code on my system safely" type of sandbox, rather it's used by e.g. browsers as defense in depth so that attackers can't just outright call execl.
- ruthmarx 2y ago> Of the three, pledge and unveil are the least horrible execution of the same idea I don't think they are the same idea though. pledge and unveil are significantly more limited in scope. > Obviously it's not a "run any random machine code on my system safely" type of sandbox That's pretty much what a sandbox is though. Not every limitation or security augmentation is a sandbox, nor does it have to be.
- shiomiru 2y ago> I don't think they are the same idea though. pledge and unveil are significantly more limited in scope. The "idea" I'm talking about is privilege dropping. But sure, you can also use seccomp for other things. > That's pretty much what a sandbox is though. Not every limitation or security augmentation is a sandbox, nor does it have to be. seccomp-bpf and pledge are both tools used to implement sandboxes in browsers.[1][2] Maybe you don't like this terminology, but it is quite well established at this point. [1]: https://wiki.mozilla.org/Security/Sandbox/Seccomp https://wiki.mozilla.org/Security/Sandbox/Seccomp [2]: https://www.openbsd.org/papers/eurobsdcon2022-landry-taming_the_fox.md https://www.openbsd.org/papers/eurobsdcon2022-landry-taming_...
- ruthmarx 2y ago> The "idea" I'm talking about is privilege dropping. OK. But privilege dropping alone does not a sandbox make. > seccomp-bpf and pledge are both tools used to implement sandboxes in browsers.[1][2] Maybe you don't like this terminology, but it is quite well established at this point. A browser sandbox is quite a different thing from an OS level sandbox, which is the context we are discussing sandboxes in.