Repository navigation
[Security] Stop USB device names from being executed as Hyprland Lua - #8129
Conversation
bc3794a to
bef7ee6
Compare
There was a problem hiding this comment.
Pull request overview
Replaces executable input-device toggle state with plain data and hardens monitor-name interpolation against Lua injection.
Changes:
- Adds data-only device persistence and migration cleanup.
- Validates monitor connector names before Lua interpolation.
- Adds security, migration, and XDG-path tests.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 8 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
bin/omarchy-toggle-input-device |
Safely quotes and persists device names. |
bin/omarchy-hyprland-monitor-clamshell |
Validates internal monitor names. |
bin/omarchy-hyprland-monitor-internal |
Validates generated monitor state. |
bin/omarchy-hyprland-monitor-internal-mirror |
Validates mirror output names. |
bin/omarchy-hyprland-monitor-scaling |
Validates focused output names. |
default/hypr/disabled-input-device.lua |
Loads disabled-device names as data. |
default/hypr/paths.lua |
Handles empty XDG variables. |
default/hypr/toggles.lua |
Applies persisted device disables. |
manual/13-toggles-idle-screensaver.md |
Documents data-based persistence. |
migrations/1787618700.sh |
Migrates legacy generated Lua state. |
test/shell.d/hyprland-paths-test.sh |
Tests XDG path behavior. |
test/shell.d/monitor-output-name-test.sh |
Tests monitor-name validation. |
test/shell.d/toggle-input-device-test.sh |
Tests injection prevention and migration. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Hyprland input-device and monitor names come from USB descriptors and hyprctl output, so they are attacker-influenceable, yet the toggle and monitor commands interpolated them straight into hyprctl eval and into generated Lua that Hyprland re-executes on every reload. The input-device toggle keys are bound with locked = true, so a malicious USB name reached Lua code execution from the lock screen; a persisted disable made it run on every start. This closes that class everywhere it appeared. - The touchpad/touchscreen disable is now the device name in a plain-text sidecar file, read back by a packaged Lua module on reload, never a generated Lua file. hyprctl eval Lua-quotes the name and control characters are rejected outright. - Dropped the shipped *-disabled.lua templates so nothing seeds a disabled state to /etc/skel, making the name file the single source of truth read from a hardcoded ~/.local/state to match the sibling tools. - The reload loader excludes those two legacy filenames, so a leftover generated *-disabled.lua on a not-yet-migrated install can never be sourced as code again; a migration then recovers the device name from it and deletes it, sanitizing installs that ran the vulnerable version. - All four monitor scripts (internal, mirror, clamshell, scaling) now validate an output name against a plain-connector-name pattern before writing it as Lua, closing the same latent pattern in the siblings. - paths.lua treats a set-but-empty XDG_STATE_HOME as unset, matching the bash side so state is never read from the filesystem root. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0144ZDt44vtxjyF8j9Y88NrM
bef7ee6 to
a73351a
Compare
|
Notes: XF86TouchpadOn (HID F22) also triggers the immediate path, though not the persistent LUA path. XF86TouchpadOff (HID F23) does nothing (seemingly remapped to actual F23). HID Ctrl+Super+F24 should also take the HID F21 (XF86TouchpadToggle) path, both immediate trigger and persistent LUA, according to Claude but I was not able to reproduce it. |
lua discards the status of a chunk read from stdin, so a blown assert printed its traceback and still exited 0: the surrounding `set -euo pipefail` never fired and the following `pass` printed `ok`. Every Lua block in these two files was unenforced, including the assertion that a quoted `hyprctl eval` cannot reach `os.execute` and the negative control that proves the test can detect the injection at all. Passing the chunk as a script argument makes lua report the failure. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Reviewed at The injection fix holds up. Neither of us found an input that escapes the new Lua literal: backslashes are doubled before quotes are escaped, so Pushed one fix, 6b8caa0. Every One thing left for you. A user who had their touchpad or touchscreen disabled gets it back enabled for the rest of the session after an update. The pacman PostTransaction hook in Same class, but not this PR's job. Tests. Both earlier Copilot comments were valid against Last thing worth knowing: #7898 is a competing fix for the same vulnerability, and #8145 rewrites |
The package hook reloads Hyprland during `omarchy-update-system-pkgs`, before `omarchy-migrate` runs, and at that reload the generated Lua is already excluded while the name file does not exist yet — so a touchpad or touchscreen the user had switched off comes back on, and stays on until their next login. Reload once more once the name has been recovered, which is the same path a login already takes to read it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Co-Authored-By: Codex XHigh <[email protected]>
|
Pushed The fix. The migration now reloads once after it has recovered the device name, so a disable the user had set survives the update instead of waiting for their next login. It reloads only when there is a name file to re-apply, and it goes through Verified against a real compositor. The part worth reporting is the negative control: with the loader from One limit worth stating plainly. Hyprland exposes no readback for a device's enabled state — Tests. Codex at xhigh found this defect, so it is co-authored on the commit. Nothing further is open against this PR from my side. The |
…(backport of #8129) Backport of the input-device name fix (PR #8129 by @acrogenesis, merged to quattro as 9285b19) onto the v4-0-1 release branch. Hyprland input-device and monitor names come from USB descriptors and hyprctl output, so they are attacker-influenceable, yet the toggle and monitor commands interpolated them straight into hyprctl eval and into generated Lua that Hyprland re-executes on every reload. XF86TouchpadToggle is bound with locked = true, so a malicious USB name reached Lua execution from the lock screen as the logged-in user, and a persisted disable made it run on every start. Publicly reported by Jorrit Jongma / Chainfire. The disable is no longer executable Lua anywhere. The device name is stored as plain-text data in a *-disabled-name sidecar and read back by a packaged module, default/hypr/disabled-input-device.lua, on every reload; the live hyprctl eval Lua-quotes the name and rejects control characters outright. The reload loader excludes the two legacy filenames, so a leftover generated *-disabled.lua on a not-yet-migrated install can never be sourced as code again, and a migration recovers the device name from it and deletes it, sanitizing installs that ran the vulnerable version. All four monitor scripts validate an output name against a plain-connector-name pattern before writing it as Lua, closing the same latent pattern in the siblings, and paths.lua treats a set-but-empty XDG_STATE_HOME as unset to match the bash side. Clean cherry-pick: all fourteen files are byte-identical to quattro, so merging v4-0-1 into quattro resolves without a conflict. This branch ships no leftover *-disabled.lua template of its own -- the tracked "disabled" files are the same two quattro has -- so the migration is the only path that has to sanitize anything here. test/shell passes: 192 files, including the three this adds. The toggle suite's public-PoC case passes here, as do the monitor scripts' accept/reject cases and the XDG path cases. test/cli passes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018DEMYa9UWtroz93DhMTtcV
Extend the coverage added in the previous commit with the edge cases worth nailing down before this touches a live desktop's monitor state: - Negative coordinates round-trip (a monitor above/left of the origin). - A corrupted or injection-crafted position state file is validated on read and never forwarded into the generated hyprctl eval string, mirroring the omacom#8129 hardening for the internal connector name. - A non-integer reported position is never remembered in the first place. - A manual internal-monitor disable keeps the clamshell layer from touching scale or position at all. - A poll tick re-running disable_internal while already docked does not clobber the remembered value with a disabled panel's empty read. - Two successive dock/undock cycles track a rearranged position without leaking a stale one from the first cycle. - A live scale-drift correction (panel never disabled) carries the remembered position instead of slipping back to "auto". - A configured position variable reference, and the catch-all rule's own position, are both confirmed against precedence: a rule specific to the internal output wins, a remembered value beats the catch-all, and the catch-all's position is never read for the internal panel. Also made the hyprctl stub list an external monitor alongside the internal one, like real `hyprctl monitors all -j` output, so every case in the file exercises the by-name jq selection instead of a single-monitor array that could never expose a selection bug. Verified these fail without the previous commit's fix (reverted the script only, kept the new tests: fails immediately on "clamshell disable remembers internal position"). Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BHyQocSji8JUDRNaaQsK7M
Extend the coverage added in the previous commit with the edge cases worth nailing down before this touches a live desktop's monitor state: - Negative coordinates round-trip (a monitor above/left of the origin). - A corrupted or injection-crafted position state file is validated on read and never forwarded into the generated hyprctl eval string, mirroring the omacom#8129 hardening for the internal connector name. - A non-integer reported position is never remembered in the first place. - A manual internal-monitor disable keeps the clamshell layer from touching scale or position at all. - A poll tick re-running disable_internal while already docked does not clobber the remembered value with a disabled panel's empty read. - Two successive dock/undock cycles track a rearranged position without leaking a stale one from the first cycle. - A live scale-drift correction (panel never disabled) carries the remembered position instead of slipping back to "auto". - A configured position variable reference, and the catch-all rule's own position, are both confirmed against precedence: a rule specific to the internal output wins, a remembered value beats the catch-all, and the catch-all's position is never read for the internal panel. Also made the hyprctl stub list an external monitor alongside the internal one, like real `hyprctl monitors all -j` output, so every case in the file exercises the by-name jq selection instead of a single-monitor array that could never expose a selection bug. Verified these fail without the previous commit's fix (reverted the script only, kept the new tests: fails immediately on "clamshell disable remembers internal position"). Co-Authored-By: Claude Opus 5 <[email protected]>
…macom#8129) * Stop device names from being executed as Hyprland Lua Hyprland input-device and monitor names come from USB descriptors and hyprctl output, so they are attacker-influenceable, yet the toggle and monitor commands interpolated them straight into hyprctl eval and into generated Lua that Hyprland re-executes on every reload. The input-device toggle keys are bound with locked = true, so a malicious USB name reached Lua code execution from the lock screen; a persisted disable made it run on every start. This closes that class everywhere it appeared. - The touchpad/touchscreen disable is now the device name in a plain-text sidecar file, read back by a packaged Lua module on reload, never a generated Lua file. hyprctl eval Lua-quotes the name and control characters are rejected outright. - Dropped the shipped *-disabled.lua templates so nothing seeds a disabled state to /etc/skel, making the name file the single source of truth read from a hardcoded ~/.local/state to match the sibling tools. - The reload loader excludes those two legacy filenames, so a leftover generated *-disabled.lua on a not-yet-migrated install can never be sourced as code again; a migration then recovers the device name from it and deletes it, sanitizing installs that ran the vulnerable version. - All four monitor scripts (internal, mirror, clamshell, scaling) now validate an output name against a plain-connector-name pattern before writing it as Lua, closing the same latent pattern in the siblings. - paths.lua treats a set-but-empty XDG_STATE_HOME as unset, matching the bash side so state is never read from the filesystem root. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0144ZDt44vtxjyF8j9Y88NrM * Let a failing Lua assertion fail the test lua discards the status of a chunk read from stdin, so a blown assert printed its traceback and still exited 0: the surrounding `set -euo pipefail` never fired and the following `pass` printed `ok`. Every Lua block in these two files was unenforced, including the assertion that a quoted `hyprctl eval` cannot reach `os.execute` and the negative control that proves the test can detect the injection at all. Passing the chunk as a script argument makes lua report the failure. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * Re-apply a recovered input-device disable to the running session The package hook reloads Hyprland during `omarchy-update-system-pkgs`, before `omarchy-migrate` runs, and at that reload the generated Lua is already excluded while the name file does not exist yet — so a touchpad or touchscreen the user had switched off comes back on, and stays on until their next login. Reload once more once the name has been recovered, which is the same path a login already takes to read it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Co-Authored-By: Codex XHigh <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: Omarchybot <[email protected]> Co-authored-by: Codex XHigh <[email protected]>


A HID gadget can put an arbitrary string in the USB product/device name Hyprland reports.
omarchy-toggle-input-deviceinterpolated that name intohyprctl evaland into a generated Lua file under~/.local/state/omarchy/toggles/hypr/, which Hyprland sources on every start.XF86TouchpadToggle(HID F21) is bound withlocked = true, so this runs on a locked session as the logged-in user. Disable persists after the gadget is unplugged. Not network RCE and not root by itself; High for an evil-maid / malicious-USB take of the user account.Public report: Omarchy Exploit (Jorrit Jongma / Chainfire).
Fix
The disable is no longer executable Lua anywhere. The device name is stored as plain-text data in a
*-disabled-namesidecar and read back by a packaged module (default/hypr/disabled-input-device.lua) on every reload; the livehyprctl evalLua-quotes the name and rejects control characters outright. The old generated-Lua templates are dropped entirely — so nothing can seed a disabled state to/etc/skel— leaving the sidecar, read from a hardcoded~/.local/stateto match the sibling toggle tools, as the single source of truth.A migration recovers the device name from any already-generated toggle Lua and deletes the file, sanitizing installs that already ran the vulnerable version.
Same class, hardened alongside
Reviewing the fix surfaced the identical "hyprctl name → Lua" pattern in the monitor helpers. All four scripts that write an output name into Lua —
omarchy-hyprland-monitor-internal,-internal-mirror,-clamshell, and-scaling— now validate it against a plain-connector-name pattern before it can be written as code. Real connector names (eDP-1,DP-3, …) are unaffected; a user-created headless output carrying an arbitrary name is rejected.paths.luaalso now treats a set-but-emptyXDG_STATE_HOMEas unset, matching the bash side so state is never read from the filesystem root.Tests
test/shell.d/toggle-input-device-test.sh— Lua-quoting, data-only persistence, the public PoC string, migration recovery of real names, and the wedge / idempotence paths.test/shell.d/monitor-output-name-test.sh— each monitor script accepts a real connector and rejects a metacharacter-laced name.test/shell.d/hyprland-paths-test.sh— empty vs set XDG variables.