The lab-preview service serves reports from /srv/reports over the network. It was installed as is, and at start it writes a self-check to the journal: who it runs as and what it can reach. Read that line, then look at the service's score.
See who lab-preview runs as
Read the self-check line in the lab-preview journal, then its score from systemd-analyze security.
First, predict
lab-preview serves ready-made reports over the network. Which user did systemd start it as?
Now start the exercise, run the command and compare your prediction with the output.
The lab-preview service runs as root and reads /etc/shadow. Why did systemd start it that way?
-
Port 8095 is above 1024 — any user can open it. Check: the same program as an ordinary user listens on it too.
-
Some image services run as their own users.
systemctl show -p User postgresqlshows a non-root one. -
The report files are 644, readable by anyone:
ls -l /srv/reports. The service did not get root because of them.
The unit has no User=, so the service ended up as root with all of root's powers.