This is a proposed Change for Fedora Linux.
This document represents a proposed Change. As part of the Changes process, proposals are publicly announced in order to receive community feedback. This proposal will only be implemented if approved by the Fedora Engineering Steering Committee.
Improve security by enabling some of the high level systemd security hardening settings that isolate and sandbox default system services.
systemd provides a number of settings that can harden security for services. We are selecting a few high level ones to enable by default on a service by service basis as suitable for that particular service.
If we want to go further, we could also consider:
We will aim to cover all the default system services as well as some of the high profile services such as Nginx or PostgreSQL. All of these settings need to be configured on a per service basis instead of using a global override to facilitate fine tuning the settings based on service requirements and limit the impact for users on upgrades. Certain services have a very targeted scope. For instance, a service that only needs to read or write from only one directory could leverage more fine grained settings to restrict access even further. We will enable as many of these as feasible for the services but not every knob is going to be applicable to every service. For example,
PrivateNetwork=yes can only be used for services that does not need network connectivity by default. We have to choose between
User if either is feasible for the service to use. As a base starting point, from Fedora 39 workstation, we have the following system services installed by default which should considered within the scope of the change (excluding systemd associated ones which already have a number of these security settings enabled). We may also consider doing this for some of the high profile services including say Nginx and PostgreSQL permitting time considerations and other contributors if any joining this effort. We will prioritize critical or long running services.
(opens a user shell that must be able to do arbitrary stuff)
(opens a user shell that must be able to do arbitrary stuff)
(this can do arbitrary stuff)
We will also coordinate with upstream following Patch status :: Fedora Docs and encourage package maintainers to upstream these changes. Systemd will ignore any of these settings it does not understand on older versions. Hence this should be safe for upstream to merge on any services.
Fedora services will get a significant security boost by default by avoiding or mitigating any unknown security vulnerabilities in default system services.
- Proposal owners: Individual per service pull requests to enable various security features as applicable.
- Other developers: Review PRs as needed
- Release engineering: Issue #11785: Impact check for SystemdSecurityHardening - releng - Pagure.io
- Policies and guidelines:
Packaging guidelines will have to be modified to add recommendations to use more of the systemd security features by default. In particular, we should add a security settings section in Packaging:Systemd - Fedora Project Wiki. Current the guidance only recommends a couple of settings for long running services. Sample text:
Systemd services included in Fedora are recommended to use as many of the following security settings as applicable while maintaining the default functionality of the service.
The full list of sandboxing features are available in systemd.exec. Note that if you are submitting changes to upstream as recommended, systemd will warn and ignore any of these features it doesn’t support. So it should be safe for upstream to enable as many of these features as applicable and not worry about distribution support for ones using older versions of systemd.
- Trademark approval: N/A
Packages will automatically get additional security features enabled by default transparently. In limited circumstances, they may need to override the defaults. Refer to user experience section for details.
You can use tools like
systemd-analyze security and
systemctl cat to verify that specific security features are enabled by default. Default services with the default features should have no adverse impact and users shouldn’t have to do anything beyond using the software as intended and report any regressions. High profile services not installed by default that gain these security features would benefit from more targeting testing to spot any unintended consequences especially for niche or advanced functionality. If advanced non-default functionality requires overrides default settings, we can document those in the release notes to provide guidance.
This should be largely transparent change for users. The goal is to have the services work as expected with the default functionality but to potentially require tweaking the settings if the configuration is changed by users after installation. For instance, if we add
ProtectHome=yes to Apache httpd.service and the user wishes to serve files out of their home directory, they will need to override the systemd setting to
ProtectHome=read-only to allow for the service to read from the user home directory in addition to changing the service specific configuration files to enable this feature.
None. We are merely enabling some of systemd security features by default for default system services and potentially some high profile services.
- Contingency mechanism: These settings can be enabled/disabled at a per service level. No wholesale reverts is necessary. If we don’t finish the work for all the services, we can follow up in future releases.
- Contingency deadline: N/A
- Blocks release? No
- Systemd Hardening — Peter's IT Docs
systemd security hardening features are enabled for default system services and following high profile services.
- Apache Httpd
If you wish to turn off any particular settings, you can follow the standard systemd method of overriding the config. For example,
$ cat /etc/systemd/system/httpd.service.d/override.conf
$ sudo systemctl daemon-reload
$ sudo systemctl restart httpd.service
$ systemctl status httpd.service
● httpd.service - The Apache HTTP Server)