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

Expose the setSupportMultipleWindows in Android to fix CVE-2020-6506 #1663

Closed

Conversation

mrcoinbase
Copy link

This PR exposes the setSupportMultipleWindows setting in Android to fix CVE-2020-6506. Let me know if there is anything missing from this PR. I suspect this may cause strange behavior in applications that assumed that this would be false by default.

@cristianoccazinsp
Copy link
Contributor

Do we also need to set it to false to mitigate the XSS vulnerability?

@mrcoinbase
Copy link
Author

Thanks for checking @cristianoccazinsp . By default, if it is true it will mitigate the vulnerability.

I'm following the similar fix that was used in google flutter https://github.com/flutter/plugins/pull/2991/files#diff-43c39528992b7b93988dcd7d78478281R129

Copy link
Member

@jamonholmgren jamonholmgren left a comment

Choose a reason for hiding this comment

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

Thank you @mrcoinbase! I believe if they set supportMultipleWindows to true, that we would also need a onCreateWindow method implementation, so this isn't quite complete. Do you have an idea of how we would handle that?

(For reference, this is how Flutter did it: https://github.com/flutter/plugins/pull/2991/files#diff-43c39528992b7b93988dcd7d78478281R77)

@@ -1281,6 +1282,20 @@ Example:
<WebView autoManageStatusBarEnabled={false} />
```

### `setSupportMultipleWindows`

Sets whether the WebView supports multiple windows. See [Android documentation]('https://developer.android.com/reference/android/webkit/WebSettings#setSupportMultipleWindows(boolean)') for more information.
Copy link
Member

Choose a reason for hiding this comment

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

Could you mention the vulnerability if they set this to false?

Copy link
Author

Choose a reason for hiding this comment

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

Sure, good idea!

@mrcoinbase
Copy link
Author

@jamonholmgren This appears to be the place we would add oncreatewindow. I'm not sure why flutter added it in their PR. https://github.com/flutter/plugins/pull/2991/files#diff-43c39528992b7b93988dcd7d78478281R96-R103 this is apparently to check if the url is secure. I'm not sure if we need to implement and override the method here:

Then again, this is just some guest development. If you believe we need to override that method and make changes, let me know.

@mrcoinbase
Copy link
Author

Also @jamonholmgren, it seems that oncreate is used to make it vulnerable, but doesn't need to be modified to protect it, see 'How to identify vulnerable apps' in https://alesandroortiz.com/articles/uxss-android-webview-cve-2020-6506

@jamonholmgren
Copy link
Member

@mrcoinbase Apologies on the delay, we're having CircleCI issues.

Copy link
Member

@jamonholmgren jamonholmgren left a comment

Choose a reason for hiding this comment

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

CircleCI issues are resolved. I think we're ready to merge this. It will be a breaking change.

Actually, our internal team has additional conversations to have here before merging. Sorry about the delay, this is not a straightforward merge.

@jamonholmgren jamonholmgren added the Maintainer: ready to publish This PR has been reviewed and is ready to be published label Oct 22, 2020
@mrcoinbase
Copy link
Author

@jamonholmgren thanks so much!

@abumalick
Copy link

abumalick commented Oct 30, 2020

We are really looking forward updating our apps with these changes.

Can you merge and publish it please?

@Titozzz
Copy link
Collaborator

Titozzz commented Nov 3, 2020

I don't believe you should set it to true without adding more logic to the code.

I understand the security issue is annoying, but there is more to be done to mitigate:

Vendors generally have two choices to mitigate for unpatched WebView users:

Enable multiwindow support. If needed, implementation options exist to mimic single-window behavior and minimize breaking changes. Does not require multi-tab UI. Suitable for browsers and frameworks.
or
Keep multiwindow support disabled, and strictly limit WebView rendering to trusted content only. Suitable for non-browser apps, and for frameworks when used in non-browser apps.

The "implementation options exist to mimic single-window behavior and minimize breaking changes." is missing I believe.

Maybe I'm wrong, as I'm not an android expert, far from it :( ! So if you still believe this is not going to break stuff and also fix the issue lmk ❤️

@Titozzz Titozzz added the User: question Further information is requested label Nov 3, 2020
@cmcewen
Copy link

cmcewen commented Nov 6, 2020

Hi! Any help needed here? I would love to fix our yarn audit 🙏

@jamonholmgren jamonholmgren removed the Maintainer: ready to publish This PR has been reviewed and is ready to be published label Nov 6, 2020
@Titozzz
Copy link
Collaborator

Titozzz commented Nov 6, 2020

Hello everyone again 👋 .

We tried out that pull request on a test project with @jamonholmgren, but setting setSupportMultipleWindows to true without implementing onWindowCreate break current the webview functionality, clicking on a link with target blank won't do anything instead of opening in the current window.

If we want to merge this, we need to come up with an onCreateWindow implementation that opens in the existing window, that way it's not breaking for anyone.

Thanks you in advance for taking time to fix this.

@jamonholmgren jamonholmgren self-requested a review November 6, 2020 22:55
Copy link
Collaborator

@Titozzz Titozzz left a comment

Choose a reason for hiding this comment

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

See last comment

@jamonholmgren
Copy link
Member

jamonholmgren commented Nov 6, 2020

To test this, enable supportMulitpleWindows and try any webpage with a link that tries to open a new window. For example, on my website the "blog" link opens in a new tab. Tapping "blog" should open in the existing window.

When we tried to do this using the existing PR, tapping "Blog" simply didn't do anything, which is undesirable.

<WebView
  source={{uri: "https://infinite.red"}}
  style={{width: "100%", height: "100%"}}
/>

@cmcewen
Copy link

cmcewen commented Nov 7, 2020

Thanks for testing y'all. The original post (https://alesandroortiz.com/articles/uxss-android-webview-cve-2020-6506/) links to a Flutter mitigation (https://github.com/flutter/plugins/pull/2991/files) which we can probably adapt. Trying to get a release out, but I can give it a try in a few days if no one else gets to it first

@kelset
Copy link
Contributor

kelset commented Nov 17, 2020

Hey folks, is there any update on when this fix will be merged or an equivalent one will be ready to address the CVE?

@Titozzz
Copy link
Collaborator

Titozzz commented Nov 17, 2020

As long as #1663 (comment) isn't solved, we cannot merge this. Please note that this is a security issue only if users don't have webview up to date AND you load urls you don't know inside your webview, so you can definitely mitigate it by blocking untrustworthy domains if security is your concern. If the goal is just to have the CVE disappear, cause its annoying to have a "security issue" with yarn audit or such, well it's not fixed yet.

@v-almonacid
Copy link

@Titozzz sorry if this might be a bit slightly off topic, but do you know if there is a way to create a blacklist for any http/https connections in react native? so that I can make sure that there is no dependency communicating with some server without me being aware of it

@jamonholmgren
Copy link
Member

Closing in favor of #1747 -- thank you @mrcoinbase for your work on this (I noted you in the release notes!)

@mrcoinbase
Copy link
Author

Thanks! Sorry I didn't have time to devote to fixing those issues. That would be a problem.

Also, @Titozzz agreed on that this closes an inconvenient CVE, but for real security purposes it's better to just not to iframe untrusted domains.

@mrcoinbase mrcoinbase deleted the mr/cve-2020-6506 branch November 24, 2020 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
User: question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants