Skip to content

WIP: Add Keyboards dangerous keys protection

Ludovico de Nittis requested to merge denittis/mutter:usb_protection2 into main

This is related to GNOME Control Center MR gnome-control-center!462 (closed) and to gsettings-desktop-schemas MR gsettings-desktop-schemas!22 (closed) .

Context

A USB device with the keyboard HID class is not only a canonical physical keyboard, it can also be a gaming mouse, a yubikey or even a malicious device that pretends to be a keyboard. So what's the problem? The most famous USB attack is the so called BadUSB, where a pen drive advertise itself also as a keyboard, and once plugged in, it is capable of opening a terminal (e.g. ctrl+alt+t) and very quickly issue some malicious commands. The problem here is that we can't reliably know if a keyboard is legitimate or if it is an attacker device.

Proposed solution

We want to limit keyboards capabilities by default, preventing them to issue dangerous keys (like function keys, ctrl and alt) unless manually authorized by the user. For example a yubikey will never require to use the function keys, so a user will be able to use it even without granting it full privileges.

This is an attempt to considerably decrease the attack surface of USB devices.

This MR can be considered the second part/complementary of this one gnome-control-center!366 (merged) . Here we are trying to add more granularity. Instead of just a binary allowed/disallowed now it is possible to authorize and use a keyboard while still keeping it under restriction.

The current key dropping implementation requires a wayland session to work. We decided to do the filter in the userspace so that later on it will be easier to add extra functionalities, like showing a system notification when a user is attempting to press dangerous keys with an untrusted device.

Edited by Florian Müllner

Merge request reports