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

electron: use timingSafeEqual to check token #7308

Merged
merged 1 commit into from
Mar 11, 2020

Conversation

paul-marechal
Copy link
Member

This should prevent an attacker from guessing the Electron token to
access an Electron application's local backend services.

Signed-off-by: Paul Maréchal [email protected]

What it does

Better safe than sorry, this PR addresses a comment made on the token implementation: #7205 (comment)

How to test

Hard to say, it would require trying to execute a purposeful timing attack, which I don't know how to do.

Review checklist

Reminder for reviewers

@paul-marechal paul-marechal added the electron issues related to the electron target label Mar 10, 2020
@paul-marechal
Copy link
Member Author

paul-marechal commented Mar 10, 2020

@phosphore Would this make the token comparison safer?

Copy link

@phosphore phosphore left a comment

Choose a reason for hiding this comment

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

LGTM! There's no immediate risk here, but it's a desirable security improvement! 👍

@akosyakov akosyakov added the security issues related to security label Mar 10, 2020
@akosyakov akosyakov requested a review from spoenemann March 10, 2020 15:45
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

The change looks fine to me, it is an improvement over the previous implementation.
I could also not find any regressions when running the electron application.

@paul-marechal paul-marechal force-pushed the mp/electron-token-safe branch 3 times, most recently from 871365c to efc12b1 Compare March 10, 2020 19:11
Copy link
Contributor

@marcdumais-work marcdumais-work left a comment

Choose a reason for hiding this comment

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

LGTM. I quickly confirmed that this change does not impede on the token check - the resulting Electron app still forbids a random browser request to its endpoints 👍

This should prevent an attacker from guessing the Electron token via a
timing attack to access an Electron application's local backend
services.

timingSafeEqual: https://nodejs.org/docs/latest-v10.x/api/crypto.html#crypto_crypto_timingsafeequal_a_b
Timing Attack: https://en.wikipedia.org/wiki/Timing_attack

Signed-off-by: Paul Maréchal <[email protected]>
@paul-marechal paul-marechal force-pushed the mp/electron-token-safe branch from efc12b1 to d9d15b7 Compare March 11, 2020 23:16
@paul-marechal paul-marechal merged commit fa39af3 into master Mar 11, 2020
@paul-marechal paul-marechal deleted the mp/electron-token-safe branch March 11, 2020 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron issues related to the electron target security issues related to security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants