Repository navigation
Conversation
Touchpad and touchscreen names come from the peripheral's own USB descriptors, so a device whose name contains a double quote could break out of the Lua string literal in omarchy-toggle-input-device: both the live hyprctl eval and the persisted toggle state file that Hyprland sources on every config reload. That turned a malicious or compromised peripheral into arbitrary Lua execution as the session user, persistent across restarts. Add omarchy-lua-quote, which escapes the only characters that can break out of or corrupt a double-quoted Lua literal (backslash, double quote, raw newline, carriage return) while leaving the name byte-for-byte intact so it still matches what Hyprland reports, and use it for both sinks. 🤖 Generated by Kimi K3 in OpenCode. Reviewed by Codex XHigh. Co-authored-by: Codex XHigh <[email protected]>
There was a problem hiding this comment.
Pull request overview
Escapes attacker-controlled input device names before embedding them in live and persisted Lua expressions.
Changes:
- Adds a Lua string-escaping helper.
- Uses escaped names in both toggle paths.
- Adds escaping tests for hostile characters.
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 1 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
bin/omarchy-lua-quote |
Adds Lua literal escaping. |
bin/omarchy-toggle-input-device |
Escapes device names before Lua interpolation. |
test/cli |
Tests escaping behavior and injection payloads. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # USB device names are peripheral-controlled and land inside double-quoted Lua | ||
| # string literals (hyprctl eval, persisted toggle state files), so the quoting | ||
| # helper must keep hostile names inside the literal. | ||
| output=$(omarchy-lua-quote 'ELAN1200:00 04F3:30BA Touchpad') |
|
Reviewed against What
Nothing in this pull request is missing from Checked by Claude Opus 5.5 and by Codex Medium as a second opinion; Codex reached the same conclusion, with independence from this review not guaranteed. Waiting on the maintainer to close it. |
Touchpad and touchscreen names come from the peripheral's own USB string descriptors, so they are attacker-controlled data: a malicious or compromised device can report a name containing a double quote.
omarchy-toggle-input-deviceembedded that name unescaped into two Lua string literals — the livehyprctl eval "hl.device({ name = \"$device\", ... })"call and the persisted toggle state file under~/.local/state/omarchy/toggles/hypr/, which Hyprland sources on every config reload. A crafted device name could therefore execute arbitrary Lua as the session user, immediately and persistently across restarts.The fix adds a small
omarchy-lua-quotehelper that escapes the only characters able to break out of or corrupt a double-quoted Lua literal — backslash first so the later escapes stay literal, then double quote, then raw newline and carriage return, which Lua rejects inside a short literal — and leaves every other byte untouched, so the quoted name still matches what Hyprland reports.omarchy-toggle-input-devicequotes the name once and uses the quoted form for both sinks. Newtest/clicases pin the behavior against a plain device name, embedded quotes, backslashes, newlines, carriage returns, and a full breakout payload, and the quoted output was verified against Lua 5.4 to parse as a pure string literal and round-trip byte-for-byte.Reviewed by Codex at xhigh effort: it round-tripped every non-NUL byte through Lua 5.4 and 5.5 against both sink expressions and found no exploitable defect or regression; the carriage-return test case its review prompted is part of the change.
🤖 Generated by Kimi K3 in OpenCode. Reviewed by Codex XHigh.