Sandbox Unblock

Sandbox Unblock

Paste a systemd unit and the error it logged. See the sandbox line that likely blocked it and get a drop-in that re-opens only that, keeping the rest of the hardening.

Output of systemctl cat <name>, every file it prints.

Output of journalctl -u <name> or systemctl status <name>, around the failure.

Ctrl + Enter diagnoses

Paste the unit and its log, then press Diagnose.

You get the sandbox line that likely blocked the service, quoted from its file, and a drop-in that re-opens only that. If the log does not show enough, it says so instead of guessing.

How this works

The rules are fixed and checked against systemd.exec(5). A rule fires only when the log shows its error and the unit has the setting that causes it.

  1. Read-only file system: EROFS on a path under ProtectSystem=, ReadOnlyPaths= or InaccessiblePaths=.
  2. Home directory hidden: A permission, not-found or read-only error under /home, /root or /run/user with ProtectHome=.
  3. Namespace setup failed: status=226/NAMESPACE with a missing path that a path or bind setting names.
  4. System call blocked: status=31/SYS with SystemCallFilter= set.
  5. Executable memory denied: A segfault or failed executable mmap with MemoryDenyWriteExecute=yes.
  6. Address family blocked: EAFNOSUPPORT with RestrictAddressFamilies= set.
  7. Device hidden: A failed open under /dev with PrivateDevices=yes.
  8. Capability dropped: status=218/CAPABILITIES, or Operation not permitted naming a CAP_*, with CapabilityBoundingSet= set.

DynamicUser=yes implies ProtectSystem=strict and ProtectHome=read-only. When one of those is the cause, the finding says so.

Worked examples

Read-only file system (php-fpm)
php-fpm[812]: PHP Warning:  file_put_contents(/srv/app/cache/x.php): failed to open stream: Read-only file system in /srv/app/index.php on line 14

ProtectSystem=strict, set by a drop-in, blocks the cache write. One ReadWritePaths= line opens that folder.

status=226/NAMESPACE (dnscrypt-proxy)
systemd[4120]: dnscrypt-proxy.service: Failed to set up mount namespacing: /run/foo: No such file or directory

ReadWritePaths= names a folder that is missing. A "-" prefix lets the service start without it.

status=31/SYS (usbguard)
systemd[1]: usbguard.service: Main process exited, code=killed, status=31/SYS

The filter killed it but the log names no call. You get the line and how to find the call, no drop-in.

What it does

Distro packages now ship services with ProtectSystem=, PrivateDevices=, SystemCallFilter= and friends. When one of them blocks something the service needs, the log says Read-only file system or status=31/SYS and nothing about which line did it. This page reads the effective unit, drop-ins included, matches the log against a fixed set of rules and quotes the line it implicates. The drop-in it writes changes only that, so the rest of the sandbox stays on.

How to use it

  1. Run systemctl cat <name> and paste everything it prints into Unit.
  2. Run journalctl -u <name> -n 50 and paste the lines around the failure into Log.
  3. Press Diagnose, read the quoted line, then save the drop-in and run the test commands.

What it does not do

Questions

Why a drop-in and not editing the unit?

Package updates overwrite the unit file. A drop-in in /etc/systemd/system/<name>.service.d/ survives them and is one file to delete.

Why does it sometimes give no drop-in?

A seccomp kill rarely names the syscall, and an address-family error rarely names the family. Guessing would open more than needed, so it shows the line and, for a seccomp kill, the commands that find the missing name.

Does the drop-in turn the sandbox off?

No. It changes only what the finding names: usually one setting or one added entry. A list that has to be rewritten is cleared and written back in full.

Is my unit or log sent anywhere?

No. It is read in this page and gone when you close the tab.

See it work

A read-only cache dir, traced to ProtectSystem=strict in a drop-in, with a one-line fix.
A read-only cache dir, traced to ProtectSystem=strict in a drop-in, with a one-line fix.
Two causes in one log, each with its own line, merged into one drop-in.
Two causes in one log, each with its own line, merged into one drop-in.
A seccomp kill that names no syscall: the filter line, and how to find the call, not a guess.
A seccomp kill that names no syscall: the filter line, and how to find the call, not a guess.

More pictures, and how Unit Forge works