Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement protection from GUI "DoS" attacks #881

Open
marmarek opened this issue Mar 8, 2015 · 52 comments · Fixed by QubesOS/qubes-desktop-linux-xfce4#4 or QubesOS/qubes-desktop-linux-manager#29
Labels
C: gui-virtualization help wanted This issue will probably not get done in a timely fashion without help from community contributors. P: major Priority: major. Between "default" and "critical" in severity.

Comments

@marmarek
Copy link
Member

marmarek commented Mar 8, 2015

Reported by omeg on 5 Jul 2014 11:00 UTC
VMs can make life in dom0 hard by displaying override-redirect windows or just making a lot of them. This can be prevented by implementing a method to temporarily hide all VM windows and disable any GUI output. This may be a configurable hotkey (guid.conf).

Migrated-From: https://wiki.qubes-os.org/ticket/881


Note to any contributors who wish to work on this issue: Please either ask for details or propose a design before starting serious work on this.

@marmarek marmarek added this to the Release 2.1 (post R2) milestone Mar 8, 2015
@marmarek marmarek added enhancement C: gui-virtualization P: major Priority: major. Between "default" and "critical" in severity. labels Mar 8, 2015
@marmarek
Copy link
Member Author

marmarek commented Mar 8, 2015

Comment by joanna on 26 Sep 2014 20:00 UTC
For now you can press Alt-F2 (in KDE) and get a "command prompt" this way.

@andrewdavidwong andrewdavidwong added the help wanted This issue will probably not get done in a timely fashion without help from community contributors. label Jun 9, 2016
andrewdavidwong added a commit that referenced this issue Jun 9, 2016
@marmarek
Copy link
Member Author

Poor man solution: press Ctrl-Alt-Esc and select a window to kill. This will terminate related GUI daemon, so all the window of given VM will be gone. Then launching anything in that VM will restart related GUI daemon, and bring back all the windows. In the meantime you may decide to kill the VM, access its console etc.

@rustybird
Copy link

Doesn't work with override_redirect windows though, apparently xkill ignores them.

@jpouellet
Copy link
Contributor

One possible solution would be additional trusted keyboard shortcuts.

A trusted shortcut (like control-shift-C) to pause the frontmost vm would at least prevent it from making any new windows. You are not able to close windows of a paused VM, but if you had another trusted keyboard shortcut to bring qubes-manager to the front (as I do), then you could kill the offending VM.

@rustybird
Copy link

rustybird commented Nov 11, 2016

@jpouellet: That's a clever idea! Maybe even have this keyboard shortcut pause all VMs, using qvm-run --pause --all? Otherwise, the DOSing VM could detect that Ctrl-Shift is being pressed (before the key combination is complete), close the window, and reopen it shortly afterwards.

@rustybird
Copy link

@jpouellet: And if all VMs are paused, the responsible GUI daemon can be killed race free by replacing Xfwm's current xkill keyboard shortcut with this (which works with both regular and override_redirect windows):

#!/bin/sh
set -e

ID=$(xdotool selectwindow)
xprop -id "$ID" _QUBES_VMNAME | grep -q ' = '  # safety check: don't kill dom0 windows
xdotool windowkill "$ID"

@jpouellet
Copy link
Contributor

jpouellet commented Nov 11, 2016

@rustybird Good point.

Is this something we want upstream? If so, which keys do you think make sense?

@rustybird
Copy link

@jpouellet:

Is this something we want upstream?

@marmarek, do you like this approach (and shipping xdotool in dom0)?

If so, which keys do you think make sense?

Ctrl-Shift-P for pause would be nice, but unfortunately github.com of all things uses this combo to switch between Preview and Write when writing comments. :|

The kill script above could bind to Ctrl-Alt-Esc, replacing xkill.

@marmarek
Copy link
Member Author

@marmarek, do you like this approach (and shipping xdotool in dom0)?

Yes, look fine!

As for key combo - maybe something even harder to press accidentally - Alt-Ctrl-Shift-P ?

Is it possible to cancel the killing script without actually killing anything - again - if pressed accidentally? I haven't found any way. Don't worry, just curious - I think xkill is also impossible to cancel (other than killing the process manually).

@jpouellet
Copy link
Contributor

Is it possible to cancel the killing script without actually killing anything - again - if pressed accidentally?

