Repository navigation
Conversation
Add sandboxing options to both user units. Only options enforced with seccomp and no_new_privs are used: credentialsd decides whether a caller is trusted partly by comparing mount namespaces, so options that give the service a private mount namespace would make it reject xdg-desktop-portal, and they would also need user namespaces in the user service manager. Both units filter system calls to @System-service plus memfd_secret, which carries the hybrid QR code secret and PINs over D-Bus. The daemon may use AF_UNIX, AF_NETLINK and AF_INET/AF_INET6 (for the hybrid tunnel); the UI only AF_UNIX and AF_NETLINK. The UI keeps writable executable memory for JIT-compiling GL drivers. systemd-analyze security: daemon 9.2 -> 6.0, UI 9.2 -> 5.8. Closes linux-credentials#21
Contributor
Author
|
Tested the USB + PIN path as well, using a virtual FIDO2 key (bulwarkid/virtual-fido attached via USB/IP, so it shows up as a real Under the hardened units in log-only mode (
Update: the PIN step now completes under the enforced hardened units. Entering the PIN created the credential ( The earlier failure was in virtual-fido, not libwebauthn or the hardening:
With both fixes, the USB + PIN path works with the hardened units as in this PR. A real key would still be a good final check. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #21.
Adds sandboxing to both systemd user units.
systemd-analyze security: daemon 9.2 → 6.0, UI 9.2 → 5.8.What's enabled (both units)
NoNewPrivileges,LockPersonality,RestrictRealtime,RestrictSUIDSGID,RestrictNamespaces,SystemCallArchitectures=native,UMask=0077.SystemCallFilter=@system-serviceplusmemfd_secret, withSystemCallErrorNumber=EPERM.memfd_secretis needed because the hybrid QR code secret (daemon) and PINs (UI) are passed over D-Bus inmemfd_secretfds.MemoryDenyWriteExecute.RestrictAddressFamilies=AF_UNIX AF_NETLINK AF_INET AF_INET6: D-Bus/BlueZ/pcscd, udev, and the hybrid tunnel.RestrictAddressFamilies=AF_UNIX AF_NETLINK.MemoryDenyWriteExecute, since GTK's GL renderer may run on a JIT-compiling driver such as llvmpipe.What's deliberately not enabled
Anything that gives the service a private mount namespace:
ProtectSystem,ProtectHome,PrivateTmp,PrivateDevices,ProtectKernel*,ProtectProc, … There are three reasons:gateway/mod.rs), so it would reject xdg-desktop-portal./proc/<pid>/root.PrivateDeviceswould also hide/dev/hidraw*from the daemon. This is explained in a comment in each unit.If we want filesystem sandboxing later, the trust check would need another way to compare callers.
Testing
I installed the generated units as user services (pointing at a debug build, plus a drop-in setting
CREDSD_TRUSTED_CALLERSso a test client could stand in for the portal) and ran real create requests completed with a phone over hybrid.@system-serviceonly: the daemon gotEPERMwriting the QR secret (memfd_secret) and the hybrid task panicked, so no QR code was shown. That's howmemfd_secretwas found. Separately, the panic on that error path (hybrid.rs:213) might be worth turning into a proper error.SystemCallFilter=cleared,SystemCallLog=~@system-service), completed with a phone: across both processes, the kernel audit log recorded exactly one syscall outside the set:memfd_secret(447) from the daemon.NoNewPrivs: 1,Seccomp: 2on both processes. The phone flow completed andCreateCredentialreturned a registration response. Calls seen:CreateSession→NotifyHybridStarted→NotifyHybridConnecting→NotifyHybridConnected→NotifyCeremonyCompleted. No seccomp denials, and the trust check still passed (same mount namespace).Not exercised: USB security keys (no key here) and the PIN flow.
memfd_secretis allowed in the UI for the PIN path based on the code (client.rs→write_secret). If someone can run a USB/PIN flow with these units, that would close the gap.