Linux Labs

Server security / Stage 7 of 10 · step 5 of 6

The service can do anything

medium ~25 min
Not running Starting usually ~20 s
Report a problem

Situation

The lab-tickets service — the tickets-api application — takes helpdesk tickets. Its unit was written in a hurry: the service runs as root, and nothing stops it from doing anything root can do. The security review is next week, and systemd-analyze security lab-tickets.service rates the service 9.6 UNSAFE right now.

The tickets live in /var/lib/tickets, the API key in /etc/tickets/api.key. The package created the tickets account for the service, but nobody ever put it into the unit. How to talk to the service is described in /usr/share/doc/tickets-api/README:

curl -s http://127.0.0.1:8097/health
key=$(sudo cat /etc/tickets/api.key)
curl -s -H "X-Api-Key: $key" http://127.0.0.1:8097/tickets

Task

  1. lab-tickets is running and enabled: the earlier tickets are in place, and a new ticket (POST /tickets) is saved in /var/lib/tickets. The application code stays the same.
  2. The service process does not run as root, has no privileges and runs with NoNewPrivileges=yes. The API key can be read by root and by the service itself — nobody else.
  3. ProtectSystem=strict: the service cannot write to /etc, /usr, /var/lib, /var/log or /opt.
  4. systemd-analyze security lab-tickets.service — 4.9 or lower, rated OK.

There is no internet on the machine; everything you need is already installed. Run administrative commands with sudo.

Visible only to you. Saved as you type.

All notes

Lab goals

0 of 4
  • lab-tickets is running and enabled, the earlier tickets are in place, a new one is saved in /var/lib/tickets; the application code is unchanged — not checked yet
  • The service process is not root, has no privileges and runs with NoNewPrivileges; an outside user cannot read the API key — not checked yet
  • ProtectSystem=strict is in effect — the service cannot write to /etc, /usr, /var/lib, /var/log or /opt — not checked yet
  • systemd-analyze security lab-tickets.service — 4.9 or lower (rated OK) — not checked yet

Hints

0 of 3 open · they open one at a time
Hint 1
Show the solution after 3 failed checks

Leave the lab?

The machine keeps running for 10 more minutes, then it is removed. Files are lost; completed goals stay.

Loading…