+MASTG-BEST-0011 Securely Load File Content in a WebView (Android)

MASTG-BEST-0011 Securely Load File Content in a WebView (Android)

The recommended approach to load file content to a WebView securely is to use WebViewClient with WebViewAssetLoader to load assets from the app's assets or resources directory using https:// URLs instead of insecure file:// URLs. This ensures the content is loaded in a secure, same-origin environment and avoids exposing local files to potential cross-origin attacks.

If you must allow the WebView to load local files using the file:// scheme, consider the following:

  • For apps with a minSdkVersion that has secure defaults for WebView file access methods, ensure that these methods are not used and the default values are preserved. Alternatively, explicitly set them to false to guarantee the WebView does not allow local file access:
  • setAllowFileAccess(false)
  • setAllowFileAccessFromFileURLs(false)
  • setAllowUniversalAccessFromFileURLs(false)
  • For apps with a minSdkVersion that does not have secure defaults for these methods (e.g., older API levels), ensure that the above methods are explicitly set to false in your WebView configuration.

For more details, refer to the official Android documentation on loading local content securely, especially the section on "Things to avoid".

1. Yleiskatsaus

Otsikko Standardi

1.1 Viittaukset

1.2 Tunnistetut vaatimukset

1.3 Liittyvät säädökset

2. Tunnistetut vaatimukset

Vaatimukset
Lähde Vaatimus

3. Liittyvät säädökset

Säädökset
Lähde Sääntely

Linkitetyt tehtävät

  • OWASP -

    EN: Publications of the OWASP Foundation, https://owasp.org/. OWASP® is a registered trademark of the OWASP Foundation, Inc.; GRCA is not affiliated with, nor endorsed by, the OWASP Foundation. Only the versions published by OWASP are authoritative.

    DE: Veröffentlichungen der OWASP Foundation, https://owasp.org/. OWASP® ist eine eingetragene Marke der OWASP Foundation, Inc.; GRCA steht in keiner Verbindung zur OWASP Foundation und wird von ihr nicht unterstützt. Maßgeblich sind allein die von OWASP veröffentlichten Fassungen.