-
Notifications
You must be signed in to change notification settings - Fork 4
fix(WalletWebViewClient): restrict externally-launched URL schemes (refs #5) #55
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,20 @@ class WalletWebViewClient( | |
| // Open all foreign web pages and app schemes like "eid" for the AusweisApp | ||
| // externally. Only wwWallet code is allowed inside the app. | ||
| if (request.url.scheme != baseUrl.scheme || request.url.host != baseUrl.host) { | ||
| // Restrict the schemes we are willing to hand to startActivity. | ||
| // Without this guard a page rendered inside the wallet WebView can | ||
| // fire arbitrary `intent://`, `content://`, `file://`, or | ||
| // `javascript:` URLs at the host activity, a known Android-WebView | ||
| // intent-smuggling / deep-link attack surface (CWE-939). | ||
| val scheme = request.url.scheme?.lowercase() | ||
| val allowed = scheme == "https" || | ||
| scheme == "http" || | ||
|
Comment on lines
+31
to
+33
|
||
| scheme == "eid" || | ||
| scheme == "tel" || | ||
| scheme == "mailto" | ||
|
Comment on lines
+32
to
+36
|
||
| if (!allowed) { | ||
| return true | ||
| } | ||
| activity.startActivity(Intent(Intent.ACTION_VIEW, request.url)) | ||
| return true | ||
|
Comment on lines
40
to
41
|
||
| } | ||
|
|
||
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.
The foreign-origin check only compares scheme + host. This treats
https://example.com:444/...as same-origin ashttps://example.com/...(ports are ignored), which can allow loading non-wallet services on the same host inside the privileged WebView. Consider including an (effective) port comparison (or compareauthority) when deciding whether a URL is allowed to stay in-app.