Service configuration writes
The packaged and CLI-installed units use ProtectSystem=strict. The daemon can
write these configuration directories when they exist:
| Directory | Runtime writer |
|---|---|
/etc/csm | CSM configuration and fragments |
/etc/audit | CSM audit rules and augenrules generated configuration |
/etc/modprobe.d | Repair of an existing, opted-in AF_ALG mitigation marker |
/etc/apache2/conf.d | cPanel Apache/LiteSpeed challenge snippet, virtual patches, and default overrides |
/etc/apache2/conf-enabled | Debian Apache challenge snippet |
/etc/httpd/conf.d | RHEL Apache challenge snippet |
/etc/nginx/conf.d | Nginx challenge snippet |
/usr/local/apache/conf | Legacy Apache virtual patches and overrides |
/usr/local/lsws/conf/templates | Standalone LiteSpeed challenge template |
The other state, quarantine, account, spool and cPanel plugin grants remain in
place. Optional directory grants tolerate absent software. Install the relevant
web server before starting CSM; restart CSM after creating a previously absent
granted directory. Custom ModSecurity override locations require a drop-in that
grants only their parent directory, followed by systemctl daemon-reload and
systemctl restart csm.service. Atomic replacement requires a directory grant.
See custom account roots for account grants.
The installer generates the unit for the systemd it finds. systemd 239 (EL8,
CloudLinux 8) does not know ProtectHostname, ProtectKernelLogs or
ProtectClock; it would log “Unknown lvalue” for each at every start and
ignore them, so the installer leaves them out there and prints which ones it
omitted. Newer systemd receives the full unit, identical to the packaged one.
A binary-swap upgrade keeps the existing unit; run csm install to regenerate
it.
The daemon cannot write arbitrary files directly under /etc, SSH configuration,
account databases, or systemd unit files. The AF_ALG seccomp drop-in is installed
by the operator’s csm harden CLI, outside the daemon. Periodic AF_ALG module
removal uses a bounded transient service with fixed module names; the daemon
retains ProtectKernelModules=yes and the module syscall restriction.
Exim transactions
The forward guard sends one bounded JSON request over stdin to its own executable
in a transient service. The helper accepts only apply/remove operations and policy
data. It accepts no paths, command names or shell programs. Applying or removing
the managed Exim block, the cPanel rebuild, and rollback all run outside the
daemon mount namespace. Operator configuration is preserved. Lookup refreshes
remain under /var/lib/csm and do not rebuild Exim.
The helper requires root. An exclusive process lock rejects overlapping config transactions without modifying Exim; the daemon reports the failure, and the operator can reload after the earlier transaction finishes. Its lifetime is bounded, and a failed command is never retried as an unsandboxed duplicate. Existing fixed Exim queue/query operations also use transient services. If the systemd bus is unavailable, the existing wrapper attempts direct execution once; inside the service, restricted writes then fail and are reported. A scope unit is unsuitable because it inherits the calling process’s sandbox.
Parse worker units
The daemon reads tenant zip listings for the phishing-kit check, and unpacks
email attachments when email AV is on, in separate workers. Each starts on
demand as a transient unit with systemd-run: one unit for zip listings, and
one per email_av.scan_concurrency slot for mail. Each unit gets these
properties:
DynamicUser=yes,CapabilityBoundingSet=(empty),NoNewPrivileges=yes;PrivateNetwork=yes,RestrictAddressFamilies=AF_UNIX;ProtectSystem=strict,ProtectHome=yes,PrivateTmp=yes,PrivateDevices=yes,ProtectKernelTunables=yes,ProtectKernelModules=yes,ProtectControlGroups=yes,RestrictNamespaces=yes,RestrictRealtime=yes,MemoryDenyWriteExecute=yes,UMask=0077;SystemCallFilter=@system-serviceandSystemCallFilter=~personality, withSystemCallErrorNumber=EPERM. The personality deny stands in forLockPersonality=yes, whichsystemd-runon systemd 239 rejects;MemoryAccounting=yes,MemoryLimit=andMemoryMax=set to the worker’s memory cap,MemorySwapMax=0;TasksMax=64,LimitNOFILE=256,LimitCORE=0,CPUWeight=50, and a one-hourRuntimeMaxSec.LimitFSIZE=is 64 MiB for zip listings; for mail it is 1 MiB aboveemail_av.max_attachment_size, and never below 64 MiB;OOMScoreAdjust=1000, making parse workers preferred victims under host memory pressure, andSlice=set to a slice of its own per unit name prefix directly undersystem.slice, for examplesystem-csm\x2dparse\x2dworker\x2dmail0.slice. The slices stay after their units end; they contain no processes but retain their accounting metadata.InaccessiblePaths=-for each account home volume thatProtectHome=yesdoes not cover: the account roots outside/home(for example/var/www/vhostson Plesk) and the sibling volumes registered cPanel accounts live on, such as/home2. The list is read once when the daemon sets up its workers, or whencsm scanstarts one.
Before launching a worker, CSM sets its slice’s runtime CPUWeight=50
through systemd. CPU weights compare siblings: the service’s weight alone
would not limit its share against the daemon outside that slice. Slice setup
shares the worker’s startup timeout, and a failure prevents the launch.
Empty slices and their runtime settings remain until reboot.
On cgroup v2, a replacement waits for earlier units in its slice to disappear before taking the slice’s OOM snapshot. If they outlive the startup timeout, the replacement gets no request and reports a startup failure.
The zip worker receives the zip as an open descriptor and returns entry names
in a sealed memfd. A mail worker receives the message’s spool header and body
as open descriptors and returns each attachment in its own sealed memfd; the
daemon scans those and closes them. It cannot create IPv4 or IPv6 sockets. Unix sockets remain
available. /home, /root, /run/user and the account home volumes listed
above are hidden; an account volume created after the daemon started is not
hidden until it restarts. Most host files are read-only. The worker can still read
world-readable host files outside those directories and write in its private
temporary directories. The daemon does not forward its environment to the
unit; systemd supplies the service environment.
A worker’s standard error reaches the daemon’s log through a pipe, never directly. Each line is cut to 512 bytes and quoted, so control characters and newlines cannot forge log lines, and at most 256 lines or 64 KiB of log entries are logged per worker unit; after that one “further output dropped” line is logged and the rest is discarded. Error text in a worker’s reply is quoted the same way. When the launcher exits, final diagnostics drain for at most one second. The log reader then closes even if another process still holds its writer.
MemoryLimit caps RAM only on cgroup v1, so the daemon also writes
memory.memsw.limit_in_bytes in the unit’s own memory cgroup, or
memory.swappiness=0 where there is no swap accounting. On cgroup v2 it sets
memory.swap.max to 0, and refuses to use a worker on a host with swap on but
no swap accounting. The daemon can write those files because csm.service
has ProtectControlGroups=no. A worker whose memory cannot be capped or
measured gets no request: the phishing check reports itself incomplete, and
mail is handled as an incomplete scan under email_av.fail_mode.
Without cgroup v2 swap accounting, the watchdog also checks that swap stays
off throughout the worker’s lifetime.
The unit runs the daemon’s own binary as its dynamic user, so the binary is
installed as mode 0711: others can execute it but not read it, and only root
can replace it. Package, CLI and script installs set this mode under any umask
and make the installation directory searchable by others; its subdirectories
keep their private modes. A rolled-back upgrade restores the previous mode.
When the binary or a directory above it is not executable by others, the
daemon logs one line at startup, raises a Critical
email_av_isolation_unavailable finding, and starts no worker. The phishing
check reports itself incomplete, and mail is handled as an incomplete scan
under email_av.fail_mode. Failed unit starts raise the same finding, at most
once an hour. This includes starts refused because the daemon has exhausted
its descriptors; those failures do not open the worker breaker. Mail and zip
workers share this allowance across spool watcher replacements. A finding
rejected by a full alert queue leaves the allowance available for a retry.
Workers are killed by unit name with systemctl kill, never by a PID. If the
daemon dies, a worker waiting for a request reads end of file and exits. A
worker stuck parsing may remain until the lifetime cap stops it. At startup,
the daemon attempts to kill leftover csm-parse-worker-* units; cleanup
failures are logged and do not prevent startup.
A worker the daemon stops on purpose, such as at shutdown, is logged as
stopped and never as a memory failure.
disabled_checks: [phishing] disables scheduled phishing checks. Requested
account scans can still use the worker, and startup cleanup still runs.
email_av.enabled: false starts no mail workers.
The PHP taint worker runs in the same kind of unit, named
csm-phptaint-worker-<generation>, with a 512 MiB memory cap and no file
writes. At startup the daemon attempts to kill leftover csm-phptaint-worker-*
units. The binary’s permissions are checked before each worker launch. If
the dynamic user cannot execute it, the daemon logs why and candidate files
are reported as not analyzed, just as when a unit fails to start or dies.
These failures appear as worker_failure coverage gaps. disabled_checks: [php_taint_deep] stops new analyses; startup cleanup still runs.
YARA-X runs in two units of the same kind. Each rule compile runs in
csm-yara-compile-worker-<generation> with a 1 GiB memory cap, from rule
text the daemon passes in memory; the compiler cannot open include files.
Scans run in one csm-yara-worker-<generation> with a memory cap of 512 MiB
plus the larger of thresholds.full_scan_max_file_mb and, with mail scanning
on, email_av.max_attachment_size, no file writes and the compiled rules
loaded from memory. A reload that changes the file cap applies to the next
scan worker. Both allow executable memory, which YARA-X needs for its
compiled rules; the other lockdown properties are unchanged. At startup the
daemon attempts to kill leftover units of both kinds. While no worker can
scan, files and mail attachments are reported as not scanned by YARA, never
as clean. signatures.yara_worker_enabled: false runs YARA-X inside the
daemon as root instead; csm validate warns about it.
The in-process csm scan <user> command starts its own worker on demand.
Its unit prefix includes the CLI process ID, so concurrent scans use distinct
slices and cannot attribute another scan’s OOM kill to their own worker.
Its report warns when worker setup, startup or archive listing fails, even
if later archives are checked successfully. A scan with unchecked archives
does not report the account as clean.
Limits and validation
These restrictions reduce accidental and misdirected writes. CSM remains a privileged root daemon: fanotify, firewall administration, BPF, process inspection and remediation require elevated privileges. The unit retains its current capabilities, and root access to the system bus permits transient services. This is not a complete boundary against arbitrary code execution as root. Reducing capabilities or separating privileged operations behind a separately permissioned broker requires its own feature and kernel compatibility review.
scripts/systemd-account-roots-test.sh runs the actual packaged sandbox in a
disposable systemd environment. It checks unrelated /etc writes return EROFS,
managed directory atomic replacement, ModSecurity overrides, and Exim helper
apply/remove/rollback using a fixed command fixture. It also exercises account
quarantine, restore and process signaling. The Exim fixture validates the helper
transport and filesystem behavior; it does not validate a real cPanel rebuild.
The cPanel release tests exercise real daemon restarts and require a licensed image
and a live run to establish that platform’s acceptance.