Tighten AdvWebView WebView posture#150
Open
jim-daf wants to merge 1 commit into
Open
Conversation
AdvWebView.init() turned on three settings that loosen the WebView sandbox more than the forum-client code actually needs: - setMixedContentMode(MIXED_CONTENT_ALWAYS_ALLOW) - setAllowFileAccessFromFileURLs(true) - setAllowUniversalAccessFromFileURLs(true) The HTML rendered into AdvWebView is always built locally by HtmlBuilder / TopicBodyBuilder / QmsHtmlBuilder and either points the WebView at an https://forum-host/forum/ base URL or references bundled resources via file:///android_asset/. The android_asset scheme is permitted regardless of the file flags, so neither FromFileURLs flag is load-bearing for any of the existing call sites. Replace MIXED_CONTENT_ALWAYS_ALLOW with MIXED_CONTENT_COMPATIBILITY_MODE, which keeps passive sub-resources (images, fonts) loading on https forum pages while blocking active mixed content like remote scripts. Remove the two setAllow*FromFileURLs(true) calls. The dev comment on the first one already said 'Maybe you don't need this rule' -- confirmed, neither is needed. setAllowFileAccess(true) is left in place because removing it would require a wider audit of every fragment that constructs an AdvWebView.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #149.
AdvWebView.init()turns on three settings that loosen the WebView sandbox more than the forum-client actually needs:The HTML rendered into
AdvWebViewis always built locally byHtmlBuilder,TopicBodyBuilderorQmsHtmlBuilder. The page is either pointed at anhttps://forum-host/forum/base URL (BbCodesQuickView.loadDataWithBaseURL) or references bundled resources viafile:///android_asset/. Theandroid_assetscheme is permitted regardless of the file flags, so neitherFromFileURLsflag is load-bearing for any of the existing WebView paths. The dev comment on the first call (Maybe you don't need this rule) already flags the uncertainty.Change
setMixedContentMode(MIXED_CONTENT_ALWAYS_ALLOW)->setMixedContentMode(MIXED_CONTENT_COMPATIBILITY_MODE).COMPATIBILITY_MODEkeeps passive sub-resources (images, fonts) loading on an https forum page while blocking active mixed content like remote scripts. This is the right default for user-generated forum content.Drop
setAllowFileAccessFromFileURLs(true)andsetAllowUniversalAccessFromFileURLs(true). Neither one takes effect when the main frame is an https URL, and they are CWE-200 sandbox-escape vectors when left on.Out of scope
setAllowFileAccess(true)is left in place. Removing it would need a wider audit of every fragment that builds its ownAdvWebView(ForumRulesFragment,SpecialView,ProfileEditFragment,QmsChatFragment,SearchPostFragment,PostPreviewFragment,ThemeFragment,MentionsListFragment), so I have kept this PR to the centralAdvWebViewonly.