medium · M4 · MASVS-PLATFORM-2 · PTKD-WEBVIEW-FILEACCESS

    WebView allows file access from web content

    setAllowUniversalAccessFromFileURLs / setAllowFileAccessFromFileURLs (Android) or the allowFileAccessFromFileURLs / allowUniversalAccessFromFileURLs preference keys (WKWebView) let a page loaded from a file:// URL read other local files and, with universal access, send them anywhere.

    How it is exploited

    setAllowFileAccessFromFileURLs lets a file:// page read other local files via XHR. One injected HTML file (downloads, cache) can exfiltrate cookies databases and private files through the WebView.

    Why it matters

    Local-file boundary inside the app breaks; web content reads app-private storage.

    How to fix it

    1. Set setAllowFileAccessFromFileURLs(false) and setAllowUniversalAccessFromFileURLs(false) (default on modern APIs; check legacy code).
    2. Serve packaged content via WebViewAssetLoader over https:// app assets instead of file:// URLs.

    Does your app have this?

    PTKD checks your build or your source project for PTKD-WEBVIEW-FILEACCESS and every other check in this knowledge base.

    Scan your app

    References

    Related checks (M4)