From ef1e90240b07fcf531b5fd9f6826b7fb0a7196c6 Mon Sep 17 00:00:00 2001 From: David Seifert Date: Mon, 2 Nov 2026 11:02:24 +0100 Subject: [PATCH] app-crypt/token2-fido-bridge: new package, add 0.1.4 Signed-off-by: David Seifert --- app-crypt/token2-fido-bridge/Manifest | 1 + ...fido-bridge-0.1.4-systemd-sandboxing.patch | 74 +++++++++++++++++++ app-crypt/token2-fido-bridge/metadata.xml | 11 +++ .../token2-fido-bridge-0.1.4.ebuild | 57 ++++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 app-crypt/token2-fido-bridge/Manifest create mode 100644 app-crypt/token2-fido-bridge/files/token2-fido-bridge-0.1.4-systemd-sandboxing.patch create mode 100644 app-crypt/token2-fido-bridge/metadata.xml create mode 100644 app-crypt/token2-fido-bridge/token2-fido-bridge-0.1.4.ebuild diff --git a/app-crypt/token2-fido-bridge/Manifest b/app-crypt/token2-fido-bridge/Manifest new file mode 100644 index 0000000000000..66f3c6c8f66b3 --- /dev/null +++ b/app-crypt/token2-fido-bridge/Manifest @@ -0,0 +1 @@ +DIST token2-fido-bridge-0.1.4.tar.gz 23227 BLAKE2B f3515c783489eb16bc01e40a3720965b8d4b64b87eba603b8c656df45f24233313180dcba45c9a8ff45fa0b1b4b5a1e81a3ed55067ddc6c2a16e79ea92efca0b SHA512 60c581b97aa3195ab1f214ea05bba798e2f466406046a357d8703028c004e54adb1456ecbecdbce0cee33aca5b1403727b841fd980f1a78211092bbb0aaf16a2 diff --git a/app-crypt/token2-fido-bridge/files/token2-fido-bridge-0.1.4-systemd-sandboxing.patch b/app-crypt/token2-fido-bridge/files/token2-fido-bridge-0.1.4-systemd-sandboxing.patch new file mode 100644 index 0000000000000..839518ea22867 --- /dev/null +++ b/app-crypt/token2-fido-bridge/files/token2-fido-bridge-0.1.4-systemd-sandboxing.patch @@ -0,0 +1,74 @@ +From 2b69bd8d0d128a1c612ac3ee984fed16c9eaca73 Mon Sep 17 00:00:00 2001 +From: David Seifert +Date: Sun, 1 Nov 2026 13:58:32 +0100 +Subject: [PATCH] Sandbox the systemd service + +The daemon only needs /dev/uhid and the pcscd socket, so drop all +capabilities and confine it, keeping modprobe outside the sandbox. +--- + README.md | 3 ++- + packaging/token2-fido-bridge.service | 30 +++++++++++++++++++++++++++- + 2 files changed, 31 insertions(+), 2 deletions(-) + +diff --git a/README.md b/README.md +index cc4a049..94f1802 100644 +--- a/README.md ++++ b/README.md +@@ -55,7 +55,8 @@ project has none of that: install the `.deb`, and it just runs. + + - Linux with the `uhid` kernel module (standard on Ubuntu/Debian/Fedora) + - `pcscd` running, a PC/SC reader, and a FIDO2-capable smartcard +-- Runs as root (needs `/dev/uhid`) ++- Runs as root (needs `/dev/uhid`), but the systemd service drops all ++ capabilities and sandboxes the daemon + + ## Install + +diff --git a/packaging/token2-fido-bridge.service b/packaging/token2-fido-bridge.service +index 605cf9c..60adb99 100644 +--- a/packaging/token2-fido-bridge.service ++++ b/packaging/token2-fido-bridge.service +@@ -6,11 +6,39 @@ Wants=pcscd.service + [Service] + Type=simple + # Ensure the uhid kernel module is available before we open /dev/uhid. +-ExecStartPre=-/sbin/modprobe uhid ++# "+" runs this outside the sandbox below, which forbids module loading. ++ExecStartPre=-+/sbin/modprobe uhid + ExecStart=/usr/bin/token2-fido-bridge + Restart=on-failure + RestartSec=2 ++# root only because /dev/uhid is root:root 0600 and pcscd's polkit policy ++# refuses session-less users; as the owner, root needs no capabilities. + User=root + ++# The daemon only opens /dev/uhid and talks to pcscd over its UNIX socket. ++CapabilityBoundingSet= ++NoNewPrivileges=yes ++DevicePolicy=closed ++DeviceAllow=/dev/uhid rw ++PrivateNetwork=yes ++RestrictAddressFamilies=AF_UNIX ++ProtectSystem=strict ++ProtectHome=yes ++PrivateTmp=yes ++ProtectClock=yes ++ProtectHostname=yes ++ProtectKernelLogs=yes ++ProtectKernelModules=yes ++ProtectKernelTunables=yes ++ProtectControlGroups=yes ++RestrictNamespaces=yes ++RestrictRealtime=yes ++RestrictSUIDSGID=yes ++LockPersonality=yes ++MemoryDenyWriteExecute=yes ++SystemCallArchitectures=native ++SystemCallFilter=@system-service ++SystemCallErrorNumber=EPERM ++ + [Install] + WantedBy=multi-user.target +-- +2.56.0 + diff --git a/app-crypt/token2-fido-bridge/metadata.xml b/app-crypt/token2-fido-bridge/metadata.xml new file mode 100644 index 0000000000000..82d9eb7588912 --- /dev/null +++ b/app-crypt/token2-fido-bridge/metadata.xml @@ -0,0 +1,11 @@ + + + + + soap@gentoo.org + David Seifert + + + token2/token2-fido-bridge + + diff --git a/app-crypt/token2-fido-bridge/token2-fido-bridge-0.1.4.ebuild b/app-crypt/token2-fido-bridge/token2-fido-bridge-0.1.4.ebuild new file mode 100644 index 0000000000000..275c3ec423feb --- /dev/null +++ b/app-crypt/token2-fido-bridge/token2-fido-bridge-0.1.4.ebuild @@ -0,0 +1,57 @@ +# Copyright 2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit cmake linux-info optfeature systemd udev + +DESCRIPTION="Expose PC/SC smartcards as virtual FIDO2/WebAuthn USB-HID security keys" +HOMEPAGE="https://github.com/token2/token2-fido-bridge" +SRC_URI="https://github.com/token2/token2-fido-bridge/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64" + +DEPEND="sys-apps/pcsc-lite" +RDEPEND="${DEPEND}" +BDEPEND="virtual/pkgconfig" + +CONFIG_CHECK="~HIDRAW ~UHID" + +PATCHES=( + "${FILESDIR}"/${P}-systemd-sandboxing.patch +) + +src_prepare() { + cmake_src_prepare + + # Upstream hardcodes /usr/lib/{systemd,udev} install paths; + # install these with the eclass helpers in src_install instead. + sed -i -e '/^install(FILES packaging\//d' CMakeLists.txt || die +} + +src_configure() { + local mycmakeargs=( + -DSTATIC_CXX_RUNTIME=OFF + ) + cmake_src_configure +} + +src_install() { + cmake_src_install + + systemd_dounit packaging/${PN}.service + udev_dorules packaging/70-${PN}.rules + insinto /usr/lib/modules-load.d + newins packaging/uhid.conf ${PN}-uhid.conf +} + +pkg_postinst() { + udev_reload + optfeature "USB CCID smartcard readers" app-crypt/ccid +} + +pkg_postrm() { + udev_reload +}