Skip to content

Consider updating 30_security-misc.conf #349

@wakesend

Description

@wakesend

https://github.com/Kicksecure/security-misc/blob/master/etc/usbguard/rules.d/30_security-misc.conf%23security-misc-shared

I cherry-picked your config to harden multiple Debian 13s, and noticed those lines:

## Allow only one keyboard to be connected
allow with-interface equals { 03:01:01 } if !allowed-matches(with-interface equals { 03:01:01 })
## Allow only one mouse to be connected
allow with-interface equals { 03:01:02 } if !allowed-matches(with-interface equals { 03:01:02 })
  • Using equals here is incorrect
  • Also, if !allowed-matches may cause problems on some PCs

Using equals here is incorrect

allow with-interface equals { 03:01:01 } expect the USB-connected device have only ONE interface, 03:01:01.
The problem is there are many keyboard devices which has another interface

# cat /etc/usbguard/rules.conf|grep 03:01:01
allow id xxxx:xxxx serial "" name "Input Receiver" hash "xxxx" parent-hash "xxxx" via-port "X" with-interface { 03:01:01 03:01:02 } <---
allow id xxxx:xxxx serial "" name "Mouse" hash "xxxx" parent-hash "xxxx" via-port "X" with-interface { 03:01:02 03:00:01 03:01:01 }
allow id xxxx:xxxx serial "" name "Keyboard" hash "xxxx" parent-hash "xxxx" via-port "X with-interface 03:01:01 <-- my real USB keyboard

In my case, there is { 03:01:01 03:01:02 } device. "equals" won't match this device, thus will be denied.

if !allowed-matches mistake

Again, both rule uses "equals", expecting exact interface match.
What about this mouse: allow id xxxx:xxxx serial "" name "Mouse" hash "xxxx" parent-hash "xxxx" via-port "X" with-interface { 03:01:02 03:00:01 03:01:01 }, this is famous brand mouse. Your rule never apply to this because of "equals".

My suggestion

  • Simplify the rule, because there are many PCs which has internal keyboard-like device (e.g., some PC has keyboard-like device for PC's boot switch!)
  • This means "Allow only one" condition is not universal at all.
# Simply allow keyboard/mouse interface
allow with-interface one-of { 03:01:01 03:01:02 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions