cleartext_traffic_allowed
Reports a platform setting that lets the app send clear text, plain HTTP, over the network. Use HTTPS, or allow clear text for one host only.
- Kind
- project-file check
- Tier
- advisory
- Host
- command-line program only (
assay project-files) - Lowest preset
- every preset (on unless switched off)
- Fix
- none
- Security class
- CWE-319 · mobile risk M5 (insecure communication) · severity 5.9
What it reports
Section titled “What it reports”| Where | Setting |
|---|---|
Android release manifests (android/app/src/main/ and src/release/) |
android:usesCleartextTraffic="true" on <application>, where no network security configuration is named |
The network security configuration the manifest names (res/xml/<name>.xml) |
<base-config cleartextTrafficPermitted="true">, or a <domain-config cleartextTrafficPermitted="true"> for a host that is not local |
ios/Runner/Info.plist, macos/Runner/Info.plist |
NSAllowsArbitraryLoads <true/>, NSAllowsArbitraryLoadsInWebContent <true/>, or an exception domain that allows insecure HTTP loads for a host that is not local |
A host you name in allowed_hosts counts as local. The result stands at the attribute or at the <key>, and its message names the host where the setting names one.
It does not report:
- a setting that is not written: both platforms refuse clear text by default, and Flutter’s templates write none of these settings;
- local hosts:
localhost, the loopback and private networks, the emulator’s address for its computer (10.0.2.2), names belowlocal, and the like; <debug-overrides>, and the manifests of thedebugandprofilesource sets, which a release build does not hold.
Whoever is on the network, such as an open Wi-Fi, a router or a proxy, can read and change clear text. A setting that lets it back in is usually written once for an emulator or a test server, and stays in the release build. A setting for one host keeps the others safe; a setting for every host does not.
Example
Section titled “Example”android/app/src/main/AndroidManifest.xml<application android:label="shop" android:usesCleartextTraffic="true"><network-security-config> <domain-config cleartextTrafficPermitted="true"> <domain>10.0.2.2</domain> </domain-config></network-security-config>ios/Runner/Info.plist<key>NSAppTransportSecurity</key><dict> <key>NSAllowsArbitraryLoads</key> <true/></dict><key>NSAppTransportSecurity</key><dict> <key>NSExceptionDomains</key> <dict> <key>printer.lan</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict></dict>with printer.lan in allowed_hosts.
Configuration
Section titled “Configuration”Under assay.project_files of the project’s root analysis_options.yaml:
| Key | Default | Effect |
|---|---|---|
allowed_hosts |
[] |
Further hosts the app may reach over plain HTTP, beside the local hosts, such as a device on your local network. *.lan names every host below lan. |
enabled |
true |
false (or the short form cleartext_traffic_allowed: false) switches the check off. |
exclude |
[] |
Path globs, from the project root, where the check places no result. |
assay: project_files: cleartext_traffic_allowed: allowed_hosts: [printer.lan, "*.corp"]How to run it
Section titled “How to run it”assay project-files runs it with the other project-file checks, and assay project-files cleartext_traffic_allowed runs it alone. The gate and the baseline commands run it in every judgement (see In the gate).
Keeping a result
Section titled “Keeping a result”No suppression comment applies. Keep a setting that is right for your app, such as an example app that loads pages over plain HTTP on purpose, in the baseline. Put a host of your local network in allowed_hosts.
Details
Section titled “Details”All cases
What it reports in full
Section titled “What it reports in full”Android, in the manifests a release build is made of (android/app/src/main/AndroidManifest.xml and android/app/src/release/AndroidManifest.xml):
android:usesCleartextTraffic="true"on<application>, where the manifests name no network security configuration. Where one is named, Android 7 (API level 24) and later ignore the attribute and take the configuration instead: the attribute is then no result, and the configuration is judged.- In the network security configuration that
android:networkSecurityConfig="@xml/<name>"names,res/xml/<name>.xml:- a
<base-config cleartextTrafficPermitted="true">, which allows clear text to every host that no<domain-config>covers: “This network security configuration lets the app send clear text to any host, which whoever is on the network can read and change.”; - a
<domain-config cleartextTrafficPermitted="true">with a domain that is no local host and thatallowed_hostsdoes not name: ”… lets the app send clear text to media.shop.dev and 1 other host, …”. It counts the domains of the<domain-config>elements inside it that do not write the attribute themselves, as they take its value. A nested<domain-config>that writes the attribute is judged on its own.
- a
iOS and macOS, in ios/Runner/Info.plist and macos/Runner/Info.plist, under NSAppTransportSecurity (App Transport Security):
NSAllowsArbitraryLoads<true/>, where none ofNSAllowsArbitraryLoadsForMedia,NSAllowsArbitraryLoadsInWebContentandNSAllowsLocalNetworkingis written. Where one of them is, whatever its value, iOS 10 and macOS 10.12 and later ignore it and take its defaultNO.NSAllowsArbitraryLoadsInWebContent<true/>, which lets the app’s web views load any page over plain HTTP.- An exception domain under
NSExceptionDomainswhoseNSExceptionAllowsInsecureHTTPLoadsorNSTemporaryExceptionAllowsInsecureHTTPLoadsis<true/>, for a domain that is no local host and thatallowed_hostsdoes not name.
A result stands at the attribute (android:usesCleartextTraffic="true", cleartextTrafficPermitted="true") or at the <key> of the property list (<key>NSAllowsArbitraryLoads</key>). Its message names the host where a setting names one.
What it does not report
Section titled “What it does not report”- A setting that is not written. An absent
usesCleartextTraffic,cleartextTrafficPermittedor App Transport Security key is the platform’s default. Apps that target Android 9 (API level 28) or later, as every current Flutter app does, have clear text refused by default, and App Transport Security refuses it on iOS and macOS unless anInfo.plistsays otherwise. Android and Apple have refused it by default since 2018 and 2016. Flutter’s templates write none of them. - Local hosts, as
cleartext_requesttakes them:localhost, the loopback and private networks, the emulator’s address for its computer (10.0.2.2), link-local addresses, names of one label, names belowlocal,home.arpaandinternal, and the names reserved for examples and tests. A range of addresses in an exception domain (iOS 17 and later take them) is local where its address is and it is no wider than a local network:192.168.0.0/16is local,0.0.0.0/0is not. <debug-overrides>, which a build that is not debuggable ignores, and which holds trust anchors only.NSAllowsArbitraryLoadsForMedia, which Apple keeps for media that is encrypted itself, andNSAllowsLocalNetworking, which covers local hosts alone.- The manifests and resources of the
debugandprofilesource sets, which a release build does not hold. Flutter’s template puts the internet permission there for the development tools.
How allowed_hosts is compared
Section titled “How allowed_hosts is compared”A host of allowed_hosts is compared as cleartext_request compares a local host: without regard to case, with or without a final dot, and an IPv6 address with or without its brackets. The rule cleartext_request has a parameter of the same name, set apart.
In the gate
Section titled “In the gate”- A change that touches the main or the release manifest is handed the results of the network security configuration the manifest names, those the session’s mark does not hold, even though the configuration itself was not touched.
- A result is known by its place (its element’s path, or the
Info.plistkeys down to its key) and by its attribute or key as written, so editing other attributes on its line hands nothing over.
Security class
Section titled “Security class”In SARIF, the check’s descriptor carries the tags security, external/cwe/cwe-319 and external/owasp-mobile-2024/m5, and the security-severity 5.9. No other report changes.