XK0-005 · Question #10540
The security team has identified a web service that is running with elevated privileges. A Linux administrator is working to change the systemd service file to meet security compliance standards…
The correct answer is C. Adding the User=webservice to the [Service] section of the service file. To prevent a systemd web service from running with elevated privileges, the administrator should explicitly configure it to run as an unprivileged user.
Question
Options
- ARemoving the ExecStart=/usr/sbin/webserver -D $OPTIONS from the service file
- BUpdating the EnvironmentFile line in the [Service] section to /home/webservice/config
- CAdding the User=webservice to the [Service] section of the service file
- DChanging the multi-user.target in the [Install] section to basic.target
How the community answered
(29 responses)- A10% (3)
- B3% (1)
- C79% (23)
- D7% (2)
Why each option
To prevent a systemd web service from running with elevated privileges, the administrator should explicitly configure it to run as an unprivileged user.
Removing `ExecStart` would prevent the service from starting altogether, which is not a solution for privilege reduction but service disablement.
Updating the `EnvironmentFile` path only changes the source for environment variables; it does not alter the user context under which the service runs.
Adding `User=webservice` to the `[Service]` section of the systemd unit file explicitly instructs systemd to run the `ExecStart` command as the `webservice` user, thereby preventing the service from executing with root or other elevated privileges and improving security compliance.
Changing `WantedBy=multi-user.target` to `basic.target` modifies the boot target dependencies, affecting when the service starts, but has no impact on the user privileges of the running service.
Concept tested: Systemd service user configuration
Source: https://www.freedesktop.org/software/systemd/man/systemd.exec.html#User=
Topics
Community Discussion
No community discussion yet for this question.