Skip to content

systemd: enable systemd hardening features#7286

Merged
Stebalien merged 1 commit intoipfs:masterfrom
RubenKelevra:feat/systemd-service-hardening
Jun 10, 2020
Merged

systemd: enable systemd hardening features#7286
Stebalien merged 1 commit intoipfs:masterfrom
RubenKelevra:feat/systemd-service-hardening

Conversation

@RubenKelevra
Copy link
Contributor

@RubenKelevra RubenKelevra commented May 7, 2020

Motivation

IPFS is a network-facing service, which just needs very limited access to the system itself outside of it's state-directory.

Systemd allows to do a lot of hardening to separate a network process from the system and reduce the attack surface.

This PR aims to enable all possible options for the latest systemd-version.

@RubenKelevra
Copy link
Contributor Author

RubenKelevra commented May 10, 2020

I've added a reduced set of security settings, for users who need the fuse-mount-feature.

@RubenKelevra RubenKelevra requested a review from Stebalien May 10, 2020 19:32
@RubenKelevra RubenKelevra marked this pull request as ready for review May 10, 2020 19:32
@RubenKelevra RubenKelevra force-pushed the feat/systemd-service-hardening branch from c097d28 to 25a2e31 Compare May 26, 2020 08:25
@RubenKelevra RubenKelevra requested a review from Stebalien May 26, 2020 08:26
@RubenKelevra
Copy link
Contributor Author

I've added a separate hardened service file. So the maintainer can choose between hardening and the fuse mount functionality.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits/questions, otherwise LGTM.

ProtectKernelModules=true
ProtectKernelLogs=true
PrivateDevices=true
DevicePolicy=closed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is implied by PrivateDevices, right?

Copy link
Contributor Author

@RubenKelevra RubenKelevra Jun 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PrivateDevices will set DevicePolicy=closed, the reasoning for setting it explicitly is some older systemd-versions might support just the simpler DevicePolicy=closed but doesn't yet support PrivateDevices.

In this case PrivateDevices would be ignored and DevicePolicy=closed not set.

# enable to specify a custom path see docs/environment-variables.md for further documentations
#Environment=IPFS_PATH=/custom/ipfs/path
# enable to specify a higher limit for open files/connections
#LimitNOFILE=1000000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given all these restrictions, will IPFS be able to set it's own file descriptor limits? If not, we should probably set this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it can.

@RubenKelevra RubenKelevra requested a review from Stebalien June 10, 2020 11:20
@Stebalien Stebalien merged commit 66beefe into ipfs:master Jun 10, 2020
@Stebalien
Copy link
Member

Thanks!

@RubenKelevra RubenKelevra deleted the feat/systemd-service-hardening branch June 10, 2020 21:06
@aschmahmann aschmahmann mentioned this pull request Sep 22, 2020
72 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants