[GH-ISSUE #2] [FEATURE] Implement Input Sanitization for Forbidden Key Combinations #1

Closed
opened 2026-10-30 21:32:18 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @joleuger on GitHub (Jan 1, 2026).
Original GitHub issue: https://github.com/joleuger/vuinputd/issues/2

Context & Motivation
Direct access to /dev/uinput allows application software to inject input events into the kernel. If a malicious or compromised application (even within a sandbox) gains access to a virtual device, it can abuse low-level kernel shortcuts.

Specifically, the following attack vectors exist:

  1. VT Switching: Injecting Ctrl+Alt+Fn allows an attacker to switch the active Virtual Terminal, potentially accessing an unsecured getty login prompt or disrupting the user's graphical session.
  2. Magic SysRq: Injecting Alt+SysRq+<command> allows an attacker to trigger low-level kernel commands (e.g., reboot, kill all processes, dump memory), which bypasses all userspace security controls.

To harden the system, vuinputd must act as a firewall, filtering these specific sequences before writing events to the kernel.

Technical Architecture
The sanitization logic will be implemented in the cuse write method of vuinputd before the write() syscall to /dev/uinput.

  1. State Tracking: The writer thread must maintain a minimal state machine to track the "pressed" status of modifier keys (Left/Right Ctrl, Left/Right Alt).
  2. Filter Logic:
  • VT Switch Detection: If Ctrl + Alt are held, drop any F1 through F12 key press events.
  • SysRq Detection: If Alt is held, drop the SysRq (PrintScreen) key press event.
  1. Drop Mechanism: Forbidden events must be silently discarded. They should not be forwarded to the kernel driver.
Originally created by @joleuger on GitHub (Jan 1, 2026). Original GitHub issue: https://github.com/joleuger/vuinputd/issues/2 **Context & Motivation** Direct access to `/dev/uinput` allows application software to inject input events into the kernel. If a malicious or compromised application (even within a sandbox) gains access to a virtual device, it can abuse low-level kernel shortcuts. Specifically, the following attack vectors exist: 1. **VT Switching:** Injecting `Ctrl+Alt+Fn` allows an attacker to switch the active Virtual Terminal, potentially accessing an unsecured `getty` login prompt or disrupting the user's graphical session. 2. **Magic SysRq:** Injecting `Alt+SysRq+<command>` allows an attacker to trigger low-level kernel commands (e.g., reboot, kill all processes, dump memory), which bypasses all userspace security controls. To harden the system, `vuinputd` must act as a firewall, filtering these specific sequences before writing events to the kernel. **Technical Architecture** The sanitization logic will be implemented in the cuse write method of `vuinputd` before the `write()` syscall to `/dev/uinput`. 1. **State Tracking:** The writer thread must maintain a minimal state machine to track the "pressed" status of modifier keys (Left/Right `Ctrl`, Left/Right `Alt`). 2. **Filter Logic:** * **VT Switch Detection:** If `Ctrl` + `Alt` are held, drop any `F1` through `F12` key press events. * **SysRq Detection:** If `Alt` is held, drop the `SysRq` (PrintScreen) key press event. 3. **Drop Mechanism:** Forbidden events must be silently discarded. They should not be forwarded to the kernel driver.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
joleuger/vuinputd#1
No description provided.