Skip to main content

SKY-D333 · Deployment and infrastructure

Edge systemd service runs as root

High

A systemd service for a robot, camera, GPU or other device that runs as root, either because it sets User=root or because it sets no User= at all. systemd starts services as root unless told otherwise.

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 edge service runs as root
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Device daemons parse input from sensors, serial lines and the network. A bug in one that runs as root hands the whole device to an attacker, including its keys, its updates and every other process on it.

What Skylos flags

arm-controller.service · INIReported on line 6
[Unit]Description=Robot arm controllerAfter=network-online.target [Service]ExecStart=/opt/arm-controller/bin/arm-controller --port /dev/ttyUSB0Restart=on-failureNoNewPrivileges=trueProtectSystem=strictPrivateTmp=true [Install]WantedBy=multi-user.target

What Skylos leaves alone

report-mailer.service · INI
[Unit]Description=Nightly sales report mailer [Service]Type=oneshotExecStart=/usr/local/bin/report-mailer --to finance@example.com

Why Skylos leaves it alone

This service also runs as root, but nothing in it points to a device: no /dev/ path, no camera, GPU, robot or bus word. The rule only checks edge and device services, so it stays quiet.

How Skylos decides

  1. Runs with --danger. Reads every *.service file outside .git, .venv, venv, node_modules, build, dist and cache folders, skipping symlinks and files over 500 KB.
  2. Parses the unit into sections and Key=value lines, joining lines that end in \. Lines starting with # or ; are comments.
  3. Needs a [Service] section and an edge context: the file name or any value in any section contains one of camera, can0, cuda, gpio, gpiochip, i2c, jetson, l4t, nvargus, nvidia, robot, ros2, roslaunch, spidev or v4l2, or the text /dev/, --device, --runtime=nvidia or network=host.
  4. Treats the service as root when [Service] has no User=, or when the last User= is empty, 0 or root. DynamicUser= is not read.
  5. Reports HIGH on the User= line, or on the ExecStart= line when there is no User=.

How to fix it

Run the service as its own user and give that user only the device groups it needs, here dialout for the serial port.

arm-controller.service · INI · the fix, against the flagged file
[Unit]Description=Robot arm controllerAfter=network-online.target [Service]Added: User=robotAdded: Group=dialoutExecStart=/opt/arm-controller/bin/arm-controller --port /dev/ttyUSB0Restart=on-failureNoNewPrivileges=trueProtectSystem=strictPrivateTmp=true [Install]WantedBy=multi-user.target

When it can be wrong

  • DynamicUser=yes without a User= line still counts as root, even though systemd then runs the service under a fresh unprivileged user.
  • The edge test is a text search over every value, so any unit that mentions /dev/ counts as a device service; a /dev/null in a shell command is enough.
  • Root services with no 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 (User=, or ExecStart= without one). systemd reads # only at the start of a line, so do not append it to a value.

    INI
    # skylos: ignore[SKY-D333] needs root for real-time schedulingExecStart=/opt/arm-controller/bin/arm-controller --port /dev/ttyUSB0
  • [tool.skylos] ignore = ["SKY-D333"] turns the rule off for the project.

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