-
Notifications
You must be signed in to change notification settings - Fork 105
feat(systemd-hardening): harden backend-status #1159
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
Draft
pophilpo
wants to merge
4
commits into
main
Choose a base branch
from
pophilpo/backend-status-hardening
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+66
−2
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3bfb731
feat(systemd-hardening): update backend-status service file
pophilpo fde87a3
feat(systemd-hardening): fix tmp issue
pophilpo e5bf124
Merge branch 'main' into pophilpo/backend-status-hardening
pophilpo 49c1a80
feat(systemd-hardening): improve security
pophilpo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 66 additions & 2 deletions
68
orb-backend-status/debian/worldcoin-backend-status.service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,83 @@ | ||
| [Unit] | ||
| Description=Worldcoin Backend Status | ||
| Documentation=https://github.com/worldcoin/orb-software | ||
| # Hard dependency: attest must be up first so the auth token is available on the bus | ||
| Requires=worldcoin-attest.service | ||
| After=worldcoin-attest.service | ||
| # Hard dependency: zenoh daemon must be running before we subscribe to topics | ||
| Requires=zenohd.service | ||
| After=zenohd.service | ||
| # Hard dependency: custom session bus must be up before we connect to it | ||
| Requires=worldcoin-dbus.service | ||
| After=worldcoin-dbus.service | ||
|
|
||
| [Service] | ||
| # Process exits when main process exits; systemd does not wait for any forked children | ||
| Type=simple | ||
| User=worldcoin | ||
| # Run as dedicated non-root service account | ||
| User=orb-backend-status | ||
| # Primary group (owns no files, just sets the GID of the process) | ||
| Group=orb-backend-status | ||
| # Grants access to /tmp/worldcoin_bus_socket (SocketGroup=worldcoin-dbus, mode 0660) | ||
| SupplementaryGroups=worldcoin-dbus | ||
|
|
||
| Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/worldcoin_bus_socket | ||
| Environment=RUST_BACKTRACE=1 | ||
| SyslogIdentifier=worldcoin-backend-status | ||
| ExecStart=/usr/local/bin/orb-backend-status | ||
| Restart=always | ||
| RestartSec=10s | ||
|
|
||
| NoNewPrivileges=yes | ||
| ProtectHome=yes | ||
| ProtectSystem=strict | ||
|
|
||
| # If at some point this service will need write access make sure to change this | ||
| ReadOnlyPaths=/ | ||
| PrivateTmp=no | ||
| PrivateDevices=yes | ||
| PrivateNetwork=no | ||
| RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX | ||
|
|
||
| # Prevent the service from creating any new kernel namespaces (no unshare, no clone with namespace flags) | ||
| RestrictNamespaces=yes | ||
| # Prevent the service from creating setuid or setgid files | ||
| RestrictSUIDSGID=yes | ||
| # Prevent the service from changing its execution domain / personality (e.g. switching to 32-bit ABI) | ||
| LockPersonality=yes | ||
| # Make the hostname and domainname read-only to the service | ||
| ProtectHostname=yes | ||
| # Prevent access to the kernel log ring buffer (/dev/kmsg, /proc/kmsg) | ||
| ProtectKernelLogs=yes | ||
| # Prevent loading or unloading kernel modules | ||
| ProtectKernelModules=yes | ||
| # Make kernel tunables (/proc/sys, /sys) read-only | ||
| ProtectKernelTunables=yes | ||
| # Make the cgroup hierarchy read-only (prevents cgroup escapes) | ||
| ProtectControlGroups=yes | ||
| # Hide other processes' /proc/[pid] entries; the service can only see its own | ||
| ProtectProc=invisible | ||
| # Prevent any memory region from being simultaneously writable and executable (blocks shellcode injection) | ||
| MemoryDenyWriteExecute=yes | ||
| # Only allow native syscall ABI; block 32-bit compat syscalls on a 64-bit kernel | ||
| SystemCallArchitectures=native | ||
| # Avoid inhereting capabilities | ||
| AmbientCapabilities= | ||
|
|
||
| # Drop all Linux capabilities from the bounding set; this service needs none. | ||
| # The bounding set is the hard ceiling: even if the process tries to gain a capability, it cannot. | ||
| CapabilityBoundingSet= | ||
| # Deny dangerous syscall groups (~ means deny-list): | ||
| # @cpu-emulation - vm86, modify_ldt (CPU emulation, not needed) | ||
| # @debug - ptrace, perf_event_open (debugging/tracing other processes) | ||
| # @module - init_module, finit_module, delete_module (kernel module loading) | ||
| # @mount - mount, umount2, pivot_root (filesystem mounting) | ||
| # @obsolete - bdflush, sysfs, uselib (removed/legacy syscalls) | ||
| # @raw-io - ioperm, iopl, pciconfig_read (direct hardware port I/O) | ||
| # @reboot - reboot, kexec_load (system reboot/power control) | ||
| # @swap - swapon, swapoff (swap management) | ||
| # @privileged - chown, setuid, setns and other privilege-manipulation calls | ||
| SystemCallFilter=~@cpu-emulation @debug @module @mount @obsolete @raw-io @reboot @swap @privileged | ||
|
|
||
| [Install] | ||
| # Start this service when reaching the normal multi-user boot target | ||
| WantedBy=multi-user.target | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add
AmbientCapabilities=