Android WebView debugging enabled

Android WebView debugging enabled

Description

WebView.setWebContentsDebuggingEnabled(true) enables debugging for every WebView in the app. In a production build, someone with a debug connection to the device can inspect page contents, storage and network requests.

Potential impact

  • Disclosure of WebView storage and session information.
  • Page manipulation or script execution.
  • Inspection of the production app's internal behavior.

Remediation

  • Guard the enabling call with BuildConfig.DEBUG. In a release build, omit the call or explicitly set it to false.
  • Check that the release manifest sets debuggable=false. WebView 113.0.5656.0 and later automatically enable debugging for apps marked debuggable.

Examples

Before

java
WebView.setWebContentsDebuggingEnabled(true);

After

java
if (BuildConfig.DEBUG) {
    WebView.setWebContentsDebuggingEnabled(true);
}

References