-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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: only allow browser-window #7205
Conversation
a6def7c
to
4994c00
Compare
I wonder whether it is possible to enable security for ws upgrade request on express level, not on level of |
packages/core/src/electron-node/token/electron-token-backend-contribution.ts
Outdated
Show resolved
Hide resolved
packages/core/src/electron-node/token/electron-token-backend-contribution.ts
Show resolved
Hide resolved
packages/core/src/electron-node/token/electron-token-backend-contribution.ts
Outdated
Show resolved
Hide resolved
packages/core/src/electron-node/token/electron-token-backend-contribution.ts
Outdated
Show resolved
Hide resolved
packages/core/src/electron-node/token/electron-token-backend-module.ts
Outdated
Show resolved
Hide resolved
packages/core/src/electron-node/token/electron-token-validator.ts
Outdated
Show resolved
Hide resolved
@marechal-p Could you reference a relevant bugzilla please? i.e. https://bugs.eclipse.org/bugs/show_bug.cgi?id=551747 |
9a0a909
to
2af89f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works good for me. Please look at comments though.
Only allow http request from Electron's own browser-window. Token is generated within electron-main, which also sets it as a cookie within browser-windows. Token is passed to the backend via environment variables. The backend is looking for this specific token to authorize requests. Fixes https://bugs.eclipse.org/bugs/show_bug.cgi?id=551747 Signed-off-by: Paul Maréchal <paul.marechal@ericsson.com>
2af89f6
to
7cc8b32
Compare
} | ||
|
||
isTokenValid(token: ElectronSecurityToken): boolean { | ||
return typeof token === 'object' && token.value === this.electronSecurityToken!.value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer a constant-time comparison algorithm here to prevent timing attacks (e.g. crypto.timingSafeEqual https://nodejs.org/api/crypto.html#crypto_crypto_timingsafeequal_a_b)
What it does
Only allow http request from Electron's own browser-window. Token is
generated within electron-main, which also sets it as a cookie within
browser-windows. Token is passed to the backend via environment
variables. The backend is looking for this specific token to authorize
requests.
How to test
Everything should keep working when running Electron. Make sure we can also display html previews. You should not be able to load
http://localhost:<dynamic-port>
in your browser anymore.Review checklist
Reminder for reviewers