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

Focus vulnerab fix #319

Merged
merged 4 commits into from
May 16, 2023
Merged

Focus vulnerab fix #319

merged 4 commits into from
May 16, 2023

Conversation

GioSensation
Copy link
Member

@GioSensation GioSensation commented May 15, 2023

Reviewer: @alistairjcbrown
Asana: https://app.asana.com/0/0/1204595906186359/f

Description

This addresses a potential clickjacking using the focus event. More info on Asana.

Steps to test

More info on Asana.

Signed-off-by: Emanuele Feliziani <feliziani.emanuele@gmail.com>
Signed-off-by: Emanuele Feliziani <feliziani.emanuele@gmail.com>
@GioSensation GioSensation self-assigned this May 15, 2023
Signed-off-by: Emanuele Feliziani <feliziani.emanuele@gmail.com>
Signed-off-by: Emanuele Feliziani <feliziani.emanuele@gmail.com>
const moved = new CustomEvent('mouseMove', {detail: {x: x + 50, y: y + 15}})
window.dispatchEvent(moved)
}, {x, y})
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hover state is passed by the native layer, so now we need to send it manually here in the tests.

previousY = event.detail.y
return
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the meat of the PR. Basically, it avoids setting the .currentFocus class if the mouse has not moved.

@@ -62,8 +62,10 @@ ${css}
this.autofillButtons.forEach((btn) => {
this.registerClickableButton(btn, () => {
// Fire only if the cursor is hovering the button
if (btn.matches('.tooltip__button:hover, .currentFocus')) {
if (btn.matches('.wrapper:not(.top-autofill) button:hover, .currentFocus')) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In these we check that the button does have the hover state, either the browser's native or our own .currentFocus.

.tooltip__button:hover .label,
.tooltip__button.currentFocus .label,
.tooltip__button:hover .label {
.wrapper:not(.top-autofill) .tooltip__button:hover .label {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were unnecessary duplicates.

@@ -106,7 +106,7 @@
border-radius: 6px;
}
.tooltip__button.currentFocus,
.tooltip__button:hover {
.wrapper:not(.top-autofill) .tooltip__button:hover {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hover state is only present in the in-page tooltips. If it's a top-autofill (the native webview) we use .currentFocus.

@GioSensation GioSensation marked this pull request as ready for review May 15, 2023 12:25
Copy link
Member

@alistairjcbrown alistairjcbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question, but LGTM :shipit:

safeExecute(this.activeButton, handler, {
checkVisibility: this.options.checkVisibility
})
if (this.activeButton.matches('.wrapper:not(.top-autofill) *:hover, .currentFocus')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Is there a reason we use *:hover here and button:hover for a similar check in src/UI/DataHTMLTooltip.js?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's because the in-context signup also has an anchor tag. I could have used the :is() selector but I'm not sure all our supported versions will work there.

@GioSensation GioSensation merged commit a95dd90 into main May 16, 2023
@GioSensation GioSensation deleted the ema/focus-vulnerab branch May 16, 2023 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants