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
- Delete server.cleartext and android.allowMixedContent from capacitor.config.
- Keep live-reload settings in a dev-only config (CAPACITOR_CONFIG env, or `cap run --live-reload`, which sets them for that run only).
- 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 appReferences
Related checks (M5)
- First-party HTTPS API without HSTS
- Cleartext HTTP traffic at runtime
- Session cookie without Secure/HttpOnly
- TLS interception succeeded (no certificate pinning)
- Weak TLS version negotiated at runtime
- App Transport Security disabled (NSAllowsArbitraryLoads)
- App Transport Security insecure exception domains
- App Transport Security disabled for media