Yes, just click on any dom0 window, as it is then a noop.

@marmarek
Copy link
Member Author

\o/

@jpouellet
Copy link
Contributor

I'll whip up a patch then. :)

@jpouellet
Copy link
Contributor

@marmarek What is the preferred way to submit pull requests that span multiple repos?

@jpouellet
Copy link
Contributor

jpouellet commented Nov 11, 2016

@marmarek The easiest place to put these is in the xfwm shortcuts settings, but then it working depends on the desktop environment. Would gui-daemon/gui-daemon/xside.c like the ctrl-shift-c/v clipboard stuff be more appropriate?

@marmarek
Copy link
Member Author

Having it in gui-daemon would work only when VM window is active - so VM could avoid this by hiding the window as @rustybird explained. So, better do it as xfce shortcut. Then KDE, i3, awesome, ...

As for the script itself, it may be in gui-daemon, or core-admin-linux.

@marmarek
Copy link
Member Author

Maybe there is some generic standard for registering global keyboard shortcuts in desktop environments?

@v6ak
Copy link

v6ak commented Nov 11, 2016

I know I am going beyond scope of this post, but it is related: Global shortcuts (other than well-known like Alt+F4) should IMHO contain Meta key, because this key is usually not present in application-specific shortcuts:

  • The pause-all-VMs should do so. I am currently not aware of any collision with the current proposal, but I believe someone will find one.
  • The supercopy/superpaste also should do so. I had come collision (probably with IntelliJ IDEA), so I've remmaped them to Meta+C and Meta+V.
  • I am not suggesting to change default desktop environment mapping to something else. I am just suggesting that Qubes should not add more potential collisions.

@rustybird
Copy link

@v6ak: Do you mean the Super key(s)? I don't seem to have any Meta or Hyper keys on my Thinkpad, but the "Side view of four qubes waving around, suggesting inter-qube data flow" key maps to Super_L according to xev.

Also, do all keyboards relevant for Qubes have such keys?

jpouellet added a commit to jpouellet/qubes-gui-daemon that referenced this issue Nov 11, 2016
Ctrl-Alt-Shift-p pauses all VMs.

Partial solution to QubesOS/qubes-issues#881
@v6ak
Copy link

v6ak commented Nov 11, 2016

@rustybird You are right, I mean Super key. While there are various keyboard modifications, I don't remember any recent keyboard without Super key. (I don't count specialized keyboards like numpad-only.)

@andrewdavidwong
Copy link
Member

I use an IBM Model M manufactured in 1990. It doesn't have a Super key.

But as long as I can reassign the shortcut in /etc/qubes/guid.conf (or elsewhere), I'll be fine. 😄

@marmarek
Copy link
Member Author

Ough, that's indeed what is happening. So, we need a better shortcut. I wonder whether Ctrl+Win+P would be ok (and generally using Win key in default key combos)? I haven't seen any keyboard without this key for a looong time, but it might be region specific. Any opinions? @andrewdavidwong @rustybird @jpouellet @v6ak
I think we shouldn't use just Win/Super as default QubesKey (@v6ak comment above), because it's very useful for standard window manager actions (and AFAIR default window-manager key in i3). But maybe combined with Ctrl would be ok? Or Alt+Win/Super?

BTW There is also Ctrl+Shift+Alt+P to unpause all.

@CarpeNoctem
Copy link

Thanks! I see the commit now: marmarek/qubes-desktop-linux-xfce4@9459331
However, testing just now, Ctrl+Alt+Shift+P didn't unpause for me, and I got an error message from qvm-run --unpause --all
[EDIT: The reason unpause hotkey doesn't work for me is because Alt+Shift changes between keyboard layouts for me and is caught before the unpause sequence. The reason the qvm-run command didn't work for me is because the implementation seems to have been migrated to qvm-unpause --all. ]

@CarpeNoctem
Copy link

I should note, for anyone running into this - You can remove or change the hotkey for qvm-pause --all in the XFCE Keyboard settings dialog (Main menu -> System Tools -> Keyboard -> Application Shortcuts).

@jpouellet
Copy link
Contributor

jpouellet commented May 11, 2018

Yep. Conflicting keyboard shortcuts are definitely a problem, and not just for pausing.

My suggestion a year ago was to pick a qubes-specific modifier sequence used for all qubes keyboard shortcuts and let the user override it.

In practice this means having something listening for keyboard presses not configured by xfce4-keyboard-settings, which I'm not sure I like - too much "magic" and different entities with separate configuration that the user needs to be aware of. I think the idea at the time was that there was going to be some central gui for all qubes settings (incl. guid.conf, etc.) so that this behavior would be obvious to the user, but that has not happened.

Not sure what's best at this point.

@v6ak
Copy link

v6ak commented May 11, 2018 via email

@jpouellet
Copy link
Contributor

QubesOS/qubes-desktop-linux-manager#29 adds code (R4-only) to notify the user when all their VMs get paused, with a button to unpause them all. This should avoid unpleasant surprises for new users trying to get Firefox incognito windows (or whatever else Ctrl+Shift+P happens to be). Once we have offline docs, another button could link to how to change the keyboard shortcut for it.

A next step would be to have some heuristic in gui-daemon automatically trigger single-VM pausing & a similar notification (because chances are the user probably won't have read the docs for this feature or remember it if/when they need it).

jpouellet added a commit to jpouellet/qubes-desktop-linux-manager that referenced this issue Jul 30, 2018
Also includes a button in the notification to unpause all.

Addresses new user Ctrl+Shift+P => "what? why did my OS break!?"

Partially fixes: QubesOS/qubes-issues#881

Depends on domain-paused and domain-unpaused events.
@marmarek marmarek reopened this Sep 2, 2018
marmarek added a commit to marmarek/qubes-desktop-linux-xfce4 that referenced this issue Jan 28, 2019
First of all Ctrl+Alt+P is too common key combo (for example conflicts
with Firefox's "New Private Window"). But even if that wouldn't be true,
in the current shape it does more harm than good, because it is
not documented (hard to discover when actually needed), and also
pause system VMs which in case of sys-usb and USB keyboard is
fatal.

Lets rethink this first.

This reverts commit 9459331.
QubesOS/qubes-issues#881
QubesOS/qubes-issues#4101
Fixes QubesOS/qubes-issues#4700
marmarek added a commit to marmarek/qubes-desktop-linux-xfce4 that referenced this issue Jan 28, 2019
First of all Ctrl+Alt+P is too common key combo (for example conflicts
with Firefox's "New Private Window"). But even if that wouldn't be true,
in the current shape it does more harm than good, because it is
not documented (hard to discover when actually needed), and also
pause system VMs which in case of sys-usb and USB keyboard is
fatal.

Lets rethink this first.

This reverts commit 9459331.
And adds a script to adjust user configuration.
QubesOS/qubes-issues#881
QubesOS/qubes-issues#4101
Fixes QubesOS/qubes-issues#4700
@jpouellet
Copy link
Contributor

So, my initial attempt at solving this problem (QubesOS/qubes-desktop-linux-xfce4#4, QubesOS/qubes-core-admin-linux#14, QubesOS/qubes-desktop-linux-manager#29) was clearly not a desirable approach in retrospect, and ironically probably caused more accidental GUI self-DoSing (#4101, #4700) than actual mitigations of it.

It seems this is just not a common enough attack to warrant a solution that requires the user to be aware that such a mitigation ability exist, and also require intentional user (inter)action to make use of it. Some more nuanced heuristic-based approach in xside gui-daemon would be much more user-friendly, though may not even justify its own complexity.

Also, as @marmarek correctly points out in QubesOS/qubes-desktop-linux-xfce4#12, pausing all is not appropriate for the case where your input devices are not directly to dom0 (e.g. usb keyboard+mouse via sys-usb), because it creates a chicken-and-egg problem with having working input and unpausing the input-device(s) VM, so clearly the particular implementation was too heavy-handed.

I'm sorry to those I frustrated with the unfortunately-more-common-than-realized conflicting choice of keyboard shortcut.

@jpouellet
Copy link
Contributor

jpouellet commented Jun 22, 2019

That said... such GUI DoS situations do still arise, whether malicious or not, e.g. #4960

@v6ak
Copy link

v6ak commented Jun 22, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: gui-virtualization help wanted This issue will probably not get done in a timely fashion without help from community contributors. P: major Priority: major. Between "default" and "critical" in severity.
Projects
None yet
6 participants