MASTG-DEMO-0083: Insecure ATS Configuration Allowing Cleartext Traffic
Download MASTG-DEMO-0083 IPA Open MASTG-DEMO-0083 Folder Build MASTG-DEMO-0083 IPA
Sample¶
The code below shows an insecure ATS configuration in an Info.plist file that disables App Transport Security in many ways:
- Globally via
NSAllowsArbitraryLoads - For web content via
NSAllowsArbitraryLoadsInWebContent - For media via
NSAllowsArbitraryLoadsForMedia - For local networking via
NSAllowsArbitraryLoadsForLocalNetworking - For specific domains (api.example.com and httpbin.org) via
NSExceptionDomains
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
Steps¶
- Extract the app ( Exploring the App Package) and locate the
Info.plistfile inside the app bundle (which we'll nameInfo_reversed.plist). - Convert the Info.plist to pretty printed JSON ( Convert Plist Files to JSON)
- Extract the relevant keys and values from the
NSAppTransportSecurityconfiguration. In this case we usegronto transform the JSON into a greppable format andegrepto search for specific regex patterns.
| run.sh | |
|---|---|
1 2 3 4 5 6 7 8 9 10 | |
Observation¶
The output shows the relevant ATS configuration keys and values found in the Info_reversed.plist file:
1 2 3 4 5 6 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
Evaluation¶
The test fails because several ATS settings are set to true, which disables ATS globally and allows cleartext HTTP traffic to any domain. Specifically, the following settings are misconfigured:
NSAllowsArbitraryLoadsForLocalNetworking = trueallows cleartext traffic on local networks.NSAllowsArbitraryLoadsForMedia = trueallows cleartext traffic for media resources.NSAllowsArbitraryLoadsInWebContent = trueallows cleartext traffic in WebViews.- Domain-specific exceptions for
api.example.comandhttpbin.orgalso allow insecure HTTP loads.
Note that even though NSAllowsArbitraryLoads = true is present, it is ignored because NSAllowsArbitraryLoadsForLocalNetworking, NSAllowsArbitraryLoadsForMedia, and NSAllowsArbitraryLoadsInWebContent are also present (regardless of their values), which take precedence.
Context Considerations:
If you reverse the app binary, you will find that its code make a HTTP request to http://httpbin.org/get using URLSession, which is affected by the ATS exceptions.
- The connection to
httpbin.orgis only allowed due to the domain-specific exception and not because of the globalNSAllowsArbitraryLoadssetting. - There are no connections to
api.example.com, so the domain-specific exceptions for it does not have an effect in this case. Regardless, having such exceptions is still a misconfiguration and should be avoided. - The app does not use WebViews or media resources, so the corresponding ATS exceptions (
NSAllowsArbitraryLoadsInWebContentandNSAllowsArbitraryLoadsForMedia) do not have an effect in this case. Regardless, having such exceptions is still a misconfiguration and should be avoided. - The app does not connect to local network resources, so the corresponding ATS exception (
NSAllowsArbitraryLoadsForLocalNetworking) does not have an effect in this case. Regardless, having such an exception is still a misconfiguration and should be avoided.