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 · 48 comments

Comments

Projects
None yet
6 participants
@marmarek
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

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Mar 8, 2015

Member

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.

Member

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 added a commit that referenced this issue Jun 9, 2016

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Sep 19, 2016

Member

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.

Member

marmarek commented Sep 19, 2016

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

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird Sep 19, 2016

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

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

@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Nov 11, 2016

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.

Contributor

jpouellet commented Nov 11, 2016

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

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird 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 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

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird Nov 11, 2016

@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: 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

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Nov 11, 2016

Contributor

@rustybird Good point.

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

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

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird Nov 11, 2016

@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.

@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

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Nov 11, 2016

Member

@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).

Member

marmarek commented Nov 11, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Nov 11, 2016

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.

Contributor

jpouellet commented Nov 11, 2016

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

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Nov 11, 2016

Member

\o/

Member

marmarek commented Nov 11, 2016

\o/

@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Nov 11, 2016

Contributor

I'll whip up a patch then. :)

Contributor

jpouellet commented Nov 11, 2016

I'll whip up a patch then. :)

@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Nov 11, 2016

Contributor

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

Contributor

jpouellet commented Nov 11, 2016

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

@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Nov 11, 2016

Contributor

@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?

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

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Nov 11, 2016

Member

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.

Member

marmarek commented Nov 11, 2016

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

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Nov 11, 2016

Member

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

Member

marmarek commented Nov 11, 2016

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

@v6ak

This comment has been minimized.

Show comment
Hide comment
@v6ak

v6ak 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.

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

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird Nov 11, 2016

@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?

@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

Implement "secure-pause" shortcut
Ctrl-Alt-Shift-p pauses all VMs.

Partial solution to QubesOS/qubes-issues#881

@jpouellet jpouellet referenced this issue in QubesOS/qubes-gui-daemon Nov 11, 2016

Closed

Implement "secure-pause" shortcut #8

@v6ak

This comment has been minimized.

Show comment
Hide comment
@v6ak

v6ak 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.)

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

This comment has been minimized.

Show comment
Hide comment
@andrewdavidwong

andrewdavidwong Nov 11, 2016

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. 😄

Member

andrewdavidwong commented Nov 11, 2016

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. 😄

@rustybird

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird Nov 13, 2016

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

I'd really love to know that too. Launching xbindkeys might be another option.

For Xfce only (must be run as the regular user, not root):

shortcut() {
    for sub in default custom; do
        xfconf-query --channel xfce4-keyboard-shortcuts \
                     --property "/commands/$sub/$1" \
                     --type string --create --set "$2"
    done
}

shortcut '<Control><Shift><Alt>p' 'qvm-run --pause --all'
shortcut '<Control><Alt>Escape'   'qvm-xkill'

<Super>p could be used instead of <Control><Shift><Alt>p above, if overriding the shortcut for the Display settings (also available via System Tools) is okay.

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

I'd really love to know that too. Launching xbindkeys might be another option.

For Xfce only (must be run as the regular user, not root):

shortcut() {
    for sub in default custom; do
        xfconf-query --channel xfce4-keyboard-shortcuts \
                     --property "/commands/$sub/$1" \
                     --type string --create --set "$2"
    done
}

shortcut '<Control><Shift><Alt>p' 'qvm-run --pause --all'
shortcut '<Control><Alt>Escape'   'qvm-xkill'

<Super>p could be used instead of <Control><Shift><Alt>p above, if overriding the shortcut for the Display settings (also available via System Tools) is okay.

@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Nov 14, 2016

Contributor

@rustybird I'd prefer to use whatever already-provided shortcut mechanism we have rather than adding another (like xbindkeys), for two reasons:

  1. It avoids adding another thing to dom0
  2. It allows users to re-configure their keyboard shortcuts in the native way they would expect to for their respective window managers. Using the xfce graphical keyboard shortcut editor, or opening your i3 config in $EDITOR and searching for the shortcut you wish to change is a natural thing. Having to first figure out where the shortcuts are actually coming from violates the principle of least surprise.
Contributor

jpouellet commented Nov 14, 2016

@rustybird I'd prefer to use whatever already-provided shortcut mechanism we have rather than adding another (like xbindkeys), for two reasons:

  1. It avoids adding another thing to dom0
  2. It allows users to re-configure their keyboard shortcuts in the native way they would expect to for their respective window managers. Using the xfce graphical keyboard shortcut editor, or opening your i3 config in $EDITOR and searching for the shortcut you wish to change is a natural thing. Having to first figure out where the shortcuts are actually coming from violates the principle of least surprise.
@rustybird

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird Nov 14, 2016

@jpouellet:

I'd prefer to use whatever already-provided shortcut mechanism we have rather than adding another (like xbindkeys), for two reasons: [...]

Agreed. Also, xbindkeys has too many dependencies (guile and tcl, tk)

@jpouellet:

I'd prefer to use whatever already-provided shortcut mechanism we have rather than adding another (like xbindkeys), for two reasons: [...]

Agreed. Also, xbindkeys has too many dependencies (guile and tcl, tk)

@v6ak

This comment has been minimized.

Show comment
Hide comment
@v6ak

v6ak Nov 14, 2016

I have nothing against configurability of keyboard shortcuts. I just wanted to discuss some reasonable default.

v6ak commented Nov 14, 2016

I have nothing against configurability of keyboard shortcuts. I just wanted to discuss some reasonable default.

@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Nov 23, 2016

Contributor

So, can we reach consensus on a good keyboard shortcut to use? That's the only thing I'm blocking on for implementing this.

Proposed solutions are:

  • Ctrl+Shift+P
  • Ctrl+Alt+Shift+P
  • Meta+P (and if so, potentially shift Ctrl+Shift+{C,V} to Meta+{C,V} for consistency?)

We could also overload Ctrl+Alt+Esc (kill window) to pause everything first as well. This may be undesired and counter-intuitive to potential users though, idk.


I personally like the idea of reserving an entire modifier (e.g. Meta) for "trusted shortcuts". This could be used as a non-conflicting subset of the keyboard modifier namespace reserved for Qubes, trusted window-management (e.g. to prove a password prompt is truly a window of a trusted VM and not just being drawn inside a less-trusted window), etc.

We could prevent all keypress events with this modifier from reaching the guest, such that it becomes much harder for a guest to guess when a trusted keyboard shortcut is about to be delivered for various GUI-related attacks (as you can currently do by sniffing Ctrl+Shift).

I have been considering making a separate proposal to this effect, but wanted to come up with a PoC first.

Contributor

jpouellet commented Nov 23, 2016

So, can we reach consensus on a good keyboard shortcut to use? That's the only thing I'm blocking on for implementing this.

Proposed solutions are:

  • Ctrl+Shift+P
  • Ctrl+Alt+Shift+P
  • Meta+P (and if so, potentially shift Ctrl+Shift+{C,V} to Meta+{C,V} for consistency?)

We could also overload Ctrl+Alt+Esc (kill window) to pause everything first as well. This may be undesired and counter-intuitive to potential users though, idk.


I personally like the idea of reserving an entire modifier (e.g. Meta) for "trusted shortcuts". This could be used as a non-conflicting subset of the keyboard modifier namespace reserved for Qubes, trusted window-management (e.g. to prove a password prompt is truly a window of a trusted VM and not just being drawn inside a less-trusted window), etc.

We could prevent all keypress events with this modifier from reaching the guest, such that it becomes much harder for a guest to guess when a trusted keyboard shortcut is about to be delivered for various GUI-related attacks (as you can currently do by sniffing Ctrl+Shift).

I have been considering making a separate proposal to this effect, but wanted to come up with a PoC first.

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Nov 23, 2016

Member

I like Ctrl+Shift+P - for consistency and harder to press accidentally (unlike Meta+P). On the other hand, my cat is able to press Alt+Ctrl+F2 - I have no idea how ;)

As for entire modifier for trusted operations - IMO it should be something more than just one key - otherwise surely we'll have some conflict. For example Meta+Tab is one of few methods for switching focus inside Windows VM (in non-seamless mode). Maybe Meta+Alt or such. But then, it will not have this nice effect of being totally invisible to VMs...

Member

marmarek commented Nov 23, 2016

I like Ctrl+Shift+P - for consistency and harder to press accidentally (unlike Meta+P). On the other hand, my cat is able to press Alt+Ctrl+F2 - I have no idea how ;)

As for entire modifier for trusted operations - IMO it should be something more than just one key - otherwise surely we'll have some conflict. For example Meta+Tab is one of few methods for switching focus inside Windows VM (in non-seamless mode). Maybe Meta+Alt or such. But then, it will not have this nice effect of being totally invisible to VMs...

@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Nov 24, 2016

Contributor
Contributor

jpouellet commented Nov 24, 2016

@jpouellet jpouellet referenced this issue in QubesOS/qubes-desktop-linux-xfce4 Nov 25, 2016

Merged

Mitigate GUI DoS (part 1) #4

@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Nov 25, 2016

Contributor

@rustybird can you elaborate on what problem your xkill alternative solves?

Contributor

jpouellet commented Nov 25, 2016

@rustybird can you elaborate on what problem your xkill alternative solves?

@rustybird

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird Nov 25, 2016

@jpouellet xkill doesn't allow selecting VM windows without a title bar, but xdotool windowselect/windowkill does.

@jpouellet xkill doesn't allow selecting VM windows without a title bar, but xdotool windowselect/windowkill does.

@v6ak

This comment has been minimized.

Show comment
Hide comment
@v6ak

v6ak Nov 25, 2016

I like Ctrl+Shift+P - for consistency

Yes, it is more consistent with current defaults for clipboard.

harder to press accidentally (unlike Meta+P)

OK, unlike copy&paste, this one is expected to be used rather rarely and the hard-to-reach approach looks good. But still, I would like the shortcut to include Meta, in order to be less likely to collide with an existing keyboard shortcut.

For example Meta+Tab is one of few methods for switching focus inside Windows VM (in non-seamless mode).

Maybe I am opposing something else, but: I did not suggest that we should remap all well-known shortcuts like Alt+Tab or Alt+F4. Since they are well-known, they are unlikely to collide with app's shortcuts. OTOH, for new shortcuts (unknown for large part of world) should IMHO include it.

OT: I usually use Meta+Alt+Tab, this works well on both Ubuntu (the WM used in Unity) and Windows.

Maybe Meta+Alt or such. But then, it will not have this nice effect of being totally invisible to VMs...

Hmm, invisibility to VMs looks interesting, but I am not sure if I want this. For example, on both Windows (either on HVM or over RDP) and Ubuntu, I frequently use Meta to open system menu. But maybe, the press of Meta could be delayed and passed iff no Qubes global key shortcut is used. This would make all reasonable behavior (Win+Tab, Meta for system menu, …) I can think of still working, while it would hide the keypresses when using functions like PauseAll, InterVmCopy and InterVmPaste.

In reality all my applications only need ctrl (1) or alt (2).

Try IntelliJ IDEA, you'll get nice shortcuts like Ctrl+Alt+Shift+C…

It is so incredibly rare to find a program which cares whether left or right ctrl/alt is pressed that I think we can safely reassign the lesser-used side.

Counter-examples:

  • Some keyboard layouts map right alt to something special (called “Alt Gr”). I remember that standard Czech keyboard does so (needed for keys like “\”, “&”, “@” or “€”) and I believe there are some other relatively common layouts (maybe Polish layout or various Cyrillic layouts) doing the same.
  • For Ctrl, Remmina is a notable exception. (Also VirtualBox, but who would run Virtualbox under Qubes…?) I cannot imagine using Remmina on Qubes if one of Ctrl keys was used by Qubes.

This idea has one more issue: What is the lesser-used side? Touch-typists will probably press Ctrl with the other hand (e.g., CtrlR+C, CtrlR+Q, CtrlL+L, CtrlL+K on traditional keyboards with QWERTY layout). Before touch-typing, I used to use the same hand (e.g., CtrlL+C, CtrlL+Q, CtrlR+L, CtrlR+K). Having to use only one of the Ctrls would be painful with traditional keyboard layout. (Well, I could handle it on Ergodox keyboard, because all the modifiers are well reachable by thumbs and I can modify the layout, but still…)

v6ak commented Nov 25, 2016

I like Ctrl+Shift+P - for consistency

Yes, it is more consistent with current defaults for clipboard.

harder to press accidentally (unlike Meta+P)

OK, unlike copy&paste, this one is expected to be used rather rarely and the hard-to-reach approach looks good. But still, I would like the shortcut to include Meta, in order to be less likely to collide with an existing keyboard shortcut.

For example Meta+Tab is one of few methods for switching focus inside Windows VM (in non-seamless mode).

Maybe I am opposing something else, but: I did not suggest that we should remap all well-known shortcuts like Alt+Tab or Alt+F4. Since they are well-known, they are unlikely to collide with app's shortcuts. OTOH, for new shortcuts (unknown for large part of world) should IMHO include it.

OT: I usually use Meta+Alt+Tab, this works well on both Ubuntu (the WM used in Unity) and Windows.

Maybe Meta+Alt or such. But then, it will not have this nice effect of being totally invisible to VMs...

Hmm, invisibility to VMs looks interesting, but I am not sure if I want this. For example, on both Windows (either on HVM or over RDP) and Ubuntu, I frequently use Meta to open system menu. But maybe, the press of Meta could be delayed and passed iff no Qubes global key shortcut is used. This would make all reasonable behavior (Win+Tab, Meta for system menu, …) I can think of still working, while it would hide the keypresses when using functions like PauseAll, InterVmCopy and InterVmPaste.

In reality all my applications only need ctrl (1) or alt (2).

Try IntelliJ IDEA, you'll get nice shortcuts like Ctrl+Alt+Shift+C…

It is so incredibly rare to find a program which cares whether left or right ctrl/alt is pressed that I think we can safely reassign the lesser-used side.

Counter-examples:

  • Some keyboard layouts map right alt to something special (called “Alt Gr”). I remember that standard Czech keyboard does so (needed for keys like “\”, “&”, “@” or “€”) and I believe there are some other relatively common layouts (maybe Polish layout or various Cyrillic layouts) doing the same.
  • For Ctrl, Remmina is a notable exception. (Also VirtualBox, but who would run Virtualbox under Qubes…?) I cannot imagine using Remmina on Qubes if one of Ctrl keys was used by Qubes.

This idea has one more issue: What is the lesser-used side? Touch-typists will probably press Ctrl with the other hand (e.g., CtrlR+C, CtrlR+Q, CtrlL+L, CtrlL+K on traditional keyboards with QWERTY layout). Before touch-typing, I used to use the same hand (e.g., CtrlL+C, CtrlL+Q, CtrlR+L, CtrlR+K). Having to use only one of the Ctrls would be painful with traditional keyboard layout. (Well, I could handle it on Ergodox keyboard, because all the modifiers are well reachable by thumbs and I can modify the layout, but still…)

@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Nov 26, 2016

Contributor

@v6ak Okay, so clearly this needs more thought and feedback. Thank you for your feedback :)

Some specific responses in this case:

  • Some keyboard layouts map right alt to something special (called “Alt Gr”). I remember that standard Czech keyboard does so (needed for keys like “\”, “&”, “@” or “€”) and I believe there are some other relatively common layouts (maybe Polish layout or various Cyrillic layouts) doing the same.

It is relatively common for french keyboards to have such a key too. In linux, this is often mapped to the compose key which was my #4 above.

  • For Ctrl, Remmina is a notable exception. (Also VirtualBox, but who would run Virtualbox under Qubes…?) I cannot imagine using Remmina on Qubes if one of Ctrl keys was used by Qubes.

IMO If a suggested change gives a significant benefit to all Qubes users (and I admit this remains to be proven in this case) at the cost of a small subset of people needing to remap a key, I think this is a fine outcome. https://xkcd.com/1172/

