medium · M5 · MASVS-NETWORK-1 · PTKD-HYBRID-CLEARTEXT

    Capacitor WebView allows cleartext or mixed content

    The Capacitor config turns on server.cleartext (the WebView may load http:// pages and APIs) or android.allowMixedContent (an https:// page may pull in http:// scripts and images). Anyone on the same network can read and change that traffic, and an injected script runs with access to every Capacitor plugin.

    How it is exploited

    A developer left server.cleartext: true from live-reload work. On café Wi-Fi an attacker answers the app's http:// API call with a script, which runs inside the WebView and calls the Capacitor Filesystem and Preferences plugins.

    Why it matters

    Traffic read and changed in transit; injected script gets the same native access as the app's own code.

    How to fix it

    1. Delete server.cleartext and android.allowMixedContent from capacitor.config.
    2. Keep live-reload settings in a dev-only config (CAPACITOR_CONFIG env, or `cap run --live-reload`, which sets them for that run only).
    3. Make every API base URL https://.

    Does your app have this?

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

    Scan your app

    References

    Related checks (M5)