Display a warning dialog for unsafe URLs#20065
Conversation
We are getting a sufficient number of LLM-generated security reports telling us that Ctrl+click and a tooltip are insufficient protection from users clicking on links to dangerous things. This commit displays a warning that prevents users from blindly clicking on dangerous things. Dangerous things include: - any non-http and non-https and non-file URLs - any file URLs that point to something understandable as a "program" (so, something which resides in `PATHEXT`.) In doing this, I learned that `til::ends_with_insensitive_ascii` was broken. I also learned that ContentDialogs summoned by any event handler out of TermControl::Pointer* would lose focus immediately. It turns out that in the absolute earliest days of Terminal, when we first created the UserControl that became TermControl, we added our Tapped event handler. It unconditionally focused the control. Since `Tapped` is a higher-level event handler than `PointerPressed`, it was firing after the gesture that opened the content dialog and stealing focus back. I'm fairly certain we don't need it. Refs #7562
| <value>This link type is currently not supported:</value> | ||
| </data> | ||
| <data name="CouldNotOpenUriDialog.PrimaryButtonText" xml:space="preserve"> | ||
| <data name="UriErrorDialog.CloseButtonText" xml:space="preserve"> |
There was a problem hiding this comment.
I had to rename the dialog because of some business about xaml UIDs causing the wrong resources to be loaded when I changed the Cancel button from being the "Primary" button to correctly being the "Close" button.
| <value>Cancel</value> | ||
| </data> | ||
| <data name="UnsafeUrlConfirmText" xml:space="preserve"> | ||
| <value>This link may lead to an unsafe location. Hyperlinks can be harmful to your computer and data. To protect your computer, only click links from trusted sources.</value> |
There was a problem hiding this comment.
This messaging was used in Notepad. I do not recommend fighting it.
There was a problem hiding this comment.
Don't worry, I got you: I'm fighting it.
|
This looks like a really nice and much-needed improvement.
These might be riskier than local paths (e.g., remote execution or credential leaks), so I was curious if they should be handled differently. |
carlos-zamora
left a comment
There was a problem hiding this comment.
LGTM! Thanks for doing this!
| <value>Cancel</value> | ||
| </data> | ||
| <data name="UnsafeUrlConfirmText" xml:space="preserve"> | ||
| <value>This link may lead to an unsafe location. Hyperlinks can be harmful to your computer and data. To protect your computer, only click links from trusted sources.</value> |
There was a problem hiding this comment.
Don't worry, I got you: I'm fighting it.
We are getting a sufficient number of LLM-generated security reports telling us that Ctrl+click and a tooltip are insufficient protection from users clicking on links to dangerous things. This commit displays a warning that prevents users from blindly clicking on dangerous things. Dangerous things include: - any non-http and non-https and non-file URLs - any file URLs that point to something understandable as a "program" (so, something which resides in `PATHEXT`.) In doing this, I learned that `til::ends_with_insensitive_ascii` was broken. I also learned that ContentDialogs summoned by any event handler out of TermControl::Pointer* would lose focus immediately. It turns out that in the absolute earliest days of Terminal, when we first created the UserControl that became TermControl, we added our Tapped event handler. It unconditionally focused the control. Since `Tapped` is a higher-level event handler than `PointerPressed`, it was firing after the gesture that opened the content dialog and stealing focus back. I'm fairly certain we don't need it. Refs #7562 (cherry picked from commit 81170af) Service-Card-Id: PVTI_lADOAF3p4s4BQX0-zgpOYmc Service-Version: 1.25
We are getting a sufficient number of LLM-generated security reports telling us that Ctrl+click and a tooltip are insufficient protection from users clicking on links to dangerous things. This commit displays a warning that prevents users from blindly clicking on dangerous things. Dangerous things include: - any non-http and non-https and non-file URLs - any file URLs that point to something understandable as a "program" (so, something which resides in `PATHEXT`.) In doing this, I learned that `til::ends_with_insensitive_ascii` was broken. I also learned that ContentDialogs summoned by any event handler out of TermControl::Pointer* would lose focus immediately. It turns out that in the absolute earliest days of Terminal, when we first created the UserControl that became TermControl, we added our Tapped event handler. It unconditionally focused the control. Since `Tapped` is a higher-level event handler than `PointerPressed`, it was firing after the gesture that opened the content dialog and stealing focus back. I'm fairly certain we don't need it. Refs #7562 (cherry picked from commit 81170af) Service-Card-Id: PVTI_lADOAF3p4s4BBcTlzgpOYmk Service-Version: 1.24
We are getting a sufficient number of LLM-generated security reports telling us that Ctrl+click and a tooltip are insufficient protection from users clicking on links to dangerous things. This commit displays a warning that prevents users from blindly clicking on dangerous things. Dangerous things include: - any non-http and non-https and non-file URLs - any file URLs that point to something understandable as a "program" (so, something which resides in `PATHEXT`.) In doing this, I learned that `til::ends_with_insensitive_ascii` was broken. I also learned that ContentDialogs summoned by any event handler out of TermControl::Pointer* would lose focus immediately. It turns out that in the absolute earliest days of Terminal, when we first created the UserControl that became TermControl, we added our Tapped event handler. It unconditionally focused the control. Since `Tapped` is a higher-level event handler than `PointerPressed`, it was firing after the gesture that opened the content dialog and stealing focus back. I'm fairly certain we don't need it. Refs microsoft#7562
This adds a `safeUriSchemes` global setting which lets you define
hyperlink URI schemes which the user considers safe. No confirmation
dialog will be shown when trying to open hyperlinks which use these
schemes.
- This solves the root issue, but doesn't introduce any UI or
documentation changes. I wanted to validate the approach and
implementation with you first.
- I closely followed the code handling the `disabledProfileSources`
setting, which is of the same type.
- This feature does not change the behavior of `http`, `https` and
`file` schemes.
Validation
I ran the dev terminal, and tested the behavior by clicking on `vscode`
hyperlinks generated by ripgrep with various `safeUriSchemes` settings:
- Setting not defined - asks for confirmation
- `["vscode"]` - does not ask for confirmation
- `["foo", "vscode"]` - does not ask for confirmation
- `["foo"]` - asks for confirmation
- `null` - asks for confirmation
- `[]` - asks for confirmation
- `[""]` - asks for confirmation
- `[{"foo": "bar"}]` - fails to deserialize (as expected)
A few uinit tests failed, but they seem unrelated to these changes:
- `KeyBindingTests` in `UnitTests_SettingsModel`, probably because I use
an AZERTY keyboard.
- A few `Conhost` tests, but I didn't touch this part
Refs #20065
Closes #20191
This adds a `safeUriSchemes` global setting which lets you define
hyperlink URI schemes which the user considers safe. No confirmation
dialog will be shown when trying to open hyperlinks which use these
schemes.
- This solves the root issue, but doesn't introduce any UI or
documentation changes. I wanted to validate the approach and
implementation with you first.
- I closely followed the code handling the `disabledProfileSources`
setting, which is of the same type.
- This feature does not change the behavior of `http`, `https` and
`file` schemes.
Validation
I ran the dev terminal, and tested the behavior by clicking on `vscode`
hyperlinks generated by ripgrep with various `safeUriSchemes` settings:
- Setting not defined - asks for confirmation
- `["vscode"]` - does not ask for confirmation
- `["foo", "vscode"]` - does not ask for confirmation
- `["foo"]` - asks for confirmation
- `null` - asks for confirmation
- `[]` - asks for confirmation
- `[""]` - asks for confirmation
- `[{"foo": "bar"}]` - fails to deserialize (as expected)
A few uinit tests failed, but they seem unrelated to these changes:
- `KeyBindingTests` in `UnitTests_SettingsModel`, probably because I use
an AZERTY keyboard.
- A few `Conhost` tests, but I didn't touch this part
Refs #20065
Closes #20191
(cherry picked from commit fb71a04)
Service-Card-Id: PVTI_lADOAF3p4s4BBcTlzgshlaM
Service-Version: 1.24
This adds a `safeUriSchemes` global setting which lets you define
hyperlink URI schemes which the user considers safe. No confirmation
dialog will be shown when trying to open hyperlinks which use these
schemes.
- This solves the root issue, but doesn't introduce any UI or
documentation changes. I wanted to validate the approach and
implementation with you first.
- I closely followed the code handling the `disabledProfileSources`
setting, which is of the same type.
- This feature does not change the behavior of `http`, `https` and
`file` schemes.
Validation
I ran the dev terminal, and tested the behavior by clicking on `vscode`
hyperlinks generated by ripgrep with various `safeUriSchemes` settings:
- Setting not defined - asks for confirmation
- `["vscode"]` - does not ask for confirmation
- `["foo", "vscode"]` - does not ask for confirmation
- `["foo"]` - asks for confirmation
- `null` - asks for confirmation
- `[]` - asks for confirmation
- `[""]` - asks for confirmation
- `[{"foo": "bar"}]` - fails to deserialize (as expected)
A few uinit tests failed, but they seem unrelated to these changes:
- `KeyBindingTests` in `UnitTests_SettingsModel`, probably because I use
an AZERTY keyboard.
- A few `Conhost` tests, but I didn't touch this part
Refs #20065
Closes #20191
(cherry picked from commit fb71a04)
Service-Card-Id: PVTI_lADOAF3p4s4BQX0-zgshlaI
Service-Version: 1.25

We are getting a sufficient number of LLM-generated security reports telling us that Ctrl+click and a tooltip are insufficient protection from users clicking on links to dangerous things.
This commit displays a warning that prevents users from blindly clicking on dangerous things.
Dangerous things include:
PATHEXT.)In doing this, I learned that
til::ends_with_insensitive_asciiwas broken.I also learned that ContentDialogs summoned by any event handler out of TermControl::Pointer* would lose focus immediately. It turns out that in the absolute earliest days of Terminal, when we first created the UserControl that became TermControl, we added our Tapped event handler.
It unconditionally focused the control.
Since
Tappedis a higher-level event handler thanPointerPressed, it was firing after the gesture that opened the content dialog and stealing focus back.I'm fairly certain we don't need it.
Refs #7562