Skip to content

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
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 below local, and the like;
  • <debug-overrides>, and the manifests of the debug and profile source 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.

Violatingandroid/app/src/main/AndroidManifest.xml
<application android:label="shop" android:usesCleartextTraffic="true">
Correcteduse HTTPS; for a server of development on the emulator’s computer, name it alone, in a configuration of the debug source set or of the main one
android/app/src/main/res/xml/network_security_config.xml
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain>10.0.2.2</domain>
</domain-config>
</network-security-config>
Violatingios/Runner/Info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Correctedremove the key and use HTTPS; for a host that has no TLS, an exception domain for it alone
<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.

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"]

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).

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.

All cases

Android, in the manifests a release build is made of (android/app/src/main/AndroidManifest.xml and android/app/src/release/AndroidManifest.xml):

  1. 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.
  2. 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 that allowed_hosts does 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.

iOS and macOS, in ios/Runner/Info.plist and macos/Runner/Info.plist, under NSAppTransportSecurity (App Transport Security):

  1. NSAllowsArbitraryLoads <true/>, where none of NSAllowsArbitraryLoadsForMedia, NSAllowsArbitraryLoadsInWebContent and NSAllowsLocalNetworking is written. Where one of them is, whatever its value, iOS 10 and macOS 10.12 and later ignore it and take its default NO.
  2. NSAllowsArbitraryLoadsInWebContent <true/>, which lets the app’s web views load any page over plain HTTP.
  3. An exception domain under NSExceptionDomains whose NSExceptionAllowsInsecureHTTPLoads or NSTemporaryExceptionAllowsInsecureHTTPLoads is <true/>, for a domain that is no local host and that allowed_hosts does 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.

  • A setting that is not written. An absent usesCleartextTraffic, cleartextTrafficPermitted or 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 an Info.plist says otherwise. Android and Apple have refused it by default since 2018 and 2016. Flutter’s templates write none of them.
  • Local hosts, as cleartext_request takes 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 below local, home.arpa and internal, 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/16 is local, 0.0.0.0/0 is 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, and NSAllowsLocalNetworking, which covers local hosts alone.
  • The manifests and resources of the debug and profile source sets, which a release build does not hold. Flutter’s template puts the internet permission there for the development tools.

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.

  • 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.plist keys down to its key) and by its attribute or key as written, so editing other attributes on its line hands nothing over.

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.