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

core: fix origin checks problems #8865

Merged
merged 1 commit into from
Dec 16, 2020
Merged

core: fix origin checks problems #8865

merged 1 commit into from
Dec 16, 2020

Conversation

paul-marechal
Copy link
Member

@paul-marechal paul-marechal commented Dec 15, 2020

Both mini-browser and plugin-ext contributes WebSocket checks refuse
WebSocket connections originating from within their served content, but
it prevented all connections when serving from the {{hostname}}
pattern.

This commit handles the case when such a pattern is used and disables
the origin check in such a case.

This is not totally fool-proof as some host/pattern combinations can
still lead to problems.

e.g. host is sweet-potato.com and the pattern is
{{uuid}}-{{hostname}}. The generated regex will be ^.+-.+$ which
still matches sweet-potato.com.

You should always include a unique string inside the pattern to avoid
such situations, like {{uuid}}-webview-{{hostname}}.

This commit also moves the mini-browser file serving to
/mini-browser to avoid conflicts when hosting on the same root origin.

Signed-off-by: Paul paul.marechal@ericsson.com

Closes #8852

How to test

  • Set THEIA_MINI_BROWSER_HOST_PATTERN={{hostname}}.
  • Start the browser application.
  • It should work, master doesn't.

Review checklist

Reminder for reviewers

@paul-marechal paul-marechal added bug bugs found in the application mini-browser issues related to the mini-browser webviews issues related to webviews labels Dec 15, 2020
@paul-marechal
Copy link
Member Author

The goal of those checks was to make apps more secure by default by refusing expected origins (webview/mini-browser). An alternative would be to remove those checks and only rely on the THEIA_HOSTS mechanism. Waiting for input on this.

Both `mini-browser` and `plugin-ext` contributes WebSocket checks refuse
WebSocket connections originating from within their served content, but
it prevented all connections when serving from the `{{hostname}}`
pattern.

This commit handles the case when such a pattern is used and disables
the origin check in such a case.

This is not totally fool-proof as some host/pattern combinations can
still lead to problems.

e.g. host is `sweet-potato.com` and the pattern is
`{{uuid}}-{{hostname}}`. The generated regex will be `^.+-.+$` which
still matches `sweet-potato.com`.

You should always include a unique string inside the pattern to avoid
such situations, like `{{uuid}}-webview-{{hostname}}`.

This commit also moves the `mini-browser` file serving to
`/mini-browser` to avoid conflicts when hosting on the same root origin.

Signed-off-by: Paul <paul.marechal@ericsson.com>
@paul-marechal
Copy link
Member Author

We'll most likely merge this patch for tomorrow's release.

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.

@marechal-p the changes work well for me 👍

I verified that when the following is set export THEIA_MINI_BROWSER_HOST_PATTERN={{hostname}} on master, the application fails to successfully start due to websocket errors.

image

I confirmed that the changeset correctly works with the environment variable set on both macos and linux.

@paul-marechal paul-marechal merged commit 0761dcf into master Dec 16, 2020
@paul-marechal paul-marechal deleted the mp/origin-check-fix branch December 16, 2020 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application mini-browser issues related to the mini-browser webviews issues related to webviews
Projects
None yet
2 participants