{"id":485416,"date":"2026-06-29T08:55:58","date_gmt":"2026-06-29T08:55:58","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=485416"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=485416","title":{"rendered":"Hajiz: rootless Linux\u2011sandbox \u043d\u0430\u00a0Rust\u00a0\u2014 namespaces, Landlock, seccomp\u2011BPF \u0438 eBPF\u2011\u0430\u0443\u0434\u0438\u0442 \u0431\u0435\u0437\u00a0sudo"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440.<\/p>\n<p>\u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u00a0\u043d\u0443\u043b\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f\u00a0\u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 Linux\u2011\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430\u00a0Rust\u00a0\u2014 <strong>Hajiz<\/strong>. \u042d\u0442\u043e \u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u00a0\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0440\u043e\u0441 \u0432\u043e\u00a0\u0447\u0442\u043e\u2011\u0442\u043e, \u0447\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0425\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u00a0\u043e\u043d \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u0438\u0437\u043d\u0443\u0442\u0440\u0438: \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u043d, \u043a\u0430\u043a\u00a0\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 eBPF\u2011\u0430\u0443\u0434\u0438\u0442 \u0441\u00a0privilege separation, \u0438 \u0437\u0430\u0447\u0435\u043c \u0432\u0441\u0451 \u044d\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u0435\u0441\u0442\u044c Docker.<\/p>\n<p>\u2192 <a href=\"https:\/\/github.com\/hag19\/hajiz\" rel=\"noopener noreferrer nofollow\">github.com\/hag19\/hajiz<\/a><\/p>\n<hr\/>\n<h3>\u0418\u0434\u0435\u044f \u0438 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h3>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430: \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0439 \u0431\u0438\u043d\u0430\u0440\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0435\u00a0\u043c\u043e\u0433 \u043d\u0430\u0432\u0440\u0435\u0434\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0411\u0435\u0437\u00a0\u0434\u0435\u043c\u043e\u043d\u0430, \u0431\u0435\u0437\u00a0setuid\u2011\u0445\u0435\u043b\u043f\u0435\u0440\u0430, \u0431\u0435\u0437\u00a0kernel\u2011\u043c\u043e\u0434\u0443\u043b\u044f, \u0431\u0435\u0437 <code>sudo<\/code> \u0434\u043b\u044f\u00a0\u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f.<\/p>\n<p>\u0414\u0443\u043c\u0430\u0439\u0442\u0435 \u043e\u00a0Hajiz \u043a\u0430\u043a\u00a0\u043e\u00a0\u043c\u043b\u0430\u0434\u0448\u0435\u043c \u0431\u0440\u0430\u0442\u0435 <code>bubblewrap<\/code> \u0438 <code>firejail<\/code>\u00a0\u2014 \u043c\u0435\u043d\u044c\u0448\u0435, \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0435\u0435, \u0441\u00a0\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0436\u0438\u043c\u043e\u043c \u0430\u0443\u0434\u0438\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0430\u043c \u0443\u0447\u0438\u0442\u0441\u044f \u0447\u0442\u043e\u00a0\u043d\u0443\u0436\u043d\u043e \u0431\u0438\u043d\u0430\u0440\u044e \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443.<\/p>\n<p><strong>\u041c\u043e\u0434\u0435\u043b\u044c \u0443\u0433\u0440\u043e\u0437:<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u0414\u043e\u0432\u0435\u0440\u044f\u0435\u043c:<\/strong> \u044f\u0434\u0440\u0443, \u0431\u0438\u043d\u0430\u0440\u044e hajiz, \u0444\u0430\u0439\u043b\u0430\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435\u00a0\u0434\u043e\u0432\u0435\u0440\u044f\u0435\u043c:<\/strong> \u0438\u0437\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u043c\u0443 \u0431\u0438\u043d\u0430\u0440\u044e \u0438 \u0432\u0441\u0435\u043c\u0443, \u0447\u0442\u043e\u00a0\u043e\u043d \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442.<\/p>\n<\/li>\n<li>\n<p><strong>\u0417\u0430\u0449\u0438\u0449\u0430\u0435\u043c \u043e\u0442:<\/strong> \u043f\u043e\u0431\u0435\u0433\u0430 \u0438\u0437\u00a0filesystem, \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u0430 \u0432\u00a0namespace, \u0443\u0442\u0435\u0447\u043a\u0438 \u0432\u00a0\u0441\u0435\u0442\u044c, \u0437\u043b\u043e\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f capabilities, syscall\u2011\u044d\u043a\u0441\u043f\u043b\u043e\u0439\u0442\u043e\u0432, privilege escalation \u0447\u0435\u0440\u0435\u0437 <code>exec()<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u043d\u0435 scope:<\/strong> side\u2011channel \u0430\u0442\u0430\u043a\u0438 (Spectre\/timing), kernel\u2011\u044d\u043a\u0441\u043f\u043b\u043e\u0439\u0442\u044b, \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0435 \u0430\u0442\u0430\u043a\u0438, \u0441\u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u0430\u043c hajiz.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h3>\u0427\u0442\u043e\u00a0\u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u00a0\u043a\u0430\u043f\u043e\u0442\u043e\u043c<\/h3>\n<p>Hajiz \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u044f\u0434\u0440\u0430 \u0432\u00a0\u043e\u0434\u043d\u0443 \u0441\u0432\u044f\u0437\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441\u00a0\u043c\u043e\u0434\u0435\u043b\u044c\u044e <strong>default\u2011deny<\/strong>\u00a0\u2014 \u0432\u0441\u0451 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e, \u0432\u044b \u044f\u0432\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e\u00a0\u043d\u0443\u0436\u043d\u043e.<\/p>\n<h4>1. Linux Namespaces<\/h4>\n<p>\u041f\u0440\u0438\u00a0\u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d:<\/p>\n<pre><code>unshare(CLONE_NEWUSER | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS | CLONE_NEWNET)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0438\u0448\u0435\u0442\u0441\u044f identity\u2011\u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0432 <code>\/proc\/self\/uid_map<\/code> \u0438 <code>\/proc\/self\/gid_map<\/code>\u00a0\u2014 UID \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441\u00a0UID \u0432\u043d\u0443\u0442\u0440\u0438, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439. \u0417\u0430\u0442\u0435\u043c \u043a\u043e\u0440\u0435\u043d\u044c \u043f\u0435\u0440\u0435\u043c\u043e\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a <code>MS_PRIVATE<\/code>, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f sandbox \u043d\u0435\u00a0\u0443\u0442\u0435\u043a\u0430\u043b\u0438 \u0432\u00a0\u0445\u043e\u0441\u0442.<\/p>\n<p><strong>\u0422\u0440\u0438 \u0440\u0435\u0436\u0438\u043c\u0430 \u0441\u0435\u0442\u0438:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0420\u0435\u0436\u0438\u043c<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>none<\/code> <em>(\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e)<\/em><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 netns \u0431\u0435\u0437\u00a0\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432\u00a0\u2014 \u043f\u043e\u043b\u043d\u044b\u0439 \u043e\u0444\u043b\u0430\u0439\u043d<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>loopback<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 netns \u0441 <code>lo<\/code> UP \u0438 <code>127.0.0.1\/8<\/code>\u00a0\u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>full<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0425\u043e\u0441\u0442\u043e\u0432\u0430\u044f \u0441\u0435\u0442\u044c; \u043d\u0430\u00a0kernel \u2265 6.7\u00a0\u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f Landlock port allowlists<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h4>2. Capabilities<\/h4>\n<p>\u0427\u0435\u0442\u044b\u0440\u0435 \u0448\u0430\u0433\u0430, \u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u0430\u0436\u0435\u043d:<\/p>\n<ol>\n<li>\n<p><code>PR_CAPBSET_DROP<\/code> \u0434\u043b\u044f\u00a0\u0432\u0441\u0435\u0433\u043e bounding set (\u043d\u0443\u0436\u0435\u043d <code>CAP_SETPCAP<\/code>\u00a0\u2014 \u043e\u043d \u0435\u0449\u0451 \u0435\u0441\u0442\u044c)<\/p>\n<\/li>\n<li>\n<p><code>PR_CAP_AMBIENT_CLEAR_ALL<\/code>\u00a0\u2014 \u0447\u0438\u0441\u0442\u0438\u043c ambient set<\/p>\n<\/li>\n<li>\n<p><code>capset(0, 0, 0)<\/code>\u00a0\u2014 \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u043c effective\/permitted\/inheritable<\/p>\n<\/li>\n<li>\n<p><code>prctl(PR_SET_NO_NEW_PRIVS)<\/code>\u00a0\u2014 \u0434\u0430\u0436\u0435 setuid\u2011\u0431\u0438\u043d\u0430\u0440\u044c \u043d\u0435\u00a0\u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438<\/p>\n<\/li>\n<\/ol>\n<h4>3. Landlock (filesystem + TCP\u2011\u043f\u043e\u0440\u0442\u044b)<\/h4>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441\u00a0Linux 5.13\u00a0\u2014 per\u2011path allowlists. \u0421 6.7\u00a0\u2014 \u0435\u0449\u0451 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 TCP\u2011\u043f\u043e\u0440\u0442\u043e\u0432. \u041d\u0430\u00a0\u0441\u0442\u0430\u0440\u044b\u0445 \u044f\u0434\u0440\u0430\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0441\u00a0\u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435\u043c.<\/p>\n<pre><code class=\"bash\"># read-only \/usr, writable \/tmphajiz --fs \/usr:ro --fs \/tmp:rw \/usr\/bin\/python3 script.py# \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0440\u0442\u044b 80 \u0438 443 \u043d\u0430\u0440\u0443\u0436\u0443hajiz --net full --allow-connect-port 443 --allow-connect-port 80 \\  \/usr\/bin\/curl https:\/\/example.com# \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043f\u043e\u0440\u0442\u043e\u0432hajiz --net full --allow-connect-port 8000-8100 \/usr\/bin\/myapp<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>4. seccomp\u2011BPF<\/h4>\n<p>\u0422\u0440\u0438 \u0440\u0435\u0436\u0438\u043c\u0430 \u043d\u0430\u00a0\u0432\u044b\u0431\u043e\u0440:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0424\u043b\u0430\u0433<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0420\u0435\u0436\u0438\u043c<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0427\u0442\u043e\u00a0\u0434\u0435\u043b\u0430\u0435\u0442<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><em>(\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e)<\/em><\/p>\n<\/td>\n<td>\n<p align=\"left\">Hardening\u2011deny<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u0432\u044b\u0441\u043e\u043a\u043e\u0440\u0438\u0441\u043a\u043e\u0432\u044b\u0435 syscall\u2011\u044b, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>--seccomp-whitelist<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">Allowlist<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u043e\u043b\u044c\u043a\u043e \u044f\u0432\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043d\u043d\u044b\u0435 syscall\u2011\u044b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>--strict-seccomp<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">Strict<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u043e\u043b\u044c\u043a\u043e <code>read<\/code>\/<code>write<\/code>\/<code>exit<\/code>\/<code>sigreturn<\/code><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u00a0hardening\u2011\u0440\u0435\u0436\u0438\u043c \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e: <code>unshare<\/code>, <code>setns<\/code>, <code>clone3<\/code>, <code>bpf<\/code>, <code>userfaultfd<\/code>, <code>add_key<\/code>, <code>request_key<\/code>, <code>keyctl<\/code>, <code>ptrace<\/code>, <code>process_vm_readv<\/code>, <code>process_vm_writev<\/code>.<\/p>\n<p>\u0412\u00a0allowlist\u2011\u0440\u0435\u0436\u0438\u043c\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u044b \u0438\u043b\u0438\u00a0\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 syscall\u2011\u044b:<\/p>\n<pre><code class=\"bash\">hajiz --seccomp-whitelist \\  --allow-group io --allow-group memory --allow-group process \\  --allow-syscall getrandom \\  \/usr\/bin\/myapp<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0433\u0440\u0443\u043f\u043f\u044b: <code>io<\/code>, <code>memory<\/code>, <code>threading<\/code>, <code>network<\/code>, <code>process<\/code>.<\/p>\n<h4>5. cgroups v2<\/h4>\n<p>\u041b\u0438\u043c\u0438\u0442\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0431\u0435\u0437\u00a0\u043b\u0438\u0448\u043d\u0438\u0445 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"bash\">hajiz --max-mem 512M --max-cpu 50 --max-pids 64 \/usr\/bin\/myapp<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 cgroups v2\u00a0\u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u00a0\u2014 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u0435\u043c \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0431\u0435\u0437\u00a0\u043b\u0438\u043c\u0438\u0442\u043e\u0432.<\/p>\n<hr\/>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432\u00a0\u2014 \u044d\u0442\u043e \u043d\u0435\u00a0\u0434\u0435\u0442\u0430\u043b\u044c<\/h3>\n<p>\u0421\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c: \u0448\u0430\u0433\u0438 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c. \u041a\u0430\u0436\u0434\u043e\u0435 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043b\u043e\u043c\u0430\u0435\u0442 \u0447\u0442\u043e\u2011\u0442\u043e \u043f\u043e\u2011\u0441\u0432\u043e\u0435\u043c\u0443.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 <code>hajiz &lt;binary&gt;<\/code>, \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0435\u043b\u0430\u0435\u0442 <code>fork()<\/code> \u0441\u00a0\u0445\u0443\u043a\u043e\u043c <code>pre_exec<\/code>. \u0425\u0443\u043a \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 <strong>\u043f\u043e\u0441\u043b\u0435 <\/strong><code><strong>fork()<\/strong><\/code><strong>, \u043d\u043e\u00a0\u0434\u043e <\/strong><code><strong>exec()<\/strong><\/code> \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d:<\/p>\n<pre><code>[parent: hajiz]                          [child: pre_exec, \u0434\u043e exec()]      \u2502                                         \u2502      \u251c\u2500 \u043f\u0430\u0440\u0441\u0438\u043c CLI                             \u2502  1. Namespaces      \u251c\u2500 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u044c                      \u2502     unshare(NEWUSER|NEWNS|NEWIPC|NEWUTS|NEWNET)      \u251c\u2500 \u0441\u0442\u0440\u043e\u0438\u043c IsolationConfig                 \u2502     \u043f\u0438\u0448\u0435\u043c uid\/gid_map      \u251c\u2500 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c cgroups \u043a \u0441\u0435\u0431\u0435               \u2502     remount \/ \u043a\u0430\u043a MS_PRIVATE      \u251c\u2500 spawn child \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba  \u2502      \u251c\u2500 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u044b \u0442\u0435\u043b\u0435\u043c\u0435\u0442\u0440\u0438\u0438          \u2502  2. Capabilities      \u251c\u2500 \u0436\u0434\u0451\u043c child                             \u2502     PR_CAPBSET_DROP (0..40)      \u2514\u2500 \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435: \u043b\u043e\u0433, cleanup cgroups       \u2502     PR_CAP_AMBIENT_CLEAR_ALL                                                \u2502     capset(0)                                                \u2502     PR_SET_NO_NEW_PRIVS                                                \u2502                                                \u2502  3. Landlock                                                \u2502     path rules + TCP port rules                                                \u2502                                                \u2502  4. seccomp-BPF                                                \u2502     \u0444\u0438\u043b\u044c\u0442\u0440 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c                                                \u2502                                                \u2502  5. exec(binary, args)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u043e\u0442 \u0447\u0442\u043e\u00a0\u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u00a0\u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0438 \u043f\u043e\u0440\u044f\u0434\u043a\u0430:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u043e\u0447\u0435\u043c\u0443 \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>capset(0)<\/code> \u0434\u043e <code>PR_CAPBSET_DROP<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>capset(0)<\/code> \u0443\u0431\u0438\u0440\u0430\u0435\u0442 <code>CAP_SETPCAP<\/code> \u2192 \u0434\u0440\u043e\u043f bounding set \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u0441\u00a0EPERM<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0414\u0440\u043e\u043f capabilities \u0434\u043e\u00a0user namespace<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0423\u00a0\u043d\u0435\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435\u0442 capabilities \u0434\u043b\u044f\u00a0\u0434\u0440\u043e\u043f\u0430\u00a0\u2014 \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043e\u0439\u0442\u0438 \u0432\u00a0user\u2011ns<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">seccomp \u0434\u043e\u00a0Landlock<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 Landlock \u0442\u0440\u0435\u0431\u0443\u0435\u0442 <code>landlock_create_ruleset<\/code>\u00a0\u2014 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u0440\u043e\u0433\u0438\u0439 seccomp \u0443\u0436\u0435 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Remount <code>\/<\/code> \u0434\u043e\u00a0user namespace<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>mount(MS_PRIVATE)<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442 <code>CAP_SYS_ADMIN<\/code>, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u043d\u0435\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u044e\u0437\u0435\u0440\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 user\u2011ns<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u042d\u0442\u043e \u043d\u0435\u00a0\u0442\u0435\u043e\u0440\u0438\u044f\u00a0\u2014 \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437\u00a0\u044d\u0442\u0438\u0445 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0439 \u043d\u0430\u00a0\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u044f\u0434\u0440\u0435 \u0434\u0430\u0451\u0442\u00a0\u043b\u0438\u0431\u043e <code>EPERM<\/code>,\u00a0\u043b\u0438\u0431\u043e \u0442\u0438\u0445\u043e\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0437\u0430\u0449\u0438\u0442\u044b.<\/p>\n<hr\/>\n<h3>Audit\u2011\u0440\u0435\u0436\u0438\u043c: \u043a\u0430\u043a\u00a0\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0443\u0447\u0438\u0442\u0441\u044f, \u0447\u0442\u043e\u00a0\u043d\u0443\u0436\u043d\u043e \u0431\u0438\u043d\u0430\u0440\u044e<\/h3>\n<p>\u042d\u0442\u043e \u043c\u043e\u044f \u043b\u044e\u0431\u0438\u043c\u0430\u044f \u0447\u0430\u0441\u0442\u044c. \u0418\u0434\u0435\u044f: \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u044c \u0431\u0435\u0437\u00a0\u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0447\u0442\u043e\u00a0\u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442, \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c TOML\u2011\u043f\u0440\u043e\u0444\u0438\u043b\u044c \u0441\u00a0\u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<pre><code class=\"bash\"># \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u044c \u0432 stdouthajiz --audit \/usr\/bin\/curl https:\/\/example.com# \u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043bhajiz --audit --audit-output curl.toml \/usr\/bin\/curl https:\/\/example.com# \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0444\u0438\u043b\u044chajiz --profile curl.toml \/usr\/bin\/curl https:\/\/example.com<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u0432\u0430 \u0431\u044d\u043a\u0435\u043d\u0434\u0430, \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438:<\/p>\n<ul>\n<li>\n<p><strong>eBPF<\/strong>\u00a0\u2014 \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043e \u043e\u0442\u00a0root \u0438\u043b\u0438\u00a0\u0441 <code>CAP_BPF<\/code>. \u0422\u0440\u0435\u0439\u0441\u0438\u0442 syscall\u2011\u044b \u0447\u0435\u0440\u0435\u0437 <code>raw_tracepoint\/sys_enter<\/code>. \u041d\u0438\u0437\u043a\u0438\u0439 overhead, \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u043d\u0430 syscall\u2011\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>strace<\/strong>\u00a0\u2014 \u043d\u0435\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 fallback. \u041c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u043d\u043e\u00a0\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0443\u0442\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0430\u0434\u0440\u0435\u0441\u0430.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: eBPF \u0442\u0440\u0435\u0431\u0443\u0435\u0442 CAP_BPF, \u043d\u043e\u00a0\u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0431\u0438\u043d\u0430\u0440\u044c \u043d\u0435\u00a0\u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e<\/h4>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435\u00a0\u2014 <strong>broker\/sandbox split<\/strong>. \u0422\u043e\u0442\u00a0\u0436\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u0447\u0442\u043e\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Chrome, firejail, bwrap.<\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442: \u044f\u0434\u0440\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 <code>CAP_BPF<\/code> \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u00a0\u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f BPF\u2011\u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e fd\u00a0\u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code>SCM_RIGHTS<\/code> \u043b\u044e\u0431\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443, \u0432\u00a0\u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043d\u0435\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443.<\/p>\n<p><strong>\u041a\u0430\u043a\u00a0\u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/strong><\/p>\n<pre><code>sudo hajiz --audit \/usr\/bin\/curl ...       \u2502       \u25bc\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\u2502  hajiz \u043f\u0440\u043e\u0446\u0435\u0441\u0441 (root \/ CAP_BPF)                                          \u2502\u2502                                                                          \u2502\u2502  socketpair(AF_UNIX, SOCK_STREAM)                                        \u2502\u2502  fork()                                                                  \u2502\u2502      \u2502                                       \u2502                           \u2502\u2502  BROKER (parent)                         SANDBOX (child)                 \u2502\u2502      \u2502                                       \u2502                           \u2502\u2502  \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 BPF-\u043e\u0431\u044a\u0435\u043a\u0442                    \u2605 \u041f\u0415\u0420\u0412\u0410\u042f \u0418\u041d\u0421\u0422\u0420\u0423\u041a\u0426\u0418\u042f:            \u2502\u2502  aya::Ebpf::load(audit_syscalls.o)         drop_all_capabilities()       \u2502\u2502  attach(\"sys_enter\")                       (capset(0) + bounding set +   \u2502\u2502  \u2190 \u044f\u0434\u0440\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 CAP_BPF \u0437\u0434\u0435\u0441\u044c             ambient clear + no_new_privs)\u2502\u2502                                             \u2502                            \u2502\u2502  \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 fd: config_map, syscall_map       recv_fds()                   \u2502\u2502  send_fds() \u2500\u2500\u2500\u2500 SCM_RIGHTS \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba (\u0443\u0436\u0435 \u0431\u0435\u0437 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439)         \u2502\u2502                                             \u2502                            \u2502\u2502  drop_all_capabilities()                    \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 target PID        \u2502\u2502  \u2605 broker \u0442\u043e\u0436\u0435 \u0431\u0435\u0437 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439               \u0432 config_map                 \u2502\u2502  BPF \u0436\u0438\u0432 \u2014 \u0434\u0435\u0440\u0436\u0438\u043c fd                        \u2502                            \u2502\u2502                                             spawn(binary)                \u2502\u2502                                             \u2502                            \u2502\u2502                                             \u044f\u0434\u0440\u043e: raw_tracepoint \u0441\u0440\u0430\u0431\u0430\u0442. \u2502\u2502                                             per syscall, \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442 \u043f\u043e PID\u2502\u2502                                             \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 syscall_map   \u2502\u2502                                             \u2502                            \u2502\u2502                                             \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043e\u0442\u0447\u0451\u0442            \u2502\u2502  read() \u25c4\u2500\u2500\u2500 socket \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u043f\u0438\u0448\u0435\u0442 \u0432 socket               \u2502\u2502  \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u043e\u0444\u0438\u043b\u044c                         exit                         \u2502\u2502  \u043f\u0438\u0448\u0435\u0442 curl.toml                                                         \u2502\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><strong>\u041e\u043a\u043d\u0430 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041f\u0440\u043e\u0446\u0435\u0441\u0441<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043e\u043a\u043d\u043e<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0427\u0442\u043e\u00a0\u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Broker<\/p>\n<\/td>\n<td>\n<p align=\"left\">start \u2192 <code>drop_all_capabilities()<\/code> \u043f\u043e\u0441\u043b\u0435 <code>send_fds()<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">BPF load + attach + sendmsg. \u041c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Sandbox<\/p>\n<\/td>\n<td>\n<p align=\"left\">fork() \u2192 \u043f\u0435\u0440\u0432\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0432\u00a0userspace<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0420\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d syscall return. \u041f\u0435\u0440\u0432\u043e\u0435 \u0447\u0442\u043e\u00a0\u0434\u0435\u043b\u0430\u0435\u0442\u00a0\u2014 <code>drop_all_capabilities()<\/code>.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0426\u0435\u043b\u0435\u0432\u043e\u0439 \u0431\u0438\u043d\u0430\u0440\u044c \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u00a0\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u00a0\u043f\u043e\u0432\u044b\u0448\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438\u00a0\u2014 \u043d\u0438 \u043d\u0430\u00a0\u043e\u0434\u043d\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e.<\/p>\n<h4>BPF\u2011\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430<\/h4>\n<p>\u041d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u0430. \u0414\u0432\u0430 map\u2011\u0430: <code>config_map<\/code> (\u0434\u0435\u0440\u0436\u0438\u0442 target TGID), <code>syscall_map<\/code> (\u0445\u044d\u0448 syscall_nr \u2192 count). \u041e\u0434\u043d\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430:<\/p>\n<pre><code>SEC(\"raw_tracepoint\/sys_enter\")int audit_syscalls(struct bpf_raw_tracepoint_args *ctx) {    u32 tgid = bpf_get_current_pid_tgid() &gt;&gt; 32;        u32 *filter_pid = bpf_map_lookup_elem(&amp;config_map, &amp;zero);    if (!filter_pid || *filter_pid == 0 || *filter_pid != tgid)        return 0;        long syscall_id = ctx-&gt;args[1];    u64 *count = bpf_map_lookup_elem(&amp;syscall_map, &amp;syscall_id);    if (count)        __sync_fetch_and_add(count, 1);    return 0;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u044f\u0434\u0440\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0446\u0438\u043a\u043b\u043e\u0432, \u0432\u044b\u0445\u043e\u0434\u043e\u0432 \u0437\u0430\u00a0\u0433\u0440\u0430\u043d\u0438\u0446\u044b, \u043d\u0435\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0447\u0442\u0435\u043d\u0438\u0439. \u042d\u0442\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438\u00a0\u2014 \u043d\u0435\u00a0\u044f\u0437\u044b\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<hr\/>\n<h3>\u0422\u0435\u043b\u0435\u043c\u0435\u0442\u0440\u0438\u044f<\/h3>\n<p>Hajiz \u044d\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 JSON\u2011\u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0430\u00a0\u043a\u0430\u0436\u0434\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0431\u00a0\u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438:<\/p>\n<pre><code class=\"bash\">hajiz -v --log run.json --fs \/usr:ro \/usr\/bin\/myapp<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0421\u043e\u0431\u044b\u0442\u0438\u0435<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041a\u043e\u0433\u0434\u0430<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>sandbox_started<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>policy_applied<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c\u00a0\u2014 \u0441\u043f\u0438\u0441\u043e\u043a blocked syscalls, allowed paths<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>syscall_denied<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043f\u0440\u0438\u00a0\u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c syscall<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>filesystem_denied<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 Landlock\u2011\u043e\u0442\u043a\u0430\u0437\u0430 (kernel \u2265 5.5)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>network_denied<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 Landlock TCP\u2011\u043e\u0442\u043a\u0430\u0437\u0430 (kernel \u2265 5.5)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>resource_usage<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043a\u0430\u0436\u0434\u044b\u0435 N \u0441\u0435\u043a\u0443\u043d\u0434\u00a0\u2014 mem, pids, cpu_usec<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>sandbox_exited<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043f\u0440\u0438\u00a0\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041d\u0430\u00a0kernel \u2265 5.0\u00a0<code>syscall_denied<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 <strong>seccomp user notification<\/strong>: \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 syscall \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432\u00a0supervisor\u2011\u043f\u043e\u0442\u043e\u043a \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 <code>-EPERM<\/code>. \u0411\u0435\u0437\u00a0\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439, \u0431\u0435\u0437 <code>kernel.dmesg_restrict<\/code>.<\/p>\n<p><code>filesystem_denied<\/code> \u0438 <code>network_denied<\/code>\u00a0\u2014 \u044d\u0442\u043e <strong>\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f<\/strong>, \u0430\u00a0\u043d\u0435\u00a0\u0432\u0435\u0440\u0434\u0438\u043a\u0442 \u044f\u0434\u0440\u0430. Supervisor \u0447\u0438\u0442\u0430\u0435\u0442 \u043f\u0443\u0442\u044c \u0438\u043b\u0438\u00a0sockaddr \u0438\u0437 <code>\/proc\/&lt;pid&gt;\/mem<\/code>, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u0440\u043e\u0442\u0438\u0432 \u043f\u0440\u0430\u0432\u0438\u043b \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 <code>SECCOMP_USER_NOTIF_FLAG_CONTINUE<\/code>. \u0420\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0437\u0430\u00a0Landlock.<\/p>\n<hr\/>\n<h3>\u041f\u0440\u043e\u0444\u0438\u043b\u0438<\/h3>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u0444\u043b\u0430\u0433\u043e\u0432\u00a0\u2014 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 TOML\u2011\u0444\u0430\u0439\u043b\u044b:<\/p>\n<pre><code>name = \"untrusted\"description = \"Minimal profile for untrusted files\"[network]mode = \"none\"allow_connect = []allow_bind    = [][filesystem]read_only  = [\"\/usr\", \"\/lib\", \"\/lib64\", \"\/bin\"]read_write = [\"\/tmp\"][seccomp]hardening     = truewhitelist     = falsestrict        = falseallow_groups   = []allow_syscalls = []<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u00a0\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043b\u0435\u0436\u0430\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u0438: <code>untrusted<\/code>, <code>firefox<\/code>, <code>document-viewer<\/code>, <code>media-player<\/code>, <code>office<\/code>.<\/p>\n<pre><code class=\"bash\">hajiz --profile profiles\/firefox.toml \/usr\/bin\/firefox<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<hr\/>\n<h3>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h3>\n<p>\u041d\u0443\u0436\u043d\u044b Rust toolchain \u0438 <code>libseccomp<\/code>. <code>clang<\/code> \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u0435\u043d\u00a0\u2014 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c, \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f eBPF\u2011\u0431\u044d\u043a\u0435\u043d\u0434 \u0430\u0443\u0434\u0438\u0442\u0430; \u0438\u043d\u0430\u0447\u0435 fallback \u043d\u0430\u00a0strace.<\/p>\n<pre><code class=\"bash\">cargo build --releasesudo install -m 755 target\/release\/hajiz \/usr\/local\/bin\/hajiz<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><strong>Ubuntu 23.10+ \/ 24.04\u00a0LTS:<\/strong> <code>kernel.apparmor_restrict_unprivileged_userns<\/code> \u0432\u043a\u043b\u044e\u0447\u0451\u043d \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 <code>unshare(CLONE_NEWUSER)<\/code> \u0431\u0435\u0437\u00a0\u044f\u0432\u043d\u043e\u0433\u043e AppArmor\u2011\u043f\u0440\u043e\u0444\u0438\u043b\u044f. Hajiz \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u044d\u0442\u043e \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443. \u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"bash\">sudo cp packaging\/apparmor\/hajiz \/etc\/apparmor.d\/hajizsudo systemctl reload apparmor<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0430\u00a0Debian, Arch, Fedora, RHEL \u0438 Ubuntu \u2264 23.04\u00a0\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043d\u0435\u00a0\u043d\u0443\u0436\u043d\u0430.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0447\u0442\u043e\u00a0\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0430\u0448\u0435 \u044f\u0434\u0440\u043e:<\/p>\n<pre><code class=\"bash\">hajiz --kernel-info<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<hr\/>\n<h3>\u0418\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f<\/h3>\n<ul>\n<li>\n<p><code><strong>filesystem_denied<\/strong><\/code><strong> \u0438 <\/strong><code><strong>network_denied<\/strong><\/code><strong>\u00a0\u2014 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f.<\/strong> Supervisor \u043d\u0435\u00a0\u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 symlink\u2011\u044b \u0442\u0430\u043a, \u043a\u0430\u043a\u00a0\u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 Landlock. Enforcement \u0432\u0441\u0435\u0433\u0434\u0430 \u0437\u0430\u00a0\u044f\u0434\u0440\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435\u0442 <\/strong><code><strong>CLONE_NEWPID<\/strong><\/code><strong>.<\/strong> <code>unshare(NEWPID)<\/code> \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0434\u0435\u0442\u0435\u0439, \u043d\u0435\u00a0\u0441\u0430\u043c exec\u2019d \u0431\u0438\u043d\u0430\u0440\u044c. \u0422\u0440\u0435\u0431\u0443\u0435\u0442 double\u2011fork + remount <code>\/proc<\/code>\u00a0\u2014 \u0432\u00a0\u043f\u043b\u0430\u043d\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p><strong>eBPF audit: \u0442\u043e\u043b\u044c\u043a\u043e syscall\u2011\u044b<\/strong>, \u0431\u0435\u0437\u00a0\u043f\u0443\u0442\u0435\u0439 \u0438 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432. strace\u2011\u0431\u044d\u043a\u0435\u043d\u0434 \u044d\u0442\u043e \u0443\u043c\u0435\u0435\u0442. \u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430\u00a0ringbuf\u00a0\u2014 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433.<\/p>\n<\/li>\n<li>\n<p><strong>cgroups v2.<\/strong>\u00a0\u041b\u0438\u043c\u0438\u0442\u044b \u043d\u0435\u00a0\u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 cgroups v2\u00a0\u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b. \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0435\u0441\u0442\u044c, \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043d\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p><code><strong>full<\/strong><\/code><strong> network \u0431\u0435\u0437\u00a0kernel \u2265 6.7<\/strong> \u0434\u0430\u0451\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u00a0\u0441\u0435\u0442\u0438 \u0431\u0435\u0437\u00a0port allowlists. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>none<\/code>\/<code>loopback<\/code> \u0434\u043b\u044f\u00a0\u0436\u0451\u0441\u0442\u043a\u043e\u0439 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h3>\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u0442\u0430\u0440\u0442<\/h3>\n<pre><code class=\"bash\"># \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e: \u043e\u0444\u043b\u0430\u0439\u043d, hardened seccomp, \u0434\u0440\u043e\u043f capshajiz \/usr\/bin\/echo hello# read-only \/usr, writable \/tmphajiz --fs \/usr:ro --fs \/tmp:rw \/usr\/bin\/python3 script.py# \u0442\u043e\u043b\u044c\u043a\u043e loopbackhajiz --net loopback \/usr\/bin\/python3 -m http.server 8000# \u043b\u0438\u043c\u0438\u0442\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432hajiz --max-mem 512M --max-cpu 50 --max-pids 64 \/usr\/bin\/myapp# audit \u2192 \u043f\u0440\u043e\u0444\u0438\u043b\u044c \u2192 \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u043e\u0434 \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u043chajiz --audit --audit-output curl.toml \/usr\/bin\/curl https:\/\/example.comhajiz --profile curl.toml \/usr\/bin\/curl https:\/\/example.com# \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0447\u0442\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u044f\u0434\u0440\u043ehajiz --kernel-info<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<hr\/>\n<h3>\u0418\u0442\u043e\u0433<\/h3>\n<p>\u041f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0441\u044f \u043a\u0430\u043a\u00a0\u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u0439 dive \u0432\u00a0\u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 Linux\u2011\u044f\u0434\u0440\u0430. \u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e\u00a0\u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435\u00a0\u2014 \u043d\u0435\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u043e\u00a0\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430\u00a0\u0442\u043e, \u043a\u0430\u043a\u00a0\u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u043d\u0430\u00a0\u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u044f\u0434\u0440\u0430. \u0418 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u00a0\u2014 \u043a\u0430\u043a\u00a0\u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c privilege separation \u0432\u00a0audit\u2011\u0440\u0435\u0436\u0438\u043c\u0435 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0431\u0438\u043d\u0430\u0440\u044c \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u00a0\u043f\u043e\u043b\u0443\u0447\u0430\u043b CAP_BPF \u0434\u0430\u0436\u0435 \u043d\u0430\u00a0\u043e\u0434\u043d\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e.<\/p>\n<p>\u0411\u0443\u0434\u0443 \u0440\u0430\u0434 \u0444\u0438\u0434\u0431\u0435\u043a\u0443 \u043f\u043e\u00a0\u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438, \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c \u0438 PR.<\/p>\n<p>\u2192 <a href=\"https:\/\/github.com\/hag19\/hajiz\" rel=\"noopener noreferrer nofollow\">github.com\/hag19\/hajiz<\/a> |\u00a0\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u044f: MIT \/ Apache-2.0<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1053220\/\">https:\/\/habr.com\/ru\/articles\/1053220\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440.\u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u00a0\u043d\u0443\u043b\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f\u00a0\u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 Linux\u2011\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430\u00a0Rust\u00a0\u2014 Hajiz. \u042d\u0442\u043e \u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u00a0\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0440\u043e\u0441 \u0432\u043e\u00a0\u0447\u0442\u043e\u2011\u0442\u043e, \u0447\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0425\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u00a0\u043e\u043d \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u0438\u0437\u043d\u0443\u0442\u0440\u0438: \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u043d, \u043a\u0430\u043a\u00a0\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 eBPF\u2011\u0430\u0443\u0434\u0438\u0442 \u0441\u00a0privilege separation, \u0438 \u0437\u0430\u0447\u0435\u043c \u0432\u0441\u0451 \u044d\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u0435\u0441\u0442\u044c Docker.\u2192 github.com\/hag19\/hajiz\u0418\u0434\u0435\u044f \u0438 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438\u0417\u0430\u0434\u0430\u0447\u0430: \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0439 \u0431\u0438\u043d\u0430\u0440\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0435\u00a0\u043c\u043e\u0433 \u043d\u0430\u0432\u0440\u0435\u0434\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0411\u0435\u0437\u00a0\u0434\u0435\u043c\u043e\u043d\u0430, \u0431\u0435\u0437\u00a0setuid\u2011\u0445\u0435\u043b\u043f\u0435\u0440\u0430, \u0431\u0435\u0437\u00a0kernel\u2011\u043c\u043e\u0434\u0443\u043b\u044f, \u0431\u0435\u0437 sudo \u0434\u043b\u044f\u00a0\u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f.\u0414\u0443\u043c\u0430\u0439\u0442\u0435 \u043e\u00a0Hajiz \u043a\u0430\u043a\u00a0\u043e\u00a0\u043c\u043b\u0430\u0434\u0448\u0435\u043c \u0431\u0440\u0430\u0442\u0435 bubblewrap \u0438 firejail\u00a0\u2014 \u043c\u0435\u043d\u044c\u0448\u0435, \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0435\u0435, \u0441\u00a0\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0436\u0438\u043c\u043e\u043c \u0430\u0443\u0434\u0438\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0430\u043c \u0443\u0447\u0438\u0442\u0441\u044f \u0447\u0442\u043e\u00a0\u043d\u0443\u0436\u043d\u043e \u0431\u0438\u043d\u0430\u0440\u044e \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443.\u041c\u043e\u0434\u0435\u043b\u044c \u0443\u0433\u0440\u043e\u0437:\u0414\u043e\u0432\u0435\u0440\u044f\u0435\u043c: \u044f\u0434\u0440\u0443, \u0431\u0438\u043d\u0430\u0440\u044e hajiz, \u0444\u0430\u0439\u043b\u0430\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u0439.\u041d\u0435\u00a0\u0434\u043e\u0432\u0435\u0440\u044f\u0435\u043c: \u0438\u0437\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u043c\u0443 \u0431\u0438\u043d\u0430\u0440\u044e \u0438 \u0432\u0441\u0435\u043c\u0443, \u0447\u0442\u043e\u00a0\u043e\u043d \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442.\u0417\u0430\u0449\u0438\u0449\u0430\u0435\u043c \u043e\u0442: \u043f\u043e\u0431\u0435\u0433\u0430 \u0438\u0437\u00a0filesystem, \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u0430 \u0432\u00a0namespace, \u0443\u0442\u0435\u0447\u043a\u0438 \u0432\u00a0\u0441\u0435\u0442\u044c, \u0437\u043b\u043e\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f capabilities, syscall\u2011\u044d\u043a\u0441\u043f\u043b\u043e\u0439\u0442\u043e\u0432, privilege escalation \u0447\u0435\u0440\u0435\u0437 exec().\u0412\u043d\u0435 scope: side\u2011channel \u0430\u0442\u0430\u043a\u0438 (Spectre\/timing), kernel\u2011\u044d\u043a\u0441\u043f\u043b\u043e\u0439\u0442\u044b, \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0435 \u0430\u0442\u0430\u043a\u0438, \u0441\u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u0430\u043c hajiz.\u0427\u0442\u043e\u00a0\u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u00a0\u043a\u0430\u043f\u043e\u0442\u043e\u043cHajiz \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u044f\u0434\u0440\u0430 \u0432\u00a0\u043e\u0434\u043d\u0443 \u0441\u0432\u044f\u0437\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441\u00a0\u043c\u043e\u0434\u0435\u043b\u044c\u044e default\u2011deny\u00a0\u2014 \u0432\u0441\u0451 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e, \u0432\u044b \u044f\u0432\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e\u00a0\u043d\u0443\u0436\u043d\u043e.1. Linux Namespaces\u041f\u0440\u0438\u00a0\u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d:unshare(CLONE_NEWUSER | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS | CLONE_NEWNET)\u041f\u0438\u0448\u0435\u0442\u0441\u044f identity\u2011\u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0432 \/proc\/self\/uid_map \u0438 \/proc\/self\/gid_map\u00a0\u2014 UID \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441\u00a0UID \u0432\u043d\u0443\u0442\u0440\u0438, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439. \u0417\u0430\u0442\u0435\u043c \u043a\u043e\u0440\u0435\u043d\u044c \u043f\u0435\u0440\u0435\u043c\u043e\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a MS_PRIVATE, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f sandbox \u043d\u0435\u00a0\u0443\u0442\u0435\u043a\u0430\u043b\u0438 \u0432\u00a0\u0445\u043e\u0441\u0442.\u0422\u0440\u0438 \u0440\u0435\u0436\u0438\u043c\u0430 \u0441\u0435\u0442\u0438:\u0420\u0435\u0436\u0438\u043c\u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435none (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e)\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 netns \u0431\u0435\u0437\u00a0\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432\u00a0\u2014 \u043f\u043e\u043b\u043d\u044b\u0439 \u043e\u0444\u043b\u0430\u0439\u043dloopback\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 netns \u0441 lo UP \u0438 127.0.0.1\/8\u00a0\u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044bfull\u0425\u043e\u0441\u0442\u043e\u0432\u0430\u044f \u0441\u0435\u0442\u044c; \u043d\u0430\u00a0kernel \u2265 6.7\u00a0\u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f Landlock port allowlists2. Capabilities\u0427\u0435\u0442\u044b\u0440\u0435 \u0448\u0430\u0433\u0430, \u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u0430\u0436\u0435\u043d:PR_CAPBSET_DROP \u0434\u043b\u044f\u00a0\u0432\u0441\u0435\u0433\u043e bounding set (\u043d\u0443\u0436\u0435\u043d CAP_SETPCAP\u00a0\u2014 \u043e\u043d \u0435\u0449\u0451 \u0435\u0441\u0442\u044c)PR_CAP_AMBIENT_CLEAR_ALL\u00a0\u2014 \u0447\u0438\u0441\u0442\u0438\u043c ambient setcapset(0, 0, 0)\u00a0\u2014 \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u043c effective\/permitted\/inheritableprctl(PR_SET_NO_NEW_PRIVS)\u00a0\u2014 \u0434\u0430\u0436\u0435 setuid\u2011\u0431\u0438\u043d\u0430\u0440\u044c \u043d\u0435\u00a0\u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u04383. Landlock (filesystem + TCP\u2011\u043f\u043e\u0440\u0442\u044b)\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441\u00a0Linux 5.13\u00a0\u2014 per\u2011path allowlists. \u0421 6.7\u00a0\u2014 \u0435\u0449\u0451 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 TCP\u2011\u043f\u043e\u0440\u0442\u043e\u0432. \u041d\u0430\u00a0\u0441\u0442\u0430\u0440\u044b\u0445 \u044f\u0434\u0440\u0430\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0441\u00a0\u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435\u043c.# read-only \/usr, writable \/tmphajiz &#8212;fs \/usr:ro &#8212;fs \/tmp:rw \/usr\/bin\/python3 script.py# \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0440\u0442\u044b 80 \u0438 443 \u043d\u0430\u0440\u0443\u0436\u0443hajiz &#8212;net full &#8212;allow-connect-port 443 &#8212;allow-connect-port 80 \\  \/usr\/bin\/curl https:\/\/example.com# \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043f\u043e\u0440\u0442\u043e\u0432hajiz &#8212;net full &#8212;allow-connect-port 8000-8100 \/usr\/bin\/myapp4. seccomp\u2011BPF\u0422\u0440\u0438 \u0440\u0435\u0436\u0438\u043c\u0430 \u043d\u0430\u00a0\u0432\u044b\u0431\u043e\u0440:\u0424\u043b\u0430\u0433\u0420\u0435\u0436\u0438\u043c\u0427\u0442\u043e\u00a0\u0434\u0435\u043b\u0430\u0435\u0442(\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e)Hardening\u2011deny\u0411\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u0432\u044b\u0441\u043e\u043a\u043e\u0440\u0438\u0441\u043a\u043e\u0432\u044b\u0435 syscall\u2011\u044b, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e&#8212;seccomp-whitelistAllowlist\u0422\u043e\u043b\u044c\u043a\u043e \u044f\u0432\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043d\u043d\u044b\u0435 syscall\u2011\u044b&#8212;strict-seccompStrict\u0422\u043e\u043b\u044c\u043a\u043e read\/write\/exit\/sigreturn\u0421\u043f\u0438\u0441\u043e\u043a \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u00a0hardening\u2011\u0440\u0435\u0436\u0438\u043c \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e: unshare, setns, clone3, bpf, userfaultfd, add_key, request_key, keyctl, ptrace, process_vm_readv, process_vm_writev.\u0412\u00a0allowlist\u2011\u0440\u0435\u0436\u0438\u043c\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u044b \u0438\u043b\u0438\u00a0\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 syscall\u2011\u044b:hajiz &#8212;seccomp-whitelist \\  &#8212;allow-group io &#8212;allow-group memory &#8212;allow-group process \\  &#8212;allow-syscall getrandom \\  \/usr\/bin\/myapp\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0433\u0440\u0443\u043f\u043f\u044b: io, memory, threading, network, process.5. cgroups v2\u041b\u0438\u043c\u0438\u0442\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0431\u0435\u0437\u00a0\u043b\u0438\u0448\u043d\u0438\u0445 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439:hajiz &#8212;max-mem 512M &#8212;max-cpu 50 &#8212;max-pids 64 \/usr\/bin\/myapp\u0415\u0441\u043b\u0438 cgroups v2\u00a0\u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u00a0\u2014 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u0435\u043c \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0431\u0435\u0437\u00a0\u043b\u0438\u043c\u0438\u0442\u043e\u0432.\u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432\u00a0\u2014 \u044d\u0442\u043e \u043d\u0435\u00a0\u0434\u0435\u0442\u0430\u043b\u044c\u0421\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c: \u0448\u0430\u0433\u0438 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c. \u041a\u0430\u0436\u0434\u043e\u0435 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043b\u043e\u043c\u0430\u0435\u0442 \u0447\u0442\u043e\u2011\u0442\u043e \u043f\u043e\u2011\u0441\u0432\u043e\u0435\u043c\u0443.\u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 hajiz &lt;binary&gt;, \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0435\u043b\u0430\u0435\u0442 fork() \u0441\u00a0\u0445\u0443\u043a\u043e\u043c pre_exec. \u0425\u0443\u043a \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 fork(), \u043d\u043e\u00a0\u0434\u043e exec() \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d:[parent: hajiz]                          [child: pre_exec, \u0434\u043e exec()]      \u2502                                         \u2502      \u251c\u2500 \u043f\u0430\u0440\u0441\u0438\u043c CLI                             \u2502  1. Namespaces      \u251c\u2500 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u044c                      \u2502     unshare(NEWUSER|NEWNS|NEWIPC|NEWUTS|NEWNET)      \u251c\u2500 \u0441\u0442\u0440\u043e\u0438\u043c IsolationConfig                 \u2502     \u043f\u0438\u0448\u0435\u043c uid\/gid_map      \u251c\u2500 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c cgroups \u043a \u0441\u0435\u0431\u0435               \u2502     remount \/ \u043a\u0430\u043a MS_PRIVATE      \u251c\u2500 spawn child \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba  \u2502      \u251c\u2500 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u044b \u0442\u0435\u043b\u0435\u043c\u0435\u0442\u0440\u0438\u0438          \u2502  2. Capabilities      \u251c\u2500 \u0436\u0434\u0451\u043c child                             \u2502     PR_CAPBSET_DROP (0..40)      \u2514\u2500 \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435: \u043b\u043e\u0433, cleanup cgroups       \u2502     PR_CAP_AMBIENT_CLEAR_ALL                                                \u2502     capset(0)                                                \u2502     PR_SET_NO_NEW_PRIVS                                                \u2502                                                \u2502  3. Landlock                                                \u2502     path rules + TCP port rules                                                \u2502                                                \u2502  4. seccomp-BPF                                                \u2502     \u0444\u0438\u043b\u044c\u0442\u0440 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c                                                \u2502                                                \u2502  5. exec(binary, args)\u0412\u043e\u0442 \u0447\u0442\u043e\u00a0\u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u00a0\u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0438 \u043f\u043e\u0440\u044f\u0434\u043a\u0430:\u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a\u041f\u043e\u0447\u0435\u043c\u0443 \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044fcapset(0) \u0434\u043e PR_CAPBSET_DROPcapset(0) \u0443\u0431\u0438\u0440\u0430\u0435\u0442 CAP_SETPCAP \u2192 \u0434\u0440\u043e\u043f bounding set \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u0441\u00a0EPERM\u0414\u0440\u043e\u043f capabilities \u0434\u043e\u00a0user namespace\u0423\u00a0\u043d\u0435\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435\u0442 capabilities \u0434\u043b\u044f\u00a0\u0434\u0440\u043e\u043f\u0430\u00a0\u2014 \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043e\u0439\u0442\u0438 \u0432\u00a0user\u2011nsseccomp \u0434\u043e\u00a0Landlock\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 Landlock \u0442\u0440\u0435\u0431\u0443\u0435\u0442 landlock_create_ruleset\u00a0\u2014 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u0440\u043e\u0433\u0438\u0439 seccomp \u0443\u0436\u0435 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043bRemount \/ \u0434\u043e\u00a0user namespacemount(MS_PRIVATE) \u0442\u0440\u0435\u0431\u0443\u0435\u0442 CAP_SYS_ADMIN, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u043d\u0435\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u044e\u0437\u0435\u0440\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 user\u2011ns\u042d\u0442\u043e \u043d\u0435\u00a0\u0442\u0435\u043e\u0440\u0438\u044f\u00a0\u2014 \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437\u00a0\u044d\u0442\u0438\u0445 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0439 \u043d\u0430\u00a0\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u044f\u0434\u0440\u0435 \u0434\u0430\u0451\u0442\u00a0\u043b\u0438\u0431\u043e EPERM,\u00a0\u043b\u0438\u0431\u043e \u0442\u0438\u0445\u043e\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0437\u0430\u0449\u0438\u0442\u044b.Audit\u2011\u0440\u0435\u0436\u0438\u043c: \u043a\u0430\u043a\u00a0\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0443\u0447\u0438\u0442\u0441\u044f, \u0447\u0442\u043e\u00a0\u043d\u0443\u0436\u043d\u043e \u0431\u0438\u043d\u0430\u0440\u044e\u042d\u0442\u043e \u043c\u043e\u044f \u043b\u044e\u0431\u0438\u043c\u0430\u044f \u0447\u0430\u0441\u0442\u044c. \u0418\u0434\u0435\u044f: \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u044c \u0431\u0435\u0437\u00a0\u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0447\u0442\u043e\u00a0\u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442, \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c TOML\u2011\u043f\u0440\u043e\u0444\u0438\u043b\u044c \u0441\u00a0\u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438.# \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u044c \u0432 stdouthajiz &#8212;audit \/usr\/bin\/curl https:\/\/example.com# \u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043bhajiz &#8212;audit &#8212;audit-output curl.toml \/usr\/bin\/curl https:\/\/example.com# \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0444\u0438\u043b\u044chajiz &#8212;profile curl.toml \/usr\/bin\/curl https:\/\/example.com\u0414\u0432\u0430 \u0431\u044d\u043a\u0435\u043d\u0434\u0430, \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438:eBPF\u00a0\u2014 \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043e \u043e\u0442\u00a0root \u0438\u043b\u0438\u00a0\u0441 CAP_BPF. \u0422\u0440\u0435\u0439\u0441\u0438\u0442 syscall\u2011\u044b \u0447\u0435\u0440\u0435\u0437 raw_tracepoint\/sys_enter. \u041d\u0438\u0437\u043a\u0438\u0439 overhead, \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u043d\u0430 syscall\u2011\u043e\u0432.strace\u00a0\u2014 \u043d\u0435\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 fallback. \u041c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u043d\u043e\u00a0\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0443\u0442\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0430\u0434\u0440\u0435\u0441\u0430.\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: eBPF \u0442\u0440\u0435\u0431\u0443\u0435\u0442 CAP_BPF, \u043d\u043e\u00a0\u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0431\u0438\u043d\u0430\u0440\u044c \u043d\u0435\u00a0\u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0420\u0435\u0448\u0435\u043d\u0438\u0435\u00a0\u2014 broker\/sandbox split. \u0422\u043e\u0442\u00a0\u0436\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u0447\u0442\u043e\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Chrome, firejail, bwrap.\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442: \u044f\u0434\u0440\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 CAP_BPF \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u00a0\u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f BPF\u2011\u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e fd\u00a0\u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 SCM_RIGHTS \u043b\u044e\u0431\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443, \u0432\u00a0\u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043d\u0435\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443.\u041a\u0430\u043a\u00a0\u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:sudo hajiz &#8212;audit \/usr\/bin\/curl &#8230;       \u2502       \u25bc\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\u2502  hajiz \u043f\u0440\u043e\u0446\u0435\u0441\u0441 (root \/ CAP_BPF)                                          \u2502\u2502                                                                          \u2502\u2502  socketpair(AF_UNIX, SOCK_STREAM)                                        \u2502\u2502  fork()                                                                  \u2502\u2502      \u2502                                       \u2502                           \u2502\u2502  BROKER (parent)                         SANDBOX (child)                 \u2502\u2502      \u2502                                       \u2502                           \u2502\u2502  \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 BPF-\u043e\u0431\u044a\u0435\u043a\u0442                    \u2605 \u041f\u0415\u0420\u0412\u0410\u042f \u0418\u041d\u0421\u0422\u0420\u0423\u041a\u0426\u0418\u042f:            \u2502\u2502  aya::Ebpf::load(audit_syscalls.o)         drop_all_capabilities()       \u2502\u2502  attach(&#171;sys_enter&#187;)                       (capset(0) + bounding set +   \u2502\u2502  \u2190 \u044f\u0434\u0440\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 CAP_BPF \u0437\u0434\u0435\u0441\u044c             ambient clear + no_new_privs)\u2502\u2502                                             \u2502                            \u2502\u2502  \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 fd: config_map, syscall_map       recv_fds()                   \u2502\u2502  send_fds() \u2500\u2500\u2500\u2500 SCM_RIGHTS \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba (\u0443\u0436\u0435 \u0431\u0435\u0437 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439)         \u2502\u2502                                             \u2502                            \u2502\u2502  drop_all_capabilities()                    \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 target PID        \u2502\u2502  \u2605 broker \u0442\u043e\u0436\u0435 \u0431\u0435\u0437 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439               \u0432 config_map                 \u2502\u2502  BPF \u0436\u0438\u0432 \u2014 \u0434\u0435\u0440\u0436\u0438\u043c fd                        \u2502                            \u2502\u2502                                             spawn(binary)                \u2502\u2502                                             \u2502                            \u2502\u2502                                             \u044f\u0434\u0440\u043e: raw_tracepoint \u0441\u0440\u0430\u0431\u0430\u0442. \u2502\u2502                                             per syscall, \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442 \u043f\u043e PID\u2502\u2502                                             \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 syscall_map   \u2502\u2502                                             \u2502                            \u2502\u2502                                             \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043e\u0442\u0447\u0451\u0442            \u2502\u2502  read() \u25c4\u2500\u2500\u2500 socket \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u043f\u0438\u0448\u0435\u0442 \u0432 socket               \u2502\u2502  \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u043e\u0444\u0438\u043b\u044c                         exit                         \u2502\u2502  \u043f\u0438\u0448\u0435\u0442 curl.toml                                                         \u2502\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\u041e\u043a\u043d\u0430 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439:\u041f\u0440\u043e\u0446\u0435\u0441\u0441\u041f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043e\u043a\u043d\u043e\u0427\u0442\u043e\u00a0\u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442Brokerstart \u2192 drop_all_capabilities() \u043f\u043e\u0441\u043b\u0435 send_fds()BPF load + attach + sendmsg. \u041c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u044b.Sandboxfork() \u2192 \u043f\u0435\u0440\u0432\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0432\u00a0userspace\u0420\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d syscall return. \u041f\u0435\u0440\u0432\u043e\u0435 \u0447\u0442\u043e\u00a0\u0434\u0435\u043b\u0430\u0435\u0442\u00a0\u2014 drop_all_capabilities().\u0426\u0435\u043b\u0435\u0432\u043e\u0439 \u0431\u0438\u043d\u0430\u0440\u044c \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u00a0\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u00a0\u043f\u043e\u0432\u044b\u0448\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438\u00a0\u2014 \u043d\u0438 \u043d\u0430\u00a0\u043e\u0434\u043d\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e.BPF\u2011\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u041d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u0430. \u0414\u0432\u0430 map\u2011\u0430: config_map (\u0434\u0435\u0440\u0436\u0438\u0442 target TGID), syscall_map (\u0445\u044d\u0448 syscall_nr \u2192 count). \u041e\u0434\u043d\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430:SEC(&#171;raw_tracepoint\/sys_enter&#187;)int audit_syscalls(struct bpf_raw_tracepoint_args *ctx) {    u32 tgid =&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-485416","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/485416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=485416"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/485416\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=485416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=485416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=485416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}