For FreeBSD, an implementation of an application isolation mechanism has been proposed, resembling the system calls plegde and unveil developed by the OpenBSD project. Isolation in plegde is achieved by prohibiting access to system calls not used by the application, while unveil selectively opens access only to specific file paths with which the application can work. A semblance of a whitelist of system calls and file paths is created for the application, while all other calls and paths are prohibited.
The difference between the developed FreeBSD analogue of plegde and unveil lies in providing an additional layer that allows isolating applications without changes to their code or with minimal changes. It should be noted that in OpenBSD, plegde and unveil are aimed at tight integration with the base environment and are applied by adding special annotations in the code of each application. To simplify the organization of protection, the filters allow avoiding detailing at the level of individual system calls and manipulating classes of system calls (input/output, file reading, file writing, sockets, ioctl, sysctl, process execution, etc.). The access restriction functions can be invoked in the application code as various actions are performed; for example, access to sockets and files can be closed after opening the necessary files and establishing a network connection.
The author of the plegde and unveil port for FreeBSD intends to provide the ability to isolate arbitrary applications, for which the utility curtain has been proposed, allowing the application of rules defined in a separate file. The proposed configuration includes a file with basic settings that define classes of system calls and typical file paths specific to certain applications (working with sound, network interaction, logging, etc.), as well as a file containing access rules for specific applications.
Værktøjet curtain kan anvendes til at isolere de fleste uændrede værktøjer, serverprocesser, grafiske applikationer og endda hele skrivebords-sessioner. Samarbejde mellem curtain og isolationsmekanismerne, der tilbydes af subsystems Jail og Capsicum, understøttes. Der er også mulighed for at organisere indlejret isolation, hvor de kørte applikationer arver de retningslinjer, der er udstedt til forældreapplikationen, og tilføjer separate begrænsninger. Nogle kerneoperationer (debugging-værktøjer, POSIX/SysV IPC, PTYs) beskyttes yderligere ved hjælp af barriere-mekanismer, der forhindrer adgang til kerneobjekter oprettet af en proces, der ikke er den nuværende eller den forældres proces.
Processen kan selv konfigurere sin egen isolation ved at kalde curtainctl eller ved at bruge funktionerne plegde() og unveil() fra biblioteket libcurtain, som svarer til lignende funktioner fra OpenBSD. For at overvåge blokeringer under applikationens drift er der blevet tilføjet sysctl 'security.curtain.log_level'. Adgang til X11- og Wayland-protokoller aktiveres separat ved at angive ved opstart af curtain mulighederne '-X'/'-Y' og '-W', men understøttelsen af grafiske applikationer er endnu ikke tilstrækkeligt stabiliseret og har en række uløste problemer (problemerne viser sig hovedsageligt ved brug af X11, mens understøttelsen af Wayland er implementeret betydeligt bedre). Brugere kan tilføje yderligere begrænsninger ved at oprette lokale filer med regler (~/.curtain.conf). For eksempel, for at tillade skrivning fra Firefox kun til mappen ~/Downloads/ kan man tilføje en sektion '[firefox]' med reglen '~/Downloads/ : rw+'.
Implementeringen inkluderer en kerne-modul mac_curtain til Mandatory Access Control (MAC), et sæt patches til FreeBSD-kernen med implementering af de nødvendige håndterings- og filterfunktioner, biblioteket libcurtain til brug af funktionerne plegde og unveil i applikationer, værktøjet curtain, eksempler på konfigurationsfiler, et sæt tests og patches til nogle programmer i brugerrummet (for eksempel til brug af $TMPDIR til at standardisere arbejdet med midlertidige filer). For så vidt muligt har forfatteren til hensigt at minimere antallet af ændringer, der kræver anvendelse af patches til kernen og applikationer.
Kilde: opennet.ru
