It is planned to port the pledge isolation mechanism to Linux

Recently, the author of the Cosmopolitan C standard library and the Redbean platform announced the implementation of the pledge() isolation mechanism for Linux.

Originally developed by the OpenBSD project , pledge allows you to selectively prohibit applications from accessing unused system calls (creating a whitelist of system calls for the application and prohibiting other calls). Unlike syscall access control mechanisms available in Linux, such as seccomp, pledge is designed from the ground up to be as user-friendly as possible.

The failed initiative to isolate applications in the OpenBSD base environment using the systrace mechanism demonstrated that isolation at the level of individual system calls is too complicated and time consuming.

Alternatively, pledge was proposed, which allowed creating isolation rules without going into detail and manipulating prepared access classes.

For example, classes offered are stdio (input/output), rpath (read only files), wpath (write files), cpath (create files), tmppath (work with temporary files), inet (sockets network), unix (unix sockets), dns (DNS resolution), getpw (read access to user database), ioctl (ioctl call), proc (process control), exec (startup processes), and id (permission control).

The rules for working with system calls are specified in the form of annotations that include a list of allowed system call classes and an array of file paths where access is permitted. After compiling and running the modified application, the kernel takes over the task of monitoring compliance with the specified rules.

Separately, the pledge implementation for FreeBSD is being developed, which is distinguished by the ability to isolate applications without making changes to their code, while in OpenBSD the pledge call is aimed at tight integration with the base environment and the addition of annotations to the code of each one.

Pledge is like the forbidden fruit we all covet when the boss says we should use things like Linux. Why does that matter? It's because the pledge() actually makes security understandable. Linux has never really had a layer of security that mere mortals can understand.

The developers of the Linux pledge port followed FreeBSD's lead and, instead of making code changes, prepared an additional utility from pledge.com that allows you to apply restrictions without altering your application code. For example, to run the curl utility with access only to the system call classes stdio, rpath, inet, and threadstdio, simply run `./pledge.com -p 'stdio rpath inet thread' curl http://example.com`.

The utility works on all Linux distributions from RHEL6 onwards and does not require root access. Additionally, based on the cosmopolitan library, an API is provided for managing restrictions in C program code, allowing, among other things, the creation of enclaves to selectively restrict access to specific application functions.

There have been a few developers in the past that have tried this. I'm not going to name names, because most of these projects were never completed. When it comes to SECOMP, online tutorials only explain how to whitelist system calls, so most people lose interest before figuring out how to filter arguments. The projects that moved forward also had oversights like allowing setuid/setgid/sticky bits to be changed. Therefore, none of the current alternatives should be used. I think this effort brings us much closer to having pledge() than ever before.

Implementation requires no kernel changes: utility constraints are translated into SECCOMP BPF rules and processed using Linux's native system call isolation mechanism. For example, calling promise("stdio rpath", 0) will convert to a BPF filter

Finally, if you are interested in learning more, you can find the details at the following link.


Add as preferred source in Google