SKY-D333 · Deployment and infrastructure
Edge systemd service runs as root
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 towardmax_highandmax_security; the detector never reports CRITICAL. - Finding type
- review
- Catalog name
- Systemd edge service runs as root
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
[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.targetWhat Skylos leaves alone
[Unit]Description=Nightly sales report mailer [Service]Type=oneshotExecStart=/usr/local/bin/report-mailer --to finance@example.comWhy 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
- Runs with
--danger. Reads every*.servicefile outside.git,.venv,venv,node_modules,build,distand cache folders, skipping symlinks and files over 500 KB. - Parses the unit into sections and
Key=valuelines, joining lines that end in\. Lines starting with#or;are comments. - Needs a
[Service]section and an edge context: the file name or any value in any section contains one ofcamera,can0,cuda,gpio,gpiochip,i2c,jetson,l4t,nvargus,nvidia,robot,ros2,roslaunch,spidevorv4l2, or the text/dev/,--device,--runtime=nvidiaornetwork=host. - Treats the service as root when
[Service]has noUser=, or when the lastUser=is empty,0orroot.DynamicUser=is not read. - Reports HIGH on the
User=line, or on theExecStart=line when there is noUser=.
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.
[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.targetWhen it can be wrong
DynamicUser=yeswithout aUser=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/nullin 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=, orExecStart=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.