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

dist: harden systemd service unit #276

Merged
merged 1 commit into from
Jul 7, 2022

Conversation

Tachi107
Copy link
Contributor

With this patch the systemd service will now run in a hardened sandbox that limits the kinds of subsystems available to the unit. This improves the overall security of the system, as nextcloud-spreed-signaling becomes almost pointless to exploit.

The most notable changes include:

  • The entire fie system is mounted read-only with ProtectSystem=strict
  • No binaries are executable, apart from /usr/bin/signaling, with NoExecPaths=/ and ExecPaths=/usr/bin/signaling
  • The service cannot see any user on the system apart from the one that is running the process, with PrivateUsers=yes
  • Most of the /proc subsystem is inaccessible, and things like system stats may be unavailabe, with ProcSubset=pid
  • All home directories are inaccessible, with ProtectHome=yes
  • The kinds of permitted system calls are limited, via SystemCallFilter=

I highly recommend you to read the systemd.exec(5) manual page to fully understand what these options do and how they can protect the system.

Unfortunately I haven't been running nextcloud-spreed-signaling in a while, and I can't currently check that these option do not break functionality. I have tested this in a limited environment and it seems that everything still works fine, but it would be better to also check that e.g. the Janus integration is still functional in this hardened sandbox.

With this patch the systemd service will now run in a hardened sandbox
that limits the kinds of subsystems available to the unit. This improves
the overall security of the system, as nextcloud-spreed-signaling
becomes almost pointless to exploit.

The most notable changes include:

- The entire fie system is mounted read-only with ProtectSystem=strict
- No binaries are executable, apart from /usr/bin/signaling, with
  NoExecPaths=/ and ExecPaths=/usr/bin/signaling
- The service cannot see any user on the system apart from the one that
  is running the process, with PrivateUsers=yes
- Most of the /proc subsystem is inaccessible, and things like system
  stats may be unavailabe, with ProcSubset=pid
- All home directories are inaccessible, with ProtectHome=yes
- The kinds of permitted system calls are limited, via SystemCallFilter=

I highly recommend you to read the systemd.exec(5) manual page to fully
understand what these options do and how they can protect the system.
https://www.freedesktop.org/software/systemd/man/systemd.exec.html
@fancycode
Copy link
Member

ping @morph027 who provided the initial systemd service

@morph027
Copy link
Contributor

Will add it to my personal instance for testing....thanks for providing and pinging!

@fancycode
Copy link
Member

@morph027 did you get a chance to test this?

@morph027
Copy link
Contributor

morph027 commented Jul 7, 2022

Ah, thanks for pinging. Works so far. Only thing i noticed is that my systemd might be a bit too old for some features.

systemd[1]: /etc/systemd/system/signaling.service.d/security.conf:7: Unknown key name 'ExecPaths' in section 'Service', ignoring.
systemd[1]: /etc/systemd/system/signaling.service.d/security.conf:10: Unknown key name 'NoExecPaths' in section 'Service', ignoring.
systemd[1]: /etc/systemd/system/signaling.service.d/security.conf:15: Unknown key name 'ProcSubset' in section 'Service', ignoring.
systemd[1]: /etc/systemd/system/signaling.service.d/security.conf:23: Unknown key name 'ProtectProc' in section 'Service', ignoring.

However, it still works.

@fancycode
Copy link
Member

Thanks for the feedback.

@fancycode fancycode merged commit 5b3b147 into strukturag:master Jul 7, 2022
@Tachi107
Copy link
Contributor Author

Tachi107 commented Jul 7, 2022 via email

mwalbeck added a commit to mwalbeck/docker-nextcloud-spreed-signaling that referenced this pull request Aug 6, 2022
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [strukturag/nextcloud-spreed-signaling](https://github.com/strukturag/nextcloud-spreed-signaling) | major | `v0.5.0` -> `v1.0.0` |

---

### Release Notes

<details>
<summary>strukturag/nextcloud-spreed-signaling</summary>

### [`v1.0.0`](https://github.com/strukturag/nextcloud-spreed-signaling/releases/tag/v1.0.0)

[Compare Source](strukturag/nextcloud-spreed-signaling@v0.5.0...v1.0.0)

##### Added

-   Clustering support.  [#&#8203;281](strukturag/nextcloud-spreed-signaling#281)
-   Send initial "welcome" message when clients connect.  [#&#8203;288](strukturag/nextcloud-spreed-signaling#288)
-   Support hello auth version "2.0" with JWT.  [#&#8203;251](strukturag/nextcloud-spreed-signaling#251)
-   dist: add systemd sysusers file.  [#&#8203;275](strukturag/nextcloud-spreed-signaling#275)
-   Add more tests.  [#&#8203;292](strukturag/nextcloud-spreed-signaling#292)
-   Add tests for virtual sessions.  [#&#8203;295](strukturag/nextcloud-spreed-signaling#295)
-   Implement per-backend session limit for clusters.  [#&#8203;296](strukturag/nextcloud-spreed-signaling#296)

##### Changed

-   Don't run "go mod tidy" when building.  [#&#8203;269](strukturag/nextcloud-spreed-signaling#269)
-   Bump sphinx from 5.0.0 to 5.0.1 in /docs  [#&#8203;270](strukturag/nextcloud-spreed-signaling#270)
-   Bump sphinx from 5.0.1 to 5.0.2 in /docs  [#&#8203;277](strukturag/nextcloud-spreed-signaling#277)
-   Move common etcd code to own class.  [#&#8203;282](strukturag/nextcloud-spreed-signaling#282)
-   Support arbitrary capabilities values.  [#&#8203;287](strukturag/nextcloud-spreed-signaling#287)
-   dist: harden systemd service unit.  [#&#8203;276](strukturag/nextcloud-spreed-signaling#276)
-   Update to Go module version of github.com/golang-jwt/jwt  [#&#8203;289](strukturag/nextcloud-spreed-signaling#289)
-   Disconnect sessions with the same room session id synchronously.  [#&#8203;294](strukturag/nextcloud-spreed-signaling#294)
-   Bump google.golang.org/grpc from 1.47.0 to 1.48.0  [#&#8203;297](strukturag/nextcloud-spreed-signaling#297)
-   Update to github.com/pion/sdp v3.0.5  [#&#8203;301](strukturag/nextcloud-spreed-signaling#301)
-   Bump sphinx from 5.0.2 to 5.1.1 in /docs  [#&#8203;303](strukturag/nextcloud-spreed-signaling#303)
-   make: Include vendored dependencies in tarball.  [#&#8203;300](strukturag/nextcloud-spreed-signaling#300)
-   docs: update and pin dependencies.  [#&#8203;305](strukturag/nextcloud-spreed-signaling#305)
-   Bump actions/upload-artifact from 2 to 3  [#&#8203;307](strukturag/nextcloud-spreed-signaling#307)
-   Bump actions/download-artifact from 2 to 3  [#&#8203;308](strukturag/nextcloud-spreed-signaling#308)
-   Bump google.golang.org/protobuf from 1.28.0 to 1.28.1  [#&#8203;306](strukturag/nextcloud-spreed-signaling#306)
-   CI: Also test with Golang 1.19  [#&#8203;310](strukturag/nextcloud-spreed-signaling#310)

##### Fixed

-   Fix check for async room messages received while not joined to a room.  [#&#8203;274](strukturag/nextcloud-spreed-signaling#274)
-   Fix testing etcd server not starting up if etcd is running on host.  [#&#8203;283](strukturag/nextcloud-spreed-signaling#283)
-   Fix CI issues on slow CPUs.  [#&#8203;290](strukturag/nextcloud-spreed-signaling#290)
-   Fix handling of "unshareScreen" messages and add test.  [#&#8203;293](strukturag/nextcloud-spreed-signaling#293)
-   Fix Read The Ddocs builds.  [#&#8203;302](strukturag/nextcloud-spreed-signaling#302)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xMzUuMSIsInVwZGF0ZWRJblZlciI6IjMyLjEzNS4xIn0=-->

Co-authored-by: Magnus Walbeck <[email protected]>
Reviewed-on: https://git.walbeck.it/walbeck-it/docker-nextcloud-spreed-signaling/pulls/207
Co-authored-by: renovate-bot <[email protected]>
Co-committed-by: renovate-bot <[email protected]>
@Tachi107 Tachi107 deleted the systemd-hardening branch August 17, 2022 17:45
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.

3 participants