This idea has one more issue: What is the lesser-used side? Touch-typists will probably press Ctrl with the other hand

Indeed, this is an oversight on my part. I touch-type and use only my left ctrl/alt. I falsely assumed this was true for others.

It still sounds reasonable to me to think that we could assign a single key as a qubes-modifier. Which key, however, remains an open question.

Contributor

jpouellet commented Nov 26, 2016

@v6ak Okay, so clearly this needs more thought and feedback. Thank you for your feedback :)

Some specific responses in this case:

  • Some keyboard layouts map right alt to something special (called “Alt Gr”). I remember that standard Czech keyboard does so (needed for keys like “\”, “&”, “@” or “€”) and I believe there are some other relatively common layouts (maybe Polish layout or various Cyrillic layouts) doing the same.

It is relatively common for french keyboards to have such a key too. In linux, this is often mapped to the compose key which was my #4 above.

  • For Ctrl, Remmina is a notable exception. (Also VirtualBox, but who would run Virtualbox under Qubes…?) I cannot imagine using Remmina on Qubes if one of Ctrl keys was used by Qubes.

IMO If a suggested change gives a significant benefit to all Qubes users (and I admit this remains to be proven in this case) at the cost of a small subset of people needing to remap a key, I think this is a fine outcome. https://xkcd.com/1172/

This idea has one more issue: What is the lesser-used side? Touch-typists will probably press Ctrl with the other hand

Indeed, this is an oversight on my part. I touch-type and use only my left ctrl/alt. I falsely assumed this was true for others.

It still sounds reasonable to me to think that we could assign a single key as a qubes-modifier. Which key, however, remains an open question.

jpouellet added a commit to jpouellet/qubes-core-admin-linux that referenced this issue Nov 27, 2016

Mitigate GUI DoS (part 2: qvm-xkill)
Can close windows of a VM while it's paused, and can not accidentally
harm dom0 by errant clicking.

Discussion in QubesOS/qubes-issues#881

Thanks to rustybird for suggested implementation.

@jpouellet jpouellet referenced this issue in QubesOS/qubes-core-admin-linux Nov 27, 2016

Merged

Mitigate GUI DoS (part 2: qvm-xkill) #14

@jpouellet

This comment has been minimized.

Show comment
Hide comment
Contributor

jpouellet commented Nov 27, 2016

jpouellet added a commit to jpouellet/qubes-core-admin-linux that referenced this issue Nov 27, 2016

Mitigate GUI DoS (part 2: qvm-xkill)
Can close windows of a VM while it's paused, and can not accidentally
harm dom0 by errant clicking.

Discussion in QubesOS/qubes-issues#881

Thanks to rustybird for assistance.
@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Nov 27, 2016

Contributor

Closed by commit prematurely.

Still needs:

  • window killing mechanism
  • documentation
Contributor

jpouellet commented Nov 27, 2016

Closed by commit prematurely.

Still needs:

  • window killing mechanism
  • documentation

@marmarek marmarek reopened this Nov 27, 2016

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Nov 27, 2016

Member

It will get closed few more times ;) Anyway I prefer this way, because we'll get here notification when packages got uploaded to some repository.

Member

marmarek commented Nov 27, 2016

It will get closed few more times ;) Anyway I prefer this way, because we'll get here notification when packages got uploaded to some repository.

@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Nov 28, 2016

Contributor

@marmarek So does that mean I should continue to use "fixes ..." in the case of relevant commits even when they do not completely fix an issue?

I used "addresses ..." instead in:

Contributor

jpouellet commented Nov 28, 2016

@marmarek So does that mean I should continue to use "fixes ..." in the case of relevant commits even when they do not completely fix an issue?

I used "addresses ..." instead in:

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Nov 28, 2016

Member

For builder-github notification, I'd say use "fixes ..." in the last commit related to the issue, in given repository - this will result in notification at appropriate time (all relevant changes released). So, if "partially fixes" means "more work to do in this repository, not done yet" - use something else (personally I add bare issue reference, without any prefix), but if it means "the other part is in another repository" - add "fixes" prefix.
Yes, I know, this is abuse of this syntax. But IMO it's still better than inventing our own.

Member

marmarek commented Nov 28, 2016

For builder-github notification, I'd say use "fixes ..." in the last commit related to the issue, in given repository - this will result in notification at appropriate time (all relevant changes released). So, if "partially fixes" means "more work to do in this repository, not done yet" - use something else (personally I add bare issue reference, without any prefix), but if it means "the other part is in another repository" - add "fixes" prefix.
Yes, I know, this is abuse of this syntax. But IMO it's still better than inventing our own.

@v6ak

This comment has been minimized.

Show comment
Hide comment
@v6ak

v6ak Dec 22, 2016

It still sounds reasonable to me to think that we could assign a single key as a qubes-modifier. Which key, however, remains an open question.

I think this is the point we agree. I just believe that the key could be Meta Super, while you prefer RCtrl.

v6ak commented Dec 22, 2016

It still sounds reasonable to me to think that we could assign a single key as a qubes-modifier. Which key, however, remains an open question.

I think this is the point we agree. I just believe that the key could be Meta Super, while you prefer RCtrl.

@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Dec 22, 2016

Contributor

I just believe that the key could be Meta, while you prefer RCtrl.

Not sure where you get that idea. I am currently using left alt. From watching xev output it appears that I do not have a Meta key. I believe you mean Super key again. I think Super makes a lot of sense, given how other OSes also use it for their own OS shortcuts (speaking especially of Windows here), and accordingly it seems comparatively sparingly used by user applications.

Regardless, it doesn't matter much to me what key is actually chosen, but rather just that some key be chosen. It can then be configurable to allow for people with weird layouts (or strong preferences, or wanting to reserve it for an inner Windows VM or such) to adjust accordingly, as @andrewdavidwong stated he wanted.

It appears to me that we are blocking only on identifying a non-controversial default. I vote for @rustybird's suggestion of the "Side view of four qubes waving around, suggesting inter-qube data flow" key :) At least on my keyboard this key maps as Super.

Contributor

jpouellet commented Dec 22, 2016

I just believe that the key could be Meta, while you prefer RCtrl.

Not sure where you get that idea. I am currently using left alt. From watching xev output it appears that I do not have a Meta key. I believe you mean Super key again. I think Super makes a lot of sense, given how other OSes also use it for their own OS shortcuts (speaking especially of Windows here), and accordingly it seems comparatively sparingly used by user applications.

Regardless, it doesn't matter much to me what key is actually chosen, but rather just that some key be chosen. It can then be configurable to allow for people with weird layouts (or strong preferences, or wanting to reserve it for an inner Windows VM or such) to adjust accordingly, as @andrewdavidwong stated he wanted.

It appears to me that we are blocking only on identifying a non-controversial default. I vote for @rustybird's suggestion of the "Side view of four qubes waving around, suggesting inter-qube data flow" key :) At least on my keyboard this key maps as Super.

@andrewdavidwong

This comment has been minimized.

Show comment
Hide comment
@andrewdavidwong

andrewdavidwong Dec 23, 2016

Member

I vote for @rustybird's suggestion of the "Side view of four qubes waving around, suggesting inter-qube data flow" key :) At least on my keyboard this key maps as Super.

It's astonishing that keyboard manufacturers were able to foresee the rise of Qubes so many years ago. 😄

Member

andrewdavidwong commented Dec 23, 2016

I vote for @rustybird's suggestion of the "Side view of four qubes waving around, suggesting inter-qube data flow" key :) At least on my keyboard this key maps as Super.

It's astonishing that keyboard manufacturers were able to foresee the rise of Qubes so many years ago. 😄

@v6ak

This comment has been minimized.

Show comment
Hide comment
@v6ak

v6ak Dec 25, 2016

Not sure where you get that idea. I am currently using left alt.

Neither am I. Maybe I got the idea of RCtrl after reading your idea of using left/right ctrl/alt and after thinking of usage of RCtrl in Remmina/VirtualBox.

It can then be configurable to allow for people with weird layouts

It looks like we mostly agree there. However, the configurability can be either (a) user configures the Qubes key and all shortcuts are configured automatically then (so, shortcuts would look like QubesKey+C, QubesKey+V, and QubesKey would be defined elsewhere), or (b) user configures all shortcuts separately. This has both technical and functional consequences:

  1. Obviously, users have diffferent configuration experience.
  2. Variant (a) requires handling the shortuts by some Qubes daemon rather than by DE. Variant (b) allows both.
  3. Both variants allow not sending the QubesKey scancode to the VM until it is clear user does not want to press any Qubes shortcut, but this requires handling all the Qubes-related shortcuts by Qubes.

Few examples for not sending QubesKey scancode too early:

Maybe it is not clear why we should want this, so I'll describe some examples. It would hide scancodes of the Qubes shortcuts. However, it would allow usage of shortcuts like Super+R or just Super, even when QubesKey = Super.

If it is not clear how it should behave generally, I could write some pseudocode that handles all those shortcuts this way. (Maybe I could write few variants with different handling of some edge cases.)

Let QubesKey = Super, CopyShortcut = QubesKey + C. Consider few scenarios. I write all of them as sequences. When multiple events are written in one list item, I don't care about their order. No scancodes are sent to VM unless I explicitly write so.

Copying

  1. User: Press Super
  2. User: Press C
  3. Qubes: InterVmCopy; Qubes notes that some keyboard shortcut has been pressed.
  4. User: Release both Super and C (in any order)

Using Win+R shortcut in a HVM (useful with Windows)

I've intentionally written this scenario with releasing R before releasing the Win, because it is more complex.

  1. User: Press Super
  2. User: Press R
  3. Qubes realizes that {Super, R} is not a subset of any Qubes-managed shortcut, so it will send all scancodes since now.
  4. Qubes: Send keydown event of {Super, R} to the VM.
  5. User releases R.
  6. Qubes: Send keyup event of R
  7. User releases Super.
  8. Qubes: Send keyup event of Super
  9. Qubes now realizes that no keys are pressed, so it disables sending all the shortcuts and switches back to filtering keys.

Using Win (i.e., Super) to open Start Menu / Dash in a Windows / Ubuntu HVM

Note: Similar scenarios would be tricky to support fully for long common prefixes of Qubes-managed shortcuts. But I believe this is rather edge case.

  1. User: Press Super
  2. User: Release Super
  3. Qubes realizes that all keys are released and key filtering is still on. This implies that the keys have been filtered, but no Qubes-managed shortcut was used.
  4. Qubes: Send keydown event of Super
  5. Qubes: Send keyup event of Super

people with weird layouts

Like me? :) https://twitter.com/v6ak/status/720648320528551936

v6ak commented Dec 25, 2016

Not sure where you get that idea. I am currently using left alt.

Neither am I. Maybe I got the idea of RCtrl after reading your idea of using left/right ctrl/alt and after thinking of usage of RCtrl in Remmina/VirtualBox.

It can then be configurable to allow for people with weird layouts

It looks like we mostly agree there. However, the configurability can be either (a) user configures the Qubes key and all shortcuts are configured automatically then (so, shortcuts would look like QubesKey+C, QubesKey+V, and QubesKey would be defined elsewhere), or (b) user configures all shortcuts separately. This has both technical and functional consequences:

  1. Obviously, users have diffferent configuration experience.
  2. Variant (a) requires handling the shortuts by some Qubes daemon rather than by DE. Variant (b) allows both.
  3. Both variants allow not sending the QubesKey scancode to the VM until it is clear user does not want to press any Qubes shortcut, but this requires handling all the Qubes-related shortcuts by Qubes.

Few examples for not sending QubesKey scancode too early:

Maybe it is not clear why we should want this, so I'll describe some examples. It would hide scancodes of the Qubes shortcuts. However, it would allow usage of shortcuts like Super+R or just Super, even when QubesKey = Super.

If it is not clear how it should behave generally, I could write some pseudocode that handles all those shortcuts this way. (Maybe I could write few variants with different handling of some edge cases.)

Let QubesKey = Super, CopyShortcut = QubesKey + C. Consider few scenarios. I write all of them as sequences. When multiple events are written in one list item, I don't care about their order. No scancodes are sent to VM unless I explicitly write so.

Copying

  1. User: Press Super
  2. User: Press C
  3. Qubes: InterVmCopy; Qubes notes that some keyboard shortcut has been pressed.
  4. User: Release both Super and C (in any order)

Using Win+R shortcut in a HVM (useful with Windows)

I've intentionally written this scenario with releasing R before releasing the Win, because it is more complex.

  1. User: Press Super
  2. User: Press R
  3. Qubes realizes that {Super, R} is not a subset of any Qubes-managed shortcut, so it will send all scancodes since now.
  4. Qubes: Send keydown event of {Super, R} to the VM.
  5. User releases R.
  6. Qubes: Send keyup event of R
  7. User releases Super.
  8. Qubes: Send keyup event of Super
  9. Qubes now realizes that no keys are pressed, so it disables sending all the shortcuts and switches back to filtering keys.

Using Win (i.e., Super) to open Start Menu / Dash in a Windows / Ubuntu HVM

Note: Similar scenarios would be tricky to support fully for long common prefixes of Qubes-managed shortcuts. But I believe this is rather edge case.

  1. User: Press Super
  2. User: Release Super
  3. Qubes realizes that all keys are released and key filtering is still on. This implies that the keys have been filtered, but no Qubes-managed shortcut was used.
  4. Qubes: Send keydown event of Super
  5. Qubes: Send keyup event of Super

people with weird layouts

Like me? :) https://twitter.com/v6ak/status/720648320528551936

@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Mar 22, 2017

Contributor

Remaining tasks:

Contributor

jpouellet commented Mar 22, 2017

Remaining tasks:

@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet May 21, 2017

Contributor

Fixes: ... OK for tracking, but this should not be closed yet. See above.

Contributor

jpouellet commented May 21, 2017

Fixes: ... OK for tracking, but this should not be closed yet. See above.

@CarpeNoctem

This comment has been minimized.

Show comment
Hide comment
@CarpeNoctem

CarpeNoctem May 11, 2018

Did this get implemented recently, or in Qubes 4.x in general as Ctrl+Shift+P?
As you know, Firefox is the default browser in Qubes.
Ctrl+Shift+P is the hotkey in Firefox to open a new Private Browsing window. I use this quite frequently, for sanity checking and viewing URLs as a non-logged-in user, etc.

This used to work on my Qubes 3.x machines. I'm not sure if it has ever worked on my new 4.x (GA, not beta) install, but a few times recently when I've tried opening a new Private Browsing window in Firefox, my whole machine appears to get into what appears to be a corrupted state.
Took me a while to figure out that what was happening was all of my VMs getting paused. :(

Did this get implemented recently, or in Qubes 4.x in general as Ctrl+Shift+P?
As you know, Firefox is the default browser in Qubes.
Ctrl+Shift+P is the hotkey in Firefox to open a new Private Browsing window. I use this quite frequently, for sanity checking and viewing URLs as a non-logged-in user, etc.

This used to work on my Qubes 3.x machines. I'm not sure if it has ever worked on my new 4.x (GA, not beta) install, but a few times recently when I've tried opening a new Private Browsing window in Firefox, my whole machine appears to get into what appears to be a corrupted state.
Took me a while to figure out that what was happening was all of my VMs getting paused. :(

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek May 11, 2018

Member

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.

Member

marmarek commented May 11, 2018

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

This comment has been minimized.

Show comment
Hide comment
@CarpeNoctem

CarpeNoctem May 11, 2018

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. ]

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

This comment has been minimized.

Show comment
Hide comment
@CarpeNoctem

CarpeNoctem May 11, 2018

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).

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

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet May 11, 2018

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@v6ak

v6ak May 11, 2018

v6ak commented May 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment