<![CDATA[USBGuard]]> 2023-04-12T15:08:56+00:00 / Jekyll <![CDATA[Increasing compiler version to C++17]]> 2021-03-01T09:00:00+00:00 /blog/2021/cpp-version As development packages are getting updated with latest features requiring newer versions of C++, we had to make a choice. We can either stuck with the old packages or start using new releases. After some investigation of newer C++ standards and its incompatibilities a decision has been made to increase the overall C++ version of USBGuard from C++11 to C++17. What does this mean for you? From now on, you will require a compiler that supports C++17 to be able to compile USBGuard sources. However, USBGuard will continue to work with old dependencies but will also support the newest development packages. An example of such package is PEGTL of version 3 which uses C++17.

]]>
<![CDATA[New release: usbguard-1.0.0, and project enhancements!]]> 2021-01-13T06:00:00+00:00 /blog/2021/usbguard-1.0.0 New release: Stable usbguard-1.0.0, and important projects updates are finally here!

A new stable release of USBGuard is available and it brings mainly important bug fixes. See the release page at Github for more information about the release. The stable release contains minor bugfixes, which were needed to be solved before the official release can be published.

Change Log

Added

  • Starting with libtool versioning
  • Added interface for IPC permission query
  • Introduced partial rule concept fo CLI
  • Added WithConnectType for ldap rule

Fixed/Changed

  • Daemon does not apply the policy when “change” action event appears anymore
  • IPCClientPrivate@disconnect is thread safe
  • Enforced loading of files from rules.d/ direcory in alfabetical order
  • Improved CLI behaviour to be consistent
  • Clarified rule’s label documentation
  • Fixed thread copy assignment bug
  • Fixed oss-fuzz build
  • Improved overall documentation
  • Set DevicePolicy to closed in service file

Thanks

Many thanks to the following people for contributions to this release and to the USBGuard project:

Regards, Radovan

]]>
<![CDATA[New release: usbguard-0.7.8, and project enhancements!]]> 2020-05-20T06:00:00+00:00 /blog/2020/usbguard-0.7.8 New release: usbguard-0.7.8, and important projects updates are here!

A new release of USBGuard is available and it brings important bug fixes. See the release page at Github for more information about the release. This release mainly contains bugfixes related to the rules.d feature introduced in 0.7.7.

Change Log

Fixed/Changed

  • Reworked upsertRule logic
  • Extended rules.d folder description with naming conventions
  • Multiple segfault fixes regarding rules.d feature

Thanks

Many thanks to the following people for contributions to this release and to the USBGuard project:

Regards, Radovan

]]>
<![CDATA[New release: usbguard-0.7.7, and project enhancements!]]> 2020-05-19T06:00:00+00:00 /blog/2020/usbguard-0.7.7 New release: usbguard-0.7.7, and important projects updates are here!

A new release of USBGuard is available and it brings important bug fixes and new features. See the release page at Github for more information about the release.

Change Log

Added

  • Added readwritepath to service file
  • Added match-all keyword to rules language
  • Added rules.d feature - daemon can load multiple rule files from rules.d/
  • Included with-connect-type in dbus signal
  • Add configure flags for optional libraries
  • Public API documentation

Fixed/Changed

  • Fixed sigwaitinfo handling
  • Fixed possible data corruption on stack with appendRule via dbus
  • Fixed ENOBUFS errno handling on netlink socket
  • Daemon can survive and wait until socket is readable again
  • Make: explicitly treat pthread as first level dependency
  • Added missing options to manual pages

Removed

  • Dropped unused PIDFile from service file
  • Dropped deprecated dbus-glib dependency

Rules.d feature in more detail

  • Users of usbguard can set rules.d folder path in the same way they specify RuleFile.
  • The USBGuard daemon will use this folder to load the policy rule set from it and to write new rules received via the IPC interface.
  • Usually, we set the option to /etc/usbguard/rules.d/.
  • The USBGuard daemon is supposed to behave like any other standard Linux daemon therefore it loads rule files in alpha-numeric order.
  • File names inside RuleFolder directory should start with a two-digit number prefix indicating the position, in which the rules are scanned by the daemon.
  • Setting up RuleFolder is as easy as the following: RuleFolder=/path/to/rulesfolder/

Thanks

Many thanks to the following people for contributions to this release and to the USBGuard project:

Regards, Radovan

]]>
<![CDATA[New release: usbguard-0.7.6, and project enhancements!]]> 2019-11-11T12:00:00+00:00 /blog/2019/usbguard-0.7.6 New release: usbguard-0.7.6, and important projects updates again!

A new release of USBGuard is available and it brings important bug fixes and new features. See the release page at Github for more information about the release.

Now the important projects updates I would like to announce:

  1. Unfortunately, I made a mistake in git workflow thus the release has not a verified sign next to release 0.7.6.
  2. The proof-of-concept Qt applet was substituted with a brand new project called usbguard-notifier.

Change Log

Added

  • Added missing options in manpage usbguard-daemon(8)
  • Extended the functionality of allow/block/reject commands the command can handle rule as a param and not only its ID e.g. in case of allow, command will allow each device that matches provided rule
  • Added debug info for malformed descriptors

Fixed/Changed

  • Changed default backend to uevent
  • Fixed handling of add uevents during scanning now we are sure that the enumeration is completed before processing any uevent we are trying to avoid a race where the kernel is still enumerating the devices and send the uevent while the parent is being authorised
  • Silenced ‘bind’ and ‘unbind’ uevents

Thanks

Many thanks to the following people for contributions to this release and to the USBGuard project:

Regards, Radovan

]]>
<![CDATA[New release: usbguard-0.7.5, and important projects updates!]]> 2019-07-15T12:00:00+00:00 /blog/2019/usbguard-0.7.5 Hello everyone!

A new release of USBGuard is available and it brings important bug fixes and new features. See the release page at Github for more information about the release.

Now the important projects updates I would like to announce:

  1. Unfortunatelly, I’ve lost access to my GPG keys (and revocation certs too) that were used to sign the release tarballs and commits. Because of that, the upcomming releases will be signed with a a different key, see my keybase.io page for details and the new key. This might change once more because future releases might be created by one of multiple maintainers (see below).

  2. I’m no longer the sole maintainer of the upstream repository. Radovan Sroka from Red Hat and Thiébaud Weksteen from Google joined the forces as maintainers. Thank you both for doing so!

Regards, Daniel

]]>
<![CDATA[Blocking USB devices while the screen is locked]]> 2017-08-11T08:00:00+00:00 /blog/2017/Screen-Locking Since the 0.7.0 release, it is possible to influence how an already running usbguard-daemon instance handles newly inserted USB devices. The behaviour is defined by the value of the InsertedDevicePolicy runtime parameter and the default choice is to apply the policy rules to figure out whether to authorize the device or not.

The parameter can be read and modified via the usbguard CLI:

$ sudo usbguard get-parameter InsertedDevicePolicy
apply-policy

To change the policy to block use:

$ sudo usbguard set-parameter InsertedDevicePolicy block

Now try to insert a USB device and it won’t be authorized even if there’s a rule in your policy that says otherwise. Devices connected before the parameter value change aren’t affected and remain in the same state.

Please note that for the examples below to work, you need to allow your desktop user to modify the USBGuard runtime parameters. This can be done either with USBGuard IPC access control or by giving sudo permissions to run usbguard set-parameter without authentication.

The following command will allow user joe to read and modify the runtime parameters via USBGuard IPC:

$ sudo usbguard add-user joe --parameters ALL

Note that the command will set the ACL exactly to what is specified on the command line, not append to the existing ACL settings for the user in case they exist.

Blocking new USB device while the screen is locked

Method #1: Screen locker wrapper script

If you are using a custom screen locker like i3lock, you’ll need to create a wrapper script that takes care of setting the InsertedDevicePolicy parameter, something like this:

#!/bin/sh

POLICY_UNLOCKED=apply-policy
POLICY_LOCKED=reject

revert() {
  usbguard set-parameter InsertedDevicePolicy $POLICY_UNLOCKED
}

trap revert SIGHUP SIGINT SIGTERM
usbguard set-parameter InsertedDevicePolicy $POLICY_LOCKED
i3lock -n
revert

Now adjust your screen locker shortcuts and setting to point to this wrapper script instead of the original locker command and that’s it.

Method #2: D-Bus screen (un)lock signals

If you are using a desktop environment which has built-in screen locking support, then it probably signals the “screen (un)locked” state via D-Bus. In that case you need to create a script to watch for these signals and set the InsertedDevicePolicy parameter appropriately. The script should be running in your session (refer to your desktop environment’s documentation on how to automatically start the script after you log in).

Example script:

#!/bin/sh

DBUS_INTERFACE=org.freedesktop.ScreenSaver
POLICY_UNLOCKED=apply-policy
POLICY_LOCKED=reject

dbus-monitor --session "type='signal',interface='"$DBUS_INTERFACE"'" |
  while read x; do
    case "$x" in 
      *"boolean true"*) usbguard set-parameter InsertedDevicePolicy $POLICY_LOCKED
    ;;
      *"boolean false"*) usbguard set-parameter InsertedDevicePolicy $POLICY_UNLOCKED
    ;;
    esac
  done
]]>
<![CDATA[IPC interface access control]]> 2017-07-13T08:00:00+00:00 /blog/2017/IPC-Access-Control I have already covered how to configure usbguard-daemon IPC access control in a previous post. However, the 0.7.0 release introduced another way to configure the same thing with more control over who can do what.

Previously, one could only enable a user or group to use the whole IPC interface. With the new ACL system, the access can be limited to specific sections of the interface and specific privileges inside that section.

The available sections and privileges are:

  • Section: Devices
    • modify: Change authorization state of devices including permanent changes (i.e. modification of device specific rules in the policy).
    • list: Ability to get a list of recognized devices and their attributes.
    • listen: Listen to device presence and device policy changes.
  • Section: Policy
    • modify: Append rules to or remove any rules from the poli‐ cy.
    • list: Ability to view the currently enforced policy.
  • Section: Exceptions
    • listen: Receive exception messages.
  • Section: Parameters
    • modify: Set values of run‐time parameters.
    • list: Get values of run‐time parameters.

To use this new system, you first have to modify the usbguard-daemon configuration and set the IPCAccessControlFiles setting to point to a location where the ACL definition files will be stored, for example: /etc/usbguard/IPCAccessControl.d/.

Once set, you can use the usbguard CLI to define the ACL. For example:

$ sudo usbguard add-user joe --devices ALL --policy list,listen --exceptions ALL

That command will enable user joe to have full access to the Devices and Exceptions sections. In addition, joe will be able to list the policy and listen to policy signals.

To remove the definition, use:

$ sudo usbguard remove-user joe
]]>
<![CDATA[New release: usbguard-0.7.0]]> 2017-04-12T19:00:00+00:00 /blog/2017/usbguard-0.7.0 Hello strangers! It’s been a while. A new release of USBGuard is available and it brings important bug fixes and new features.

From all the bug fixes in this release, I’d like to point out one which required a backwards incompatible change and requires an update to existing policies. The Linux USB root hub devices use the kernel version as the bcdDevice attribute value. The value is part of the USB descriptor data which USBGuard uses for computing the device hash and therefore causes the device hash to change on every kernel update. This in turn makes USBGuard rules which rely on this hash to not match and block the device. And because it’s a root hub device that gets blocked, all the other devices get blocked too. The bug fix is simple, reset the bcdDevice value to zero before hashing (applied only for the Linux root hub devices).

New features include an UEvent based device manager and support for fine-grained IPC access control. Check out the Change Log for more details.

Change Log

Added

  • Added DeviceManagerBackend configuration option. This option can be used to select from several device manager backend implementations.
  • Implemented an uevent based device manager backend.
  • Added setParameter, getParameter IPC (incl. D-Bus) methods.
  • Added set-parameter, get-parameter CLI subcommands.
  • Qt Applet: Added Spanish (es_AR) translation.
  • Create empty rules.conf file at install time (make install).
  • Support for numeric UID/GID values in IPCAllowedUsers and IPCAllowedGroups settings.
  • If bash completion support is detected at configure time, install the bash completion script during make install.
  • Added new configuration setting: IPCAccessControlFiles.
  • IPC access is now configurable down to a section and privilege level per user and/or group.
  • Added add-user, remove-user usbuard CLI subcommands for creating, removing IPC access control files.
  • Added AuditFilePath configuration option for setting the location of the USBGuard audit events log file path. If set, the usbguard-daemon will log policy and device related actions and whether they succeeded or not.

Removed

  • Removed UDev based device manager backend and UDev related dependencies.
  • Removed UDev development files/API dependency

Changed

  • Reset Linux root hub bcdDevice value before updating device hash. This is a backwards incompatible change because it changes how the device hash is computed for Linux root hub devices.
  • Refactored low-level USB device handling into SysFSDevice class which represents a device in the /sys filesystem (sysfs).
  • Removed usage of readdir_r because it’s obsolete. Replaced with readdir with the assumption that its usage is thread-safe if the directory handle passed to it is not shared between threads.
  • Extended test suite with use case tests.
  • Install the usbguard-daemon configuration and policy file with strict file permissions to prevent policy leaks.
  • Fixed several memory leaks.
  • Don’t pre-resolve user and group names in IPCAllowedUsers and IPCAllowedGroups settings. Instead, resolve the name during the IPC authentication phase.

Thanks

Many thanks to the following people for contributions to this release and to the USBGuard project:

Updating

If you are using Fedora or the USBGuard Copr repository, run:

$ sudo dnf update --enablerepo=updates-testing usbguard

Download

Signed release tarball can be downloaded from the USBGuard release page at GitHub:

SHA256(usbguard-0.7.0.tar.gz)= 1e1485a2b47ba3bde9de2851b371d2552a807047a21e0b81553cf80d7f722709
]]>
<![CDATA[New release: usbguard-0.6.2]]> 2016-09-18T18:00:00+00:00 /blog/2016/usbguard-0.6.2 A quick bugfix release.

Bugs Fixed

  • CLI & Library: Wait for IPC disconnect & shutdown in the IPCClient dtor, if needed.
  • Qt Applet: Fixed loading of default decision and decision method settings.

Updating

If you are using Fedora or the USBGuard Copr repository, run:

$ sudo dnf update --enablerepo=updates-testing usbguard

Download

Signed release tarball can be downloaded from the USBGuard release page at GitHub:

SHA256(usbguard-0.6.2.tar.gz)= dad33da0312b95a3a41434a7b5bbd03f5ec7096f6ea9ee238ad2f15908bc51fd
]]>