Rule Definition
Ensure the developer will work with a list of trusted source. Thanks to Strict-Transport-Security header you will enforces secure (HTTP over SSL/TLS) connections to the server.
Remediation
Ensure you use HTTPS protocol for traffic to particular domains with Android 8.1 and older
Violation Code Sample
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="True">
<domain includeSubdomains="true">secure.example.com</domain>
</domain-config>
</network-security-config>
or
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config>
<domain includeSubdomains="true">secure.example.com</domain>
</domain-config>
</network-security-config>
Fixed Code Sample
For example, an app may want to ensure that all connections to secure.example.com are always done over HTTPS to protect sensitive traffic from hostile networks.
so you need to proceed as follow :
1- Declare the configuration in your app's manifest:
<manifest ... >
<application
android:networkSecurityConfig="@res/xml/network_security_config.xml:"
... >
<!-- Place child elements of <application> element here. -->
</application>
</manifest>
2- In the res/xml/network_security_config.xml, set cleartextTrafficPermitted option to false:
res/xml/network_security_config.xml:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="false">
<domain includeSubdomains="true">secure.example.com</domain>
</domain-config>
</network-security-config>
Reference
https://cwe.mitre.org/data/definitions/404.html
https://developer.android.com/training/articles/security-config
Related Technologies
Technical Criterion
Secure Coding - Weak Security Features
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.