Skip to main content

SKY-D336 · Deployment and infrastructure

Edge systemd service with broad capabilities or devices

High

An edge or device systemd service that grants powerful Linux capabilities such as CAP_SYS_ADMIN, allows every device with a DeviceAllow= wildcard, or starts a docker run --privileged container. These settings give a non-root process most of root's power.

Languages
systemd units
Quality gate
counted toward the gate limits (full and diff scans). Reported under security (danger). It counts toward max_high and max_security; the detector never reports CRITICAL.
Finding type
review
Catalog name
Systemd broad edge service privilege
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

CAP_SYS_ADMIN alone lets a process mount filesystems, change namespaces and often escape to full root. A camera daemon rarely needs it, so a bug in that daemon becomes a takeover of the device.

What Skylos flags

camera-capture.service · INIReported on line 7
[Unit]Description=Camera capture [Service]User=cameraExecStart=/opt/capture/bin/capture --device /dev/video0AmbientCapabilities=CAP_SYS_ADMINDeviceAllow=/dev/video0 rwNoNewPrivileges=true

What Skylos leaves alone

camera-capture.service · INI
[Unit]Description=Camera capture [Service]User=cameraExecStart=/opt/capture/bin/capture --device /dev/video0CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_MODULEDeviceAllow=/dev/video0 rwNoNewPrivileges=true

Why Skylos leaves it alone

CAP_SYS_ADMIN still appears, but after a leading ~, which tells systemd to remove these capabilities from the service. That is a hardening setting, not a grant.

How Skylos decides

  1. Runs with --danger. Reads the same *.service files as SKY-D333 and needs the same [Service] section and edge context (a device, camera, GPU or robot word, or a /dev/ path, somewhere in the unit). Unlike SKY-D333 to SKY-D335, it does not need the service to run as root.
  2. Reports AmbientCapabilities= or CapabilityBoundingSet= naming CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_SYS_MODULE, CAP_SYS_PTRACE, CAP_SYS_RAWIO or CAP_DAC_OVERRIDE. A bounding set that starts with ~ is skipped.
  3. Reports DeviceAllow= set to *, /dev/*, char-* or block-* (or starting with one of those).
  4. Reports an Exec…= line that runs docker run with --privileged.
  5. Reports HIGH once per unit: on the first matching capability or DeviceAllow= line, or, when there is none, on the docker run line.

How to fix it

Grant only the capability the program really uses (here real-time scheduling) and keep DeviceAllow= to the one device.

camera-capture.service · INI · the fix, against the flagged file
[Unit]Description=Camera capture [Service]User=cameraExecStart=/opt/capture/bin/capture --device /dev/video0Removed: AmbientCapabilities=CAP_SYS_ADMINAdded: AmbientCapabilities=CAP_SYS_NICEDeviceAllow=/dev/video0 rwNoNewPrivileges=true

When it can be wrong

  • A CapabilityBoundingSet= that lists only the dangerous capability the service needs is reported even though it narrows the set.
  • Other broad grants, such as CAP_SYS_BOOT, CAP_BPF or PrivateDevices=no, are not on the list and are not reported.
  • Units without a device context are never checked.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • Put the marker on a comment line directly above the reported line. systemd reads # only at the start of a line.

    INI
    # skylos: ignore[SKY-D336] vendor SDK mounts a debugfs nodeAmbientCapabilities=CAP_SYS_ADMIN
  • [tool.skylos] ignore = ["SKY-D336"] turns the rule off for the project.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.