Skip to content

LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.

Firewall: no exemption by identity under user@; Linux apps restricted from the microphone, camera, USB or Bluetooth start in their own view (no session bus, no user manager), and Landlock scoping fails closed without ABI 6

Federico Pereira88686d9ee5f8
diff --git a/assets/locales/en/errors.json b/assets/locales/en/errors.json
index 4d1de6d..f620084 100644
--- a/assets/locales/en/errors.json
+++ b/assets/locales/en/errors.json
@@ -1,4 +1,5 @@
{
+ "apps.restrictKernel": "This app's restrictions need a newer kernel: it was not started",
"admin.actionFailed": "The action finished with an error",
"admin.forkFailed": "Could not start the action",
"admin.invalidArgument": "Invalid argument",
diff --git a/assets/locales/en/firewall.json b/assets/locales/en/firewall.json
index 29983d8..9ad5624 100644
--- a/assets/locales/en/firewall.json
+++ b/assets/locales/en/firewall.json
@@ -41,7 +41,7 @@
"r.no-clipboard": "No reading the clipboard",
"desktopAlways": "The desktop itself always has access to files, removable drives, the clipboard and Bluetooth; restrict individual apps instead.",
"whenNextLaunch": "{name} (at next launch)",
- "linuxWhen": "Applies immediately to the running app, except access to your files, which applies the next time it starts.",
+ "linuxWhen": "Applies immediately to the running app. Access to your files applies the next time it starts; for the microphone, the camera, USB and Bluetooth, restart the app so it can't get around them.",
"helpLine": "{name}: {help}",
"help.no-internet": "only the local network; checked on every new connection.",
"help.no-lan": "nothing on the local network, including this computer.",
diff --git a/assets/locales/es/errors.json b/assets/locales/es/errors.json
index 731b7df..997ef90 100644
--- a/assets/locales/es/errors.json
+++ b/assets/locales/es/errors.json
@@ -1,4 +1,5 @@
{
+ "apps.restrictKernel": "Las restricciones de esta app necesitan un kernel más nuevo: no se abrió",
"admin.actionFailed": "La acción terminó con un error",
"admin.forkFailed": "No se pudo iniciar la acción",
"admin.invalidArgument": "Argumento inválido",
diff --git a/assets/locales/es/firewall.json b/assets/locales/es/firewall.json
index 4596170..dd090ed 100644
--- a/assets/locales/es/firewall.json
+++ b/assets/locales/es/firewall.json
@@ -41,7 +41,7 @@
"r.no-clipboard": "Sin leer el portapapeles",
"desktopAlways": "El escritorio en sí siempre tiene acceso a los archivos, las unidades extraíbles, el portapapeles y Bluetooth; restringe apps individuales.",
"whenNextLaunch": "{name} (al próximo inicio)",
- "linuxWhen": "Se aplica enseguida a la app abierta, salvo el acceso a tus archivos, que se aplica la próxima vez que se inicie.",
+ "linuxWhen": "Se aplica de inmediato a la app abierta. El acceso a tus archivos se aplica la próxima vez que se abra; para el micrófono, la cámara, USB y Bluetooth, reinicia la app para que no pueda esquivarlas.",
"helpLine": "{name}: {help}",
"help.no-internet": "solo la red local; se comprueba en cada conexión nueva.",
"help.no-lan": "nada de la red local, ni esta computadora.",
diff --git a/assets/locales/pt/errors.json b/assets/locales/pt/errors.json
index d457139..00f57c2 100644
--- a/assets/locales/pt/errors.json
+++ b/assets/locales/pt/errors.json
@@ -1,4 +1,5 @@
{
+ "apps.restrictKernel": "As restrições deste app precisam de um kernel mais novo: ele não foi aberto",
"admin.actionFailed": "A ação terminou com um erro",
"admin.forkFailed": "Não foi possível iniciar a ação",
"admin.invalidArgument": "Argumento inválido",
diff --git a/assets/locales/pt/firewall.json b/assets/locales/pt/firewall.json
index 54bfc85..a3cbd9d 100644
--- a/assets/locales/pt/firewall.json
+++ b/assets/locales/pt/firewall.json
@@ -41,7 +41,7 @@
"r.no-clipboard": "Sem ler a área de transferência",
"desktopAlways": "A própria área de trabalho sempre tem acesso aos arquivos, unidades removíveis, área de transferência e Bluetooth; restrinja apps individuais.",
"whenNextLaunch": "{name} (na próxima abertura)",
- "linuxWhen": "Aplica-se na hora ao app aberto, exceto o acesso aos seus arquivos, que vale a partir da próxima vez que ele abrir.",
+ "linuxWhen": "Aplica-se imediatamente ao app aberto. O acesso aos seus arquivos se aplica na próxima vez que ele abrir; para o microfone, a câmera, USB e Bluetooth, reinicie o app para que ele não possa contorná-las.",
"helpLine": "{name}: {help}",
"help.no-internet": "só a rede local; verificado a cada nova conexão.",
"help.no-lan": "nada da rede local, nem este computador.",
diff --git a/docs/FIREWALL.md b/docs/FIREWALL.md
index f3c41b4..6a7a500 100644
--- a/docs/FIREWALL.md
+++ b/docs/FIREWALL.md
@@ -190,13 +190,12 @@ on `open()` and `mknod()` of a device node, and returns 0 only for the device cl
restricted from (`np_dev_restriction()` in `np_shared.h`, plus, for "no microphone", the ALSA
capture PCMs in `np_snd`). In the app's own scope "no microphone" fails closed: an ALSA node the
last scan of `/sys/class/sound` hasn't classified yet (a USB microphone plugged in, at most 5 s)
-is denied too. Under the `user@` union "no microphone" denies the known capture nodes to every
-process except the user's real PipeWire and WirePlumber (otherwise the microphone is gone for
-every app and doesn't come back): exactly their process id in exactly the cgroups
-`user.slice/user-<uid>.slice/user@<uid>.service/session.slice/{pipewire,wireplumber}.service`, and
-only while each holds that one process (`np_sndsvc`, refreshed every second). A process the user moves
-into that cgroup has another process id and is still denied; a nested cgroup that merely ends in
-the same names is another cgroup. Everything else returns 1. Programs systemd attaches higher up (`DeviceAllow=`) still
+is denied too. "No microphone" is not part of the `user@` union: there it would deny the capture
+nodes to the user's own PipeWire and WirePlumber, and the microphone would be gone for every app
+(it doesn't come back). Nothing under `user@` is exempted for being, or claiming to be, the sound
+server: the user controls that manager (units, drop-ins, environment, PipeWire's own config), so
+no such check is unforgeable. Instead a restricted app can't get there: see "Its own view"
+below. Everything else returns 1. Programs systemd attaches higher up (`DeviceAllow=`) still
apply: the kernel allows only what all of them allow. A denial is logged by `lord-netperm` once per
5 s, not counted with the connections. `lord-server`'s own scope (`lordos`) never gets device
restrictions in the kernel: it opens the camera, the FIDO key and the sound for the apps after
@@ -279,13 +278,15 @@ the apps could change. Who a client is:
- When a restricted app falsely claims another process's PID through `pipewire-pulse`, every
client claiming that PID is treated as restricted while the false claim lasts, the honest one
included.
-- A process that escaped to `user@<uid>` (`systemd-run --user`) is held as restricted only while
- a restricted app runs, like `lord-netperm`'s union (which also denies it the ALSA capture
- nodes). If the restricted app exits first, the escaped process is free. With `no-files` the app
- can't reach the session bus or the user manager, which closes that path; no-mic and no-camera
- alone don't cut the session bus (that would break most apps' D-Bus use).
-- If PipeWire restarts while a no-mic app runs, the new daemon is known to `lord-netperm` within a
- second; an ALSA capture open in that second is refused.
+- An app restricted with no-files, no-mic, no-camera, no-usb or no-bluetooth and started from
+ the launcher has no session bus and no user manager (its own view), so it can't escape to
+ `user@<uid>`. One that wasn't started by the launcher, or that was already running when the
+ restriction was set (restart it to apply; Settings says so), may have escaped. The guard holds
+ `user@` clients as restricted while a restricted app runs, but the ALSA capture nodes stay open
+ to processes there.
+- An app restricted without `no-files` can still write its home folder: startup files, user units,
+ `firewall.json` itself. Such a change takes effect outside the restriction later (the next
+ login, a reload). Only `no-files` keeps an app from them.
- A Linux app restricted without `no-files` runs as the user, so it could take over another of the
user's processes (lord-server, PipeWire, another app) with `ptrace` and act through it. LordOS
sets `kernel.yama.ptrace_scope = 1` (`/usr/lib/sysctl.d/50-lordos-ptrace.conf`): only a
@@ -294,6 +295,17 @@ the apps could change. Who a client is:
address bound into the app's view) would remove the need to trust `application.process.id` at
all: also the next step.
+**Its own view, for device restrictions.** An app restricted with no-mic, no-camera, no-usb or
+no-bluetooth (without no-files) gets the same view as below, without the home restriction: its
+home folder stays as it is, but the runtime dir holds only the Wayland socket, `pipewire-0` and
+`pulse/native` (no session bus, no `systemd/private`, no agents). `/tmp`, `/var/tmp` and
+`/dev/shm` are private, `/dev/pts` is its own, with new PID and IPC namespaces and Landlock's
+scoping (no abstract unix socket and no signal outside it). So it can't create or change a unit
+nor start anything outside its scope, and the device program and the PipeWire guard always find
+it by its scope. It costs the app the session bus: notifications, portals and the like over
+D-Bus don't work for it. Applied at launch: restart the app to apply. Without Landlock ABI 6
+(kernel 6.12 or later) a restricted app isn't started at all, and the launcher says why.
+
**No access to your files.** Applied by the launcher's child after it entered its scope and right
before `execve`, so a restriction set while the app runs applies at its next launch (Settings
says so). Two layers:
diff --git a/docs/SECURITY-REVIEW-0.8.0.md b/docs/SECURITY-REVIEW-0.8.0.md
index 5934193..9c5d0f2 100644
--- a/docs/SECURITY-REVIEW-0.8.0.md
+++ b/docs/SECURITY-REVIEW-0.8.0.md
@@ -37,8 +37,8 @@ Tests:
| 10 | Medium | Launcher | Time-of-check to time-of-use on "Open with": the path was checked with `realpath()` in lord-server but bound (and given to Landlock) later by path, following symlinks. A running instance could swap a component for a symlink to `~/.ssh`. | Fixed: the opened file is reopened with `openat2(RESOLVE_NO_SYMLINKS)` and must still be the inode that was checked (dev and inode), both for the bind and for the Landlock rule (also on `/media`). Otherwise the grant is dropped. | 594399c |
| 11 | Medium | Launcher | Without `XDG_RUNTIME_DIR` no tmpfs went over the runtime dir, so the bus stayed reachable. | Fixed: it falls back to `/run/user/<uid>`, or refuses to launch. | 594399c |
| 12 | Medium | lord-netperm (root) | No-mic denied only the ALSA capture minors seen at the last scan (every 5 s). A USB microphone plugged in was open to a restricted app in between, and the app keeps the fd afterwards. | Fixed: in the app's own scope every ALSA minor not classified as non-capture is denied (fail closed; `np_snd` classifies every node). Test: `mic.sh` 6, with an unknown minor. | bd09ae7 |
-| 13 | Medium | lord-netperm, `user@` union | The union's no-mic denied the capture nodes to the user's own PipeWire and WirePlumber. While any no-mic app ran, the microphone disappeared for the whole desktop and did not come back (WirePlumber drops the source). Reproduced on VM 118. A first fix took no-mic out of the union; review showed that reopened an escape (a no-mic app without no-files can `systemd-run --user` and open `/dev/snd` directly). | Fixed: no-mic is in the union. Only the user's real PipeWire and WirePlumber keep the capture nodes: the exact cgroup `user@<uid>.service/session.slice/{pipewire,wireplumber}.service`, only while it holds one process, matched in the program by that process's tgid **and** the cgroup id (`np_sndsvc`, refreshed every second). A process moved into that cgroup has another tgid. Tests: `mic.sh` 9 (escaped open, open from inside pipewire.service's cgroup) and "once lifted, the desktop still records". | 00b2c95, 30d4e8a |
-| 14 | Medium | PipeWire guard | A process escaped to `user@` (`systemd-run --user pw-record`) was not restricted. | Fixed: while a restricted app runs, a client under `user@<uid>` counts as restricted, except PipeWire, WirePlumber and pipewire-pulse. Those are identified by the exact unit path, being the only process in it, and their root-owned executable. Clients outside app scopes are re-checked every second. Test: `mic.sh` 9. | c1f12c7, 99a0c7d |
+| 13 | High | lord-netperm, `user@` union, launcher | The union's no-mic denied the capture nodes to the user's own PipeWire and WirePlumber: while any no-mic app ran, the microphone disappeared for the whole desktop and did not come back (reproduced on VM 118). Taking no-mic out of the union reopened the escape (a no-mic app without no-files could `systemd-run --user` and open `/dev/snd` directly). Two exemptions for "the real sound services" were tried and rejected (see "Design change" below). | Fixed by design: no process under `user@` is exempted for who it is. Every app restricted with no-mic, no-camera, no-usb or no-bluetooth is started in its own view (no session bus, no user manager, Landlock scoping), so it can't escape its scope, and no-mic stays out of the union. Tests: `files.sh` 3c (for each of the four restrictions: no bus, no `systemd/private`, no `systemd-run`, home kept, PipeWire reachable), `mic.sh` 6 (ALSA capture → EPERM in the scope) and "once lifted, the desktop still records". | 00b2c95, see below |
+| 14 | Medium | PipeWire guard | A process escaped to `user@` (`systemd-run --user pw-record`) was not restricted. | Mitigated: escape is closed for launcher-started apps (#13). While a restricted app runs, the guard also holds `user@` clients as restricted, except PipeWire, WirePlumber and pipewire-pulse (exact unit path, alone in it, root-owned binary). That exemption is best effort: it decides only what the guard hides, never a kernel decision. Test: `mic.sh` 9. | c1f12c7, 99a0c7d |
| 15 | Medium | PipeWire guard (reported by the automated reviewer) | The first fix for #14, and the existing pipewire-pulse check, matched the cgroup path by suffix. The user owns `user@`, so a nested `…/x.scope/session.slice/pipewire.service` posed as the sound server. Reproduced on VM 118 against the suffix version (it recorded 286 KB). | Fixed: exact path built from the uid, sole process in the unit, root-owned executable (same inode). Test: `mic.sh` 9 (nested fake pipewire and wireplumber units). Other cgroup matching was checked: `appid.c` (now anchored, #18), netperm `scope_app` (reads only root-owned directories), `cgroup.c` (exact `strcmp`). | 99a0c7d |
| 16 | Medium | PipeWire guard | The pulse identity check counted connections but didn't tie them to the claimant. A process in another PID namespace (a no-files app) reports its inner PID, which left slack that a no-mic app could claim with the outer PID. | Fixed: a claimed PID must live in our PID namespace (`NSpid`). Test: `mic.sh` 7 (claim of a namespaced recorder's outer PID). | c1f12c7 |
| 17 | Medium | lord-sessiond (root), pre-existing | On a switch the leaving session's framebuffers stayed alive until it handled RP_UNDISPLAY; a stuck or hostile one never does. The next DRM master can read them (`GETFB2` + map): the last frame of another user's unlocked desktop. The new keep path made the window longer. | Fixed: `take_back()` removes every framebuffer of the lent file (`GETRESOURCES` + `RMFB`) before `DROP_MASTER`. | 913113f |
@@ -60,7 +60,43 @@ Tests:
| 33 | Low | Launcher | The abstract unix socket scoping (`LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET`) depends on the build headers. It is present on Debian 13. | Open. | — |
| 34 | Low | Launcher | `/run/dbus` (system bus), `/run/cups` and `/run/lordos/*.sock` stay reachable from a no-files view. Each was checked: `cgroup.sock` requires the session leaf and a trusted binary, `netperm.sock` takes only RELOAD, `fand.sock` gives STATUS only. | Accepted. | — |
| 35 | Info | PipeWire guard | A new client has full permissions for milliseconds before the first `update_permissions`, and a stream can get a few milliseconds of audio before it is destroyed. | Documented (FIREWALL.md). | — |
-| 36 | Info | Escapes | A no-mic or no-camera app without no-files can still reach the session bus and `systemd-run --user`. It is held by the `user@` union and the guard only while a restricted app runs. Cutting the bus for those restrictions would break most apps. | Documented. | — |
+| 36 | Info | Escapes | An app not started from the launcher, or already running when it was restricted, may have escaped to `user@`; the ALSA capture nodes stay open there. An app restricted without no-files can write its own home (startup files, user units, `firewall.json`), which takes effect later, outside the restriction. | Documented (FIREWALL.md); Settings says "restart the app". | — |
+| 37 | High | lord-netperm (reported by the automated reviewer) | The `np_sndsvc` exemption (the exact unit cgroup, its sole process's tgid, the packaged binary, no user unit files or drop-ins) was still forgeable. The user controls their own manager: `systemd-run --user --unit=pipewire.service` passed the file checks (reproduced on VM 118: `sndsvc.sh` 3 and 4 got the exemption), and so would type-wide `service.d` drop-ins, `set-environment` (`LD_PRELOAD`) and PipeWire's or WirePlumber's own config (modules are code). | Removed: replaced by the design in #13. The intermediate commits 30d4e8a and the uncommitted hardening are superseded. | see below |
+| 38 | Medium | `sec/sandbox.c` (reported by the automated reviewer) | Landlock's abstract unix socket scoping failed open: with ABI < 6, or built without the scoping constants, the files sandbox went on without it, so a restricted app could reach the session's abstract sockets. | Fixed: both the files sandbox and the device view require ABI 6, otherwise the app isn't started. The launcher checks this before forking and reports `apps.restrictKernel` (a localized notification). The read-only remount of a read-only grant now fails closed too. Test: `files.sh` 3d (`LORD_SANDBOX_MAX_ABI=5`, which can only lower the ABI). | see below |
+
+## Design change: no exemption by identity under `user@`
+
+The user owns their systemd user manager, so anything that runs in `user@<uid>.service` can be
+made to look like anything:
+- a nested cgroup with the same names;
+- a process moved into the real unit's cgroup;
+- a unit file, drop-in or type-wide `service.d` drop-in;
+- a transient unit with the same name (`systemd-run --user --unit=pipewire.service`);
+- the manager's environment (`set-environment`, `environment.d`, `LD_PRELOAD`);
+- PipeWire's and WirePlumber's own config, which loads modules.
+
+Two attempts to exempt the user's real PipeWire from the union's no-mic were rejected:
+1. matching by cgroup path suffix (#15);
+2. the exact cgroup, its sole process's tgid, the packaged binary's inode and the absence of user
+ unit files (#37).
+
+Both were beaten on VM 118. The design now:
+1. **No process under `user@` is trusted by lord-netperm** for who or what it claims to be.
+2. **The escape is closed at the source.** A Linux app restricted with no-files, no-mic,
+ no-camera, no-usb or no-bluetooth is started by the launcher in its own view:
+ - user, mount, PID and IPC namespaces;
+ - a runtime dir with only the Wayland socket, `pipewire-0` and `pulse/native`, so no session
+ bus, no `systemd/private` and no agents;
+ - private `/tmp`, `/var/tmp`, `/dev/shm` and devpts;
+ - Landlock scoping of abstract sockets and signals.
+
+ Only no-files also hides the home folder. Such an app can't create or change a unit, or start
+ anything outside its scope, so the device program and the PipeWire guard always find it by its
+ scope.
+3. **No-mic stays out of the `user@` union.** The union keeps covering the network and the other
+ devices for processes that escaped earlier.
+4. **The cost:** these apps lose the session bus (notifications, portals). A restriction set while
+ the app runs needs a restart to close the escape (the Settings note says so).
## Checked and clean
diff --git a/sdk/apps.js b/sdk/apps.js
index 2f9d84a..ce73749 100644
--- a/sdk/apps.js
+++ b/sdk/apps.js
@@ -12,6 +12,8 @@ import { createElement as h } from 'react';
import { View, Text, Image } from '@lordos/runtime';
import { createStore, useStore } from './store.js';
import { locale, appName } from './i18n.js';
+import { errorText } from './errors.js';
+import { notify } from './notify.js';
import { listApps, wm, windows, appRegistry, getApp as registryApp } from './windows.js';
const DESKTOP = 'desktop:';
@@ -74,7 +76,13 @@ export function appCategory(a) {
}
export function launchApp(id) {
- if (isLinuxApp(id)) return lord.apps.launch(String(id).slice(DESKTOP.length));
+ if (isLinuxApp(id)) {
+ const ok = lord.apps.launch(String(id).slice(DESKTOP.length));
+ // refused for a reason the user can act on (e.g. its restrictions need a newer kernel)
+ const code = !ok && typeof lord.apps.lastError === 'function' ? lord.apps.lastError() : '';
+ if (code) notify({ app: 'settings', title: errorText(code) });
+ return ok;
+ }
// An installed .lpk app runs as its own isolated process (lord-server --app <id>), if the
// server supports it; it reaches the desktop as a Wayland window with app_id = its id. Otherwise it
// falls back to in-process mode (compatibility). See docs/PRIVACY.md.
diff --git a/server/src/apps.c b/server/src/apps.c
index 50f7432..1fb3cd7 100644
--- a/server/src/apps.c
+++ b/server/src/apps.c
@@ -571,6 +571,36 @@ static FilesPlan *files_plan(const DesktopApp *a, const char *file, const char *
return p;
}
+/* No microphone, camera, USB or Bluetooth (without no-files): the same view minus the home
+ * restriction. No session bus, no systemd user manager, no agents: such an app can't create or
+ * change a unit, or start anything outside its scope (systemd-run --user, D-Bus activation), so the
+ * device program and the PipeWire guard, which know it by its scope, always see it. */
+static FilesPlan *view_plan(const char *cwd) {
+ FilesPlan *p = calloc(1, sizeof *p);
+ if (!p) return NULL;
+ const char *h = getenv("HOME");
+ if (!h || !realpath(h, p->home) || p->home[0] != '/' || !strcmp(p->home, "/")) { free(p); return NULL; }
+ p->cfg.home = p->home;
+ p->cfg.keep_home = 1;
+ const char *rt = getenv("XDG_RUNTIME_DIR");
+ char rtdef[64];
+ snprintf(rtdef, sizeof rtdef, "/run/user/%u", (unsigned)getuid());
+ if (!(rt && rt[0] == '/' && realpath(rt, p->runtime)) && !realpath(rtdef, p->runtime)) { free(p); return NULL; }
+ p->cfg.runtime_dir = p->runtime;
+ const char *wd = getenv("WAYLAND_DISPLAY");
+ int ns = 0;
+ if (wd && wd[0] && !strchr(wd, '/') && strlen(wd) < sizeof p->wayland) { snprintf(p->wayland, sizeof p->wayland, "%s", wd); p->cfg.sockets[ns++] = p->wayland; }
+ else p->cfg.sockets[ns++] = "wayland-0";
+ p->cfg.sockets[ns++] = "pipewire-0"; /* playback; capture goes through the PipeWire guard */
+ p->cfg.sockets[ns++] = "pulse/native";
+ p->cfg.sockets[ns] = NULL;
+ if (cwd && cwd[0] == '/') { snprintf(p->cwd, sizeof p->cwd, "%s", cwd); p->cfg.cwd = p->cwd; }
+ return p;
+}
+
+static char last_error[64];
+const char *apps_last_error(void) { return last_error; }
+
static int launch(const char *id, const char *file);
int apps_launch(const char *id) { return launch(id, NULL); }
@@ -589,6 +619,7 @@ int apps_launch_with(const char *id, const char *path) {
}
static int launch(const char *id, const char *file) {
+ last_error[0] = 0;
if (!valid_id(id)) return -1;
const DesktopApp *list;
int n = apps_list(cached_lang[0] ? cached_lang : "en", &list);
@@ -613,12 +644,26 @@ static int launch(const char *id, const char *file) {
FilesPlan *plan = NULL;
char fwid[FW_APP_MAX];
snprintf(fwid, sizeof fwid, "desktop:%s", id);
+ uint32_t viewed = FW_R_NO_FILES | FW_R_NO_MIC | FW_R_NO_CAMERA | FW_R_NO_USB | FW_R_NO_BLUETOOTH;
+ if (restrict_blocks(fwid, viewed) && sandbox_landlock_abi() < 6) {
+ /* fail closed: without Landlock ABI 6 the session's abstract sockets can't be kept away */
+ fprintf(stderr, "apps: %s is restricted, but this kernel's Landlock is too old (ABI < 6): not launched\n", id);
+ snprintf(last_error, sizeof last_error, "apps.restrictKernel");
+ free(buf);
+ return -1;
+ }
if (restrict_blocks(fwid, FW_R_NO_FILES)) {
if (!sandbox_landlock_abi() || !(plan = files_plan(a, file, cwd))) {
fprintf(stderr, "apps: %s is restricted to no files, but Landlock is not available: not launched\n", id);
free(buf);
return -1;
}
+ } else if (restrict_blocks(fwid, FW_R_NO_MIC | FW_R_NO_CAMERA | FW_R_NO_USB | FW_R_NO_BLUETOOTH)) {
+ if (!(plan = view_plan(cwd))) {
+ fprintf(stderr, "apps: %s is restricted, but its own view can't be built: not launched\n", id);
+ free(buf);
+ return -1;
+ }
}
pid_t pid = fork();
@@ -645,7 +690,8 @@ static int launch(const char *id, const char *file) {
_exit(126);
}
/* its own view (namespaces: no session sockets, only its folders), then Landlock */
- if (plan && (sandbox_files_isolate(&plan->cfg) || sandbox_apply_files(&plan->cfg))) {
+ if (plan && (sandbox_files_isolate(&plan->cfg) ||
+ (plan->cfg.keep_home ? sandbox_apply_scope() : sandbox_apply_files(&plan->cfg)))) {
static const char msg[] = "apps: could not apply the no-files restriction: not launched\n";
if (write(2, msg, sizeof msg - 1) < 0) {}
_exit(126);
diff --git a/server/src/apps.h b/server/src/apps.h
index 20c6b78..0f9a27c 100644
--- a/server/src/apps.h
+++ b/server/src/apps.h
@@ -26,5 +26,7 @@ int apps_launch(const char *id);
/* Same, but opening a file or folder (see apps.c: only apps with MimeType and paths in the
* home folder or the user's mounts, as a single argument). */
int apps_launch_with(const char *id, const char *path);
+/* Why the last apps_launch/apps_launch_with refused, as an error code ("" = no specific reason). */
+const char *apps_last_error(void);
#endif
diff --git a/server/src/netperm/netperm.c b/server/src/netperm/netperm.c
index 2f9cef9..aec7363 100644
--- a/server/src/netperm/netperm.c
+++ b/server/src/netperm/netperm.c
@@ -80,7 +80,6 @@ typedef struct {
int nsc, cap;
int dirty_counts;
uint64_t user_cg; /* id of user@<uid>.service, or 0 if it isn't there (nor attached) */
- uint32_t snd_tgid[2]; /* its PipeWire and WirePlumber in np_sndsvc (0 = none) */
int ulinks[16], nulinks; /* the programs attached to user@<uid>.service */
} Session;
@@ -102,7 +101,7 @@ typedef struct {
static struct {
int bpf_ok;
char bpf_err[200]; /* a code line (errcode.h): the firewall page shows it translated */
- int m_np_cfg, m_np_apps, m_np_union, m_np_lpm4, m_np_lpm6, m_np_seen, m_np_counts, m_np_events, m_np_snd, m_np_sndsvc;
+ int m_np_cfg, m_np_apps, m_np_union, m_np_lpm4, m_np_lpm6, m_np_seen, m_np_counts, m_np_events, m_np_snd;
uint32_t snd[NP_MAX_SND]; /* the ALSA minors in np_snd */
int nsnd;
int dev_ok, bt_ok; /* the device / Bluetooth programs loaded */
@@ -212,7 +211,6 @@ static int map_fd(const char *name) {
if (!strcmp(name, "np_counts")) return G.m_np_counts;
if (!strcmp(name, "np_events")) return G.m_np_events;
if (!strcmp(name, "np_snd")) return G.m_np_snd;
- if (!strcmp(name, "np_sndsvc")) return G.m_np_sndsvc;
return -1;
}
#endif
@@ -311,13 +309,16 @@ static void drop_scope(Scope *sc) {
/* Recompiles the user's union from the flags of their scopes and writes it (or deletes it if
* there's no restriction). Only takes effect with user@ attached. */
-static void sync_sndsvc(Session *s);
-
static void sync_union(Session *s) {
if (!G.bpf_ok || !s->user_cg) return;
NpApp u;
memset(&u, 0, sizeof u);
- for (int k = 0; k < s->nsc; k++) u.flags |= s->sc[k].app_v.flags;
+ /* "no microphone" stays out of the union: under user@ it would deny the ALSA capture nodes
+ * to the user's own PipeWire, which then drops the microphone for every app (and doesn't get
+ * it back). A process escaped there is held by the PipeWire guard instead (its clients count
+ * as restricted while restricted apps run); reading the card directly from there is the
+ * residual risk (docs/FIREWALL.md). */
+ for (int k = 0; k < s->nsc; k++) u.flags |= s->sc[k].app_v.flags & ~NP_R_NO_MIC;
if (u.flags) {
u.trusted = 1; /* whatever the union doesn't restrict is allowed without notice */
u.mode = NP_M_SILENT;
@@ -325,38 +326,6 @@ static void sync_union(Session *s) {
} else {
bpfs_map_delete(G.m_np_union, &s->user_cg);
}
- sync_sndsvc(s);
-}
-
-/* The user's real sound services, which keep the ALSA capture nodes under the union's no-mic
- * (PipeWire opens them to record, WirePlumber to probe the card's profiles): the exact cgroups
- * user.slice/user-<uid>.slice/user@<uid>.service/session.slice/{pipewire,wireplumber}.service
- * (never a nested one that merely ends in the same names), and only while each holds exactly one
- * process. Its tgid and cgroup id go into np_sndsvc; the program matches both. Refreshed every
- * second (a restart is a new process). */
-static void sync_sndsvc(Session *s) {
- if (!G.bpf_ok) return;
- static const char *const unit[2] = { "pipewire.service", "wireplumber.service" };
- char dir[200], path[300], line[32];
- snprintf(dir, sizeof dir, CG_ROOT "/" CG_USER "/user-%u.slice/user@%u.service/session.slice", s->uid, s->uid);
- int dfd = s->user_cg ? open(dir, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC) : -1;
- for (int k = 0; k < 2; k++) {
- uint32_t tgid = 0;
- uint64_t cg = dfd >= 0 ? bpfs_cgroup_id(dfd, unit[k]) : 0;
- if (cg) {
- snprintf(path, sizeof path, "%s/%s/cgroup.procs", dir, unit[k]);
- FILE *f = fopen(path, "re");
- int n = 0;
- unsigned long v = 0;
- while (f && fgets(line, sizeof line, f)) { if (!n) v = strtoul(line, NULL, 10); n++; }
- if (f) fclose(f);
- if (n == 1 && v > 0 && v <= UINT32_MAX) tgid = (uint32_t)v;
- }
- if (s->snd_tgid[k] && s->snd_tgid[k] != tgid) bpfs_map_delete(G.m_np_sndsvc, &s->snd_tgid[k]);
- if (tgid && bpfs_map_update(G.m_np_sndsvc, &tgid, &cg, BPF_ANY)) tgid = 0;
- s->snd_tgid[k] = tgid;
- }
- if (dfd >= 0) close(dfd);
}
static void drop_user_links(Session *s) {
@@ -455,7 +424,6 @@ static void drop_session(int k) {
for (int i = 0; i < s->nsc; i++) drop_scope(&s->sc[i]);
drop_user_links(s);
if (s->user_cg) { bpfs_map_delete(G.m_np_union, &s->user_cg); bpfs_map_delete(G.m_np_counts, &s->user_cg); }
- for (int k = 0; k < 2; k++) if (s->snd_tgid[k]) bpfs_map_delete(G.m_np_sndsvc, &s->snd_tgid[k]);
if (s->wd >= 0) inotify_rm_watch(G.ifd, s->wd);
free(s->sc);
fw_store_free(s->store);
@@ -793,7 +761,7 @@ static int bpf_setup(void) {
#define NP_MKMAP(n, t, k, v, m, f) G.m_##n = bpfs_map_create(t, k, v, m, f, #n);
NP_MAPS(NP_MKMAP)
#undef NP_MKMAP
- if (G.m_np_snd < 0 || G.m_np_sndsvc < 0 || G.m_np_cfg < 0 || G.m_np_apps < 0 || G.m_np_union < 0 || G.m_np_lpm4 < 0 || G.m_np_lpm6 < 0 || G.m_np_seen < 0 || G.m_np_counts < 0 || G.m_np_events < 0) {
+ if (G.m_np_snd < 0 || G.m_np_cfg < 0 || G.m_np_apps < 0 || G.m_np_union < 0 || G.m_np_lpm4 < 0 || G.m_np_lpm6 < 0 || G.m_np_seen < 0 || G.m_np_counts < 0 || G.m_np_events < 0) {
lerr_set(G.bpf_err, sizeof G.bpf_err, "fw.bpfMaps", "errno", lerr_errno(errno), NULL);
return -1;
}
@@ -971,7 +939,6 @@ int main(int argc, char **argv) {
attach_service();
if (G.dns) { npdns_tick(G.dns); watch_dns(); }
if (G.tick % 5 == 0) scan_all(); /* in case an inotify notice was lost */
- for (int k = 0; k < G.nsess; k++) sync_sndsvc(&G.sess[k]);
if (G.tick % 30 == 0) {
dnsmap_expire(G.names, mono());
for (int s = 0; s < G.nsess; s++)
diff --git a/server/src/netperm/np.bpf.c b/server/src/netperm/np.bpf.c
index feeb958..0e63582 100644
--- a/server/src/netperm/np.bpf.c
+++ b/server/src/netperm/np.bpf.c
@@ -40,8 +40,6 @@
static void *(*bpf_map_lookup_elem)(void *map, const void *key) = (void *)1;
static long (*bpf_map_update_elem)(void *map, const void *key, const void *value, unsigned long long flags) = (void *)2;
static unsigned long long (*bpf_ktime_get_ns)(void) = (void *)5;
-static unsigned long long (*bpf_get_current_pid_tgid)(void) = (void *)14;
-static unsigned long long (*bpf_get_current_cgroup_id)(void) = (void *)80;
static unsigned long long (*bpf_get_current_ancestor_cgroup_id)(int level) = (void *)123;
static long (*bpf_ringbuf_output)(void *ringbuf, void *data, unsigned long long size, unsigned long long flags) = (void *)130;
@@ -55,7 +53,6 @@ char np_seen[4] SEC("maps");
char np_counts[4] SEC("maps");
char np_events[4] SEC("maps");
char np_snd[4] SEC("maps");
-char np_sndsvc[4] SEC("maps");
#define AF_INET 2
#define AF_INET6 10
@@ -300,21 +297,14 @@ SEC("cgroup/dev") int np_dev(struct bpf_cgroup_dev_ctx *ctx) {
if (snd) {
/* Recording straight from the card. In the app's own scope this fails closed: an ALSA node
* the last scan didn't classify (a USB microphone plugged in since) counts as capture.
- * Under the user@ union only the known capture nodes count, and the user's real PipeWire
- * and WirePlumber keep them: exactly their process (tgid) in exactly their unit's cgroup
- * (np_sndsvc, which lord-netperm fills only while that cgroup holds that one process). A
- * process the user moves into that cgroup has another tgid, so it never matches. */
+ * Outside it only the known capture nodes count (lord-netperm keeps no-mic out of the
+ * user@ union today, so this is for a union that ever carries it). */
np_u32 minor = ctx->minor;
np_u32 *kind = bpf_map_lookup_elem(&np_snd, &minor);
np_u64 sid = bpf_get_current_ancestor_cgroup_id((int)cfg->level);
int own = sid && sid == cgid;
- if (!(kind ? *kind == NP_SND_CAPTURE : own)) return 1;
- if (!own) {
- np_u32 tgid = (np_u32)(bpf_get_current_pid_tgid() >> 32);
- np_u64 *svc = bpf_map_lookup_elem(&np_sndsvc, &tgid);
- if (svc && *svc == bpf_get_current_cgroup_id()) return 1;
- }
- need = NP_R_NO_MIC;
+ if (kind ? *kind == NP_SND_CAPTURE : own) need = NP_R_NO_MIC;
+ else return 1;
}
if (!(app->flags & need)) return 1;
report_dev(cgid, NP_D_DEV, ctx->major, ctx->minor, need);
diff --git a/server/src/netperm/np_shared.h b/server/src/netperm/np_shared.h
index 8f305bf..8d26b4b 100644
--- a/server/src/netperm/np_shared.h
+++ b/server/src/netperm/np_shared.h
@@ -17,9 +17,6 @@
* np_events RINGBUF NpEvent towards lord-netperm
* np_snd HASH ALSA minor (u32) → u32 every ALSA node in /sys/class/sound: NP_SND_CAPTURE for the
* capture PCMs (/dev/snd/pcmC*D*c), NP_SND_OTHER for the rest
- * np_sndsvc HASH tgid (u32) → cgroup id (u64) each session user's real PipeWire and WirePlumber: the one process in
- * user@<uid>/session.slice/{pipewire,wireplumber}.service, which the user@
- * union's no-mic leaves the capture nodes to
*
* Besides the network, the same per-app policy carries the device restrictions (docs/FIREWALL.md,
* "Linux apps"): "no camera", "no USB" and "no screen capture" (/dev/fb*) (cgroup/dev, by device
diff --git a/server/src/netperm/npload.h b/server/src/netperm/npload.h
index 7ca29a8..86d2285 100644
--- a/server/src/netperm/npload.h
+++ b/server/src/netperm/npload.h
@@ -22,8 +22,7 @@
X(np_seen, BPF_MAP_TYPE_LRU_HASH, sizeof(NpSeenKey), 8, NP_MAX_SEEN, 0) \
X(np_counts, BPF_MAP_TYPE_HASH, 8, sizeof(NpCount), NP_MAX_APPS, 0) \
X(np_events, BPF_MAP_TYPE_RINGBUF, 0, 0, NP_RINGBUF, 0) \
- X(np_snd, BPF_MAP_TYPE_HASH, 4, 4, NP_MAX_SND, 0) \
- X(np_sndsvc, BPF_MAP_TYPE_HASH, 4, 8, 2 * NP_MAX_SESS, 0)
+ X(np_snd, BPF_MAP_TYPE_HASH, 4, 4, NP_MAX_SND, 0)
/* Each program: its section, kind and attach point. btf: the kernel function an LSM program
* hooks (its id comes from /sys/kernel/btf/vmlinux). opt: 1 = the device and Bluetooth
diff --git a/server/src/sec/sandbox.c b/server/src/sec/sandbox.c
index 33f19e7..3338d0a 100644
--- a/server/src/sec/sandbox.c
+++ b/server/src/sec/sandbox.c
@@ -16,6 +16,7 @@
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <sched.h>
#include <signal.h>
@@ -64,7 +65,14 @@ static int drop_caps(void) {
static int ll_create(struct landlock_ruleset_attr *a, size_t n) { return (int)syscall(SYS_landlock_create_ruleset, a, n, 0U); }
static int ll_add(int fd, enum landlock_rule_type t, const void *attr) { return (int)syscall(SYS_landlock_add_rule, fd, t, attr, 0U); }
static int ll_enforce(int fd) { return (int)syscall(SYS_landlock_restrict_self, fd, 0U); }
-static int ll_abi(void) { return (int)syscall(SYS_landlock_create_ruleset, NULL, 0U, LANDLOCK_CREATE_RULESET_VERSION); }
+/* The kernel's Landlock ABI. LORD_SANDBOX_MAX_ABI (tests only) can lower it, never raise it: the
+ * only effect is that restricted apps refuse to start. */
+static int ll_abi(void) {
+ int abi = (int)syscall(SYS_landlock_create_ruleset, NULL, 0U, LANDLOCK_CREATE_RULESET_VERSION);
+ const char *cap = getenv("LORD_SANDBOX_MAX_ABI");
+ if (cap && *cap >= '0' && *cap <= '9' && atoi(cap) < abi) abi = atoi(cap);
+ return abi;
+}
static int ll_path(int rs, const char *path, uint64_t allow) {
struct landlock_path_beneath_attr pb = { .allowed_access = allow };
@@ -194,9 +202,9 @@ int sandbox_landlock_abi(void) {
}
int sandbox_apply_files(const SandboxFilesCfg *cfg) {
-#ifdef HAVE_LANDLOCK
+#if defined(HAVE_LANDLOCK) && defined(LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET)
int abi = ll_abi();
- if (abi < 1) return -1;
+ if (abi < 6) return -1; /* fail closed: abstract unix sockets must be scoped too */
uint64_t ro = LANDLOCK_ACCESS_FS_READ_FILE | LANDLOCK_ACCESS_FS_READ_DIR | LANDLOCK_ACCESS_FS_EXECUTE;
uint64_t rw = ro | LANDLOCK_ACCESS_FS_WRITE_FILE | LANDLOCK_ACCESS_FS_MAKE_DIR | LANDLOCK_ACCESS_FS_MAKE_REG |
LANDLOCK_ACCESS_FS_REMOVE_FILE | LANDLOCK_ACCESS_FS_REMOVE_DIR | LANDLOCK_ACCESS_FS_MAKE_SYM |
@@ -213,10 +221,8 @@ int sandbox_apply_files(const SandboxFilesCfg *cfg) {
struct landlock_ruleset_attr attr;
memset(&attr, 0, sizeof attr);
attr.handled_access_fs = handled;
-#ifdef LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET
/* abstract unix sockets of programs outside the app (ABI 6): refused too */
- if (abi >= 6) attr.scoped = LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET;
-#endif
+ attr.scoped = LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET;
int rs = ll_create(&attr, sizeof attr);
if (rs < 0) return -1;
/* not "/run" or "/var" as a whole: /run/media/<user> and /var/mail are the user's */
@@ -254,6 +260,30 @@ int sandbox_apply_files(const SandboxFilesCfg *cfg) {
#endif
}
+int sandbox_apply_scope(void) {
+#if defined(HAVE_LANDLOCK) && defined(LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET) && defined(LANDLOCK_SCOPE_SIGNAL)
+ int abi = ll_abi();
+ if (abi < 6) { /* fail closed: the session's abstract sockets would stay reachable */
+ static const char m[] = "sandbox: Landlock ABI < 6 (abstract unix sockets can't be scoped): not launched\n";
+ if (write(2, m, sizeof m - 1) < 0) {}
+ return -1;
+ }
+ if (apply_nopriv()) return -1;
+ struct landlock_ruleset_attr attr;
+ memset(&attr, 0, sizeof attr);
+ attr.scoped = LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET | LANDLOCK_SCOPE_SIGNAL;
+ int rs = ll_create(&attr, sizeof attr);
+ if (rs < 0) return -1;
+ int r = ll_enforce(rs);
+ close(rs);
+ return r ? -1 : 0;
+#else
+ static const char m[] = "sandbox: built without Landlock scoping: not launched\n";
+ if (write(2, m, sizeof m - 1) < 0) {}
+ return -1;
+#endif
+}
+
/* ---- the app's own view: user + mount + PID namespace (sandbox.h) ---- */
#ifndef OPEN_TREE_CLONE
@@ -330,7 +360,7 @@ int sandbox_files_isolate(const SandboxFilesCfg *cfg) {
int nk = 0;
for (int pass = 0; pass < 2; pass++) {
const char *const *list = pass ? cfg->ro : cfg->rw;
- for (int i = 0; i < SANDBOX_FILES_MAX && list[i]; i++) {
+ for (int i = 0; !cfg->keep_home && i < SANDBOX_FILES_MAX && list[i]; i++) {
if (!is_under(list[i], cfg->home) || !strcmp(list[i], cfg->home)) continue; /* outside home: Landlock alone */
struct stat st;
int t;
@@ -360,7 +390,7 @@ int sandbox_files_isolate(const SandboxFilesCfg *cfg) {
}
int bad = 0;
const char *opts = "mode=0700,size=64m";
- bad |= mount("tmpfs", cfg->home, "tmpfs", MS_NOSUID | MS_NODEV, opts);
+ if (!cfg->keep_home) bad |= mount("tmpfs", cfg->home, "tmpfs", MS_NOSUID | MS_NODEV, opts);
if (cfg->runtime_dir) bad |= mount("tmpfs", cfg->runtime_dir, "tmpfs", MS_NOSUID | MS_NODEV, "mode=0700,size=8m");
bad |= mount("tmpfs", "/tmp", "tmpfs", MS_NOSUID | MS_NODEV, "mode=1777");
struct stat vt;
@@ -373,7 +403,7 @@ int sandbox_files_isolate(const SandboxFilesCfg *cfg) {
if (!bad) bad |= mount("/dev/pts/ptmx", "/dev/ptmx", NULL, MS_BIND, NULL);
for (int i = 0; i < nk && !bad; i++) {
if (bind_clone(keep[i].fd, keep[i].path, keep[i].dir)) { bad = 1; break; }
- if (keep[i].ro) mount(NULL, keep[i].path, NULL, MS_REMOUNT | MS_BIND | MS_RDONLY | MS_NOSUID | MS_NODEV, NULL);
+ if (keep[i].ro && mount(NULL, keep[i].path, NULL, MS_REMOUNT | MS_BIND | MS_RDONLY | MS_NOSUID | MS_NODEV, NULL)) { bad = 1; break; }
}
for (int i = 0; i < nk; i++) close(keep[i].fd);
/* the working directory again, inside the view: the one inherited still points into the real
diff --git a/server/src/sec/sandbox.h b/server/src/sec/sandbox.h
index 0a6eb2d..d55aac6 100644
--- a/server/src/sec/sandbox.h
+++ b/server/src/sec/sandbox.h
@@ -94,6 +94,11 @@ typedef struct {
* again without following any symlink and only if it is still the same inode the launcher checked */
const char *opened;
unsigned long long opened_dev, opened_ino;
+ /* 1: the view without the home restriction (no-mic, no-camera, no-usb, no-bluetooth): the home
+ * folder stays as it is and rw[]/ro[] are unused; everything else (runtime dir with only
+ * sockets[], private /tmp, /var/tmp, /dev/shm, devpts, /proc, PID and IPC namespaces) is the
+ * same. Then sandbox_apply_scope instead of sandbox_apply_files. */
+ int keep_home;
} SandboxFilesCfg;
/* Before sandbox_apply_files: the app's own view of the system, so no unix socket of the session
@@ -115,6 +120,11 @@ typedef struct {
* app. Doesn't allocate. */
int sandbox_files_isolate(const SandboxFilesCfg *cfg);
int sandbox_apply_files(const SandboxFilesCfg *cfg);
+/* For keep_home views: Landlock with no filesystem rules, only its scoping (ABI 6): no abstract
+ * unix socket and no signal outside the app (the view has no network namespace, so abstract
+ * sockets are shared with the session). Sets no_new_privs. 0 applied (or a kernel without ABI 6:
+ * logged, nothing else to do), -1 failed. */
+int sandbox_apply_scope(void);
/* Landlock ABI of the running kernel (0 = none). */
int sandbox_landlock_abi(void);
diff --git a/server/src/ui/js_sys.c b/server/src/ui/js_sys.c
index ffa49e4..844017a 100644
--- a/server/src/ui/js_sys.c
+++ b/server/src/ui/js_sys.c
@@ -1414,6 +1414,12 @@ static JSValue f_apps_launch(JSContext *c, JSValueConst this_val, int argc, JSVa
return JS_NewBool(c, ok);
}
+/* lord.apps.lastError(): the error code of the last refused launch ("" if none), no arguments */
+static JSValue f_apps_last_error(JSContext *c, JSValueConst this_val, int argc, JSValueConst *argv) {
+ (void)this_val; (void)argc; (void)argv;
+ return JS_NewString(c, apps_last_error());
+}
+
/* ---- lord.apps: native LordOS app packages (.lpk, lpk.c) ---- */
#define LPK_JS_MAX (16 * 1024 * 1024)
@@ -1790,6 +1796,7 @@ static const JSCFunctionListEntry apps_funcs[] = {
JS_CFUNC_DEF("linux", 1, f_apps_linux),
JS_CFUNC_DEF("launch", 1, f_apps_launch),
JS_CFUNC_DEF("launchWith", 2, f_apps_launch_with),
+ JS_CFUNC_DEF("lastError", 0, f_apps_last_error),
JS_CFUNC_DEF("packages", 0, f_apps_packages),
JS_CFUNC_DEF("inspectPackage", 1, f_apps_inspect),
JS_CFUNC_DEF("installPackage", 1, f_apps_install),
diff --git a/server/tests/fwlinux/files.sh b/server/tests/fwlinux/files.sh
index 7623b06..10a6bd6 100755
--- a/server/tests/fwlinux/files.sh
+++ b/server/tests/fwlinux/files.sh
@@ -98,6 +98,30 @@ probe ~/.config
expect write_autostart "@(Permission denied|No such file|Read-only)*"
[ -e ~/.config/autostart/fwlinux.desktop ] && bad "an autostart entry was written through ~/.config" || ok "~/.config was not granted writable"
+for r in no-mic no-camera no-usb no-bluetooth; do
+ echo "3c. $r alone: its home stays, but not the session bus nor the user manager (no escape from its scope)"
+ restrict desktop:fwprobe $r
+ probe
+ expect read_documents ok
+ expect write_own_config ok
+ expect connect_session_bus "No such file"
+ expect connect_systemd_private "No such file"
+ expect connect_pipewire_manager "No such file"
+ expect cwd_relative_bus "No such file"
+ expect connect_pipewire ok
+ expect connect_tmp_socket "No such file"
+ expect read_session_shm "No such file"
+ expect systemd_run_user "exit"
+ [ -e ~/.cache/fwprobe/escaped ] && bad "$r: a process escaped through the user manager" || ok "$r: nothing started through the user manager"
+ # its home is its own to write (startup files too: see docs/FIREWALL.md, the residual risk)
+ rm -f ~/.config/autostart/fwlinux.desktop ~/.local/share/applications/fwlinux-evil.desktop ~/.cache/fwprobe/escaped
+done
+echo "3d. a restricted app on a kernel whose Landlock can't scope abstract sockets: not launched"
+rm -f "$OUT"
+LORD_SANDBOX_MAX_ABI=5 WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/$U "$CLI" fwprobe >/dev/null 2>&1 && bad "launched with Landlock ABI 5" || ok "refused with Landlock ABI 5"
+sleep 1; [ -s "$OUT" ] && bad "the app ran with Landlock ABI 5" || ok "the app did not run"
+restrict desktop:fwprobe no-files
+
echo "4. malicious .desktop files: names chosen to reach other programs' folders"
EVIL=/usr/local/lib/lordos-tests/files_probe.py # a system path: these ids get no folders of their own
sudo install -D -m 644 "$D/files_probe.py" "$EVIL"
diff --git a/server/tests/fwlinux/mic.sh b/server/tests/fwlinux/mic.sh
index 1e1460b..5e197f6 100755
--- a/server/tests/fwlinux/mic.sh
+++ b/server/tests/fwlinux/mic.sh
@@ -157,18 +157,6 @@ if command -v systemd-run >/dev/null && [ -d "$UM" ]; then
done
for d in session.slice/pipewire.service session.slice/wireplumber.service session.slice ""; do rmdir "$UM/fwfake.scope/$d" 2>/dev/null; done
rm -f "$f"
- CAPN=$(ls /dev/snd/pcmC*D*c 2>/dev/null | head -1)
- if [ -n "$CAPN" ] && [ -S /run/lordos/netperm.sock ]; then
- got=$(timeout 10 systemd-run --user --pipe --quiet python3 -c 'import os,sys,errno
-try: os.close(os.open(sys.argv[1], os.O_RDONLY | os.O_NONBLOCK)); print("ok")
-except OSError as e: print(errno.errorcode.get(e.errno))' "$CAPN" 2>&1 | tail -1)
- [ "$got" = EPERM ] && ok "escaped with systemd-run --user, open $CAPN → EPERM" || bad "escaped open of $CAPN → $got"
- got=$(timeout 10 systemd-run --user --scope -q bash -c 'P=$1/user@$2.service/session.slice/pipewire.service; echo $$ > $P/cgroup.procs 2>/dev/null; exec python3 -c "import os,sys,errno
-try: os.close(os.open(sys.argv[1], os.O_RDONLY | os.O_NONBLOCK)); print(\"ok\")
-except OSError as e: print(errno.errorcode.get(e.errno))" "$3"' _ /sys/fs/cgroup/user.slice/user-$U.slice "$U" "$CAPN" 2>&1 | tail -1)
- [ "$got" = EPERM ] && ok "moved into PipeWire's own cgroup, open $CAPN → EPERM" || bad "moved into pipewire.service, open → $got"
- sleep 1.5 # lord-netperm sees PipeWire alone in its cgroup again
- fi
f=$OUTD/um.raw
timeout 10 systemd-run --user --scope -q timeout 3 pw-record --rate 48000 --channels 1 --format s16 "$f" >/dev/null 2>&1
n=$(stat -c %s "$f" 2>/dev/null || echo 0)