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

Improve security of systemd service rest-server.service by restricting network access #246

Merged

Conversation

eriksjolund
Copy link
Contributor

@eriksjolund eriksjolund commented Jul 15, 2023

What is the purpose of this change? What does it change?

Improve security of rest-server.service by restricting network access.

This patch improves the overall security assessment score given by systemd-analyze security rest-server.service from "1.3 OK" to "0.6 SAFE" (when using systemd-analyze version 253)

  • Remove AF_INET AF_INET6 from RestrictAddressFamilies. Sockets originating from socket activation are not affected by the systemd directive RestrictAddressFamilies. See systemd.exec man page.

  • Add PrivateNetwork=yes as recommended for socket-activated services in the systemd.socket man page.

  • Add dependency on rest-server.socket

Was the change discussed in an issue or in the forum before?

Yes, in the forum:

https://forum.restic.net/t/using-none-instead-of-af-inet-af-inet6-for-restrictaddressfamilies-in-systemd-unit-rest-server-service/6448

Checklist

  • I have enabled maintainer edits for this PR
  • I have added tests for all changes in this PR
  • I have added documentation for the changes (in the manual)
  • There's a new file in changelog/unreleased/ that describes the changes for our users (template here)
  • I have run gofmt on the code in all commits
  • All commit messages are formatted in the same style as the other commits in the repo
  • I'm done, this Pull Request is ready for review

@eriksjolund eriksjolund force-pushed the adjust_restrict_address_families branch from 1b08bf8 to 1983121 Compare July 15, 2023 13:54
@eriksjolund eriksjolund marked this pull request as ready for review July 15, 2023 13:55
@eriksjolund eriksjolund force-pushed the adjust_restrict_address_families branch from 1983121 to df1b777 Compare July 15, 2023 14:00
Copy link
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

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

Thanks for opening a PR! I like the changes in general, but I think some comments and in particular the changelog are too verbose:

examples/systemd/rest-server.service Outdated Show resolved Hide resolved
changelog/unreleased/pull-246 Outdated Show resolved Hide resolved
examples/systemd/rest-server.service Outdated Show resolved Hide resolved
This patch improves the overall security assessment score given by
`systemd-analyze security rest-server.service` from "1.3 OK" to "0.6 SAFE"
(when using systemd-analyze version 253)

* Remove `AF_INET AF_INET6` from RestrictAddressFamilies.
  Sockets originating from socket activation are not affected by the
  systemd directive RestrictAddressFamilies.
  See systemd.exec man page.

* Add `PrivateNetwork=yes`
  as recommended for socket-activated services in the systemd.socket man page

* Add dependency on rest-server.socket

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
@eriksjolund eriksjolund force-pushed the adjust_restrict_address_families branch from df1b777 to ec2ce8c Compare July 17, 2023 06:55
Copy link
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@MichaelEischer MichaelEischer merged commit 0bb8cd4 into restic:master Jul 23, 2023
5 checks passed
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.

None yet

2 participants