Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd: enable systemd hardening features #7286

Merged
merged 1 commit into from
Jun 10, 2020

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.

misc/systemd/ipfs.service Outdated Show resolved Hide resolved
@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 marked this pull request as ready for review May 10, 2020 19:32
misc/systemd/ipfs.service Outdated Show resolved Hide resolved
misc/systemd/ipfs.service Outdated Show resolved Hide resolved
@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.

@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