Skip to content

Lesson 7 of 13 · 10m

TLS Is Not a Given

Cleartext permission is a per-app, per-SDK policy decision set in networkSecurityConfig and the ATS dict — one staging exemption or NSAllowsArbitraryLoads silently undoes it.

https:// in the URL is not the guarantee

On Android, whether cleartext HTTP is even allowed depends on usesCleartextTraffic and the app's targetSdkVersion, not on your URL strings. Apps targeting API 27 or lower permit cleartext by default; API 28+ (Pie, 2018) flipped the default to blocked. A target-33 app that silently falls back to http:// for an endpoint fails the connection — unless somebody set usesCleartextTraffic="true" or a networkSecurityConfig <domain-config cleartextTrafficPermitted="true"> entry to make a staging build work, and shipped it.

The manifest-level config is res/xml/network_security_config.xml, pointed to by android:networkSecurityConfig. Its vocabulary matters: <base-config> applies to everything, <domain-config> overrides per host, <trust-anchors> picks between system and user CA stores, <debug-overrides> exists precisely so test builds can trust a proxy CA without touching release config, and <pin-set> does pinning — covered next lesson. The audit question is never "do we use HTTPS"; it's "what does our config permit where we didn't look" — and WebView inherits the same policy, so a cleartext exception is also WebView's exception.

iOS answers the same problem with App Transport Security: since iOS 9 (announced WWDC 2015), NSURLSession, WKWebView, and URLSession connections must be TLS 1.2+ with forward secrecy and 2048-bit RSA minimums. NSAllowsArbitraryLoads — the flag every StackOverflow answer reaches for — disables the whole thing globally; NSAllowsArbitraryLoadsInWebContent (iOS 10+) scopes the kill to web content, and NSExceptionDomains in the NSAppTransportSecurity dict scopes it to named hosts with per-domain minimums like NSExceptionMinimumTLSVersion. App Review asks you to justify arbitrary loads; grep the Info.plist for NSAllows before you grep URLs for http.

Where it actually breaks

Third-party SDKs ship their own HTTP stacks. An analytics or ad SDK running plain HTTP to its ingest endpoint doesn't care what your networkSecurityConfig intends — MobSF and a proxy will show the traffic your manifest forgot about. Cleartext also arrives through the seams: WebView.loadUrl("http://..."), image loaders fetching http URLs from API responses, a deeplink handler that passes a url extra straight into a WebView — each bypasses the "we only do HTTPS" story even though the framework policy may still block or permit per config. The other direction breaks too: permissive cleartextTrafficPermitted entries survive refactors, and nobody audits them at release.

Redirects deserve their own sentence: a 302 from https to http inside a WebView under arbitrary loads is a downgrade the URL bar never shows.

Certificate Transparency is the quieter companion control: since 2018 Chrome and (on iOS) ATS-adjacent policy require publicly trusted certs to appear in CT logs — which means an attacker can't mint a cert for your domain without it landing in a public, auditable log (crt.sh queries them). CT catches rogue issuance; it does nothing about a rogue-but-installed trust anchor, which is the gap pinning exists to close.

The same config files hold the trust-anchor policy: <trust-anchors> restricts who the app will believe, and since API 24 the user store isn't believed by default — your own test CA needs a <debug-overrides> entry, not a release exemption.

The wrong model

"HTTPS is a URL property." It isn't — it's a platform policy decision applied per-connection. The app, its WebViews, its image pipeline, its deeplink handler, and every bundled SDK each get a policy, and any of them can hold an exception you didn't write. The certificate trust anchors, TLS floor, and cleartext permission all live in config files a junior edits to unblock a demo and forgets.

Practice

  • rg 'cleartext|NSAllows' over the manifest and Info.plist in every release audit; the answer should be empty or a reviewed list.
  • Keep usesCleartextTraffic absent (target 28+ default) or explicitly false.
  • Never ship NSAllowsArbitraryLoads; scoped exceptions via NSExceptionDomains only, with NSIncludesSubdomains set correctly.
  • Run nscurl --ats-diagnostics https://your.api (macOS) when an iOS connection fails mysteriously — it tells you exactly which ATS rule killed it.
  • Test the real artifact through a proxy: the SDK traffic you see in Burp is the audit, not the manifest alone.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.