Insecure service configuration - Host verification
Description
The system does not properly restrict incoming conections from unknown external hosts.
Impact
Establish conections with untrusted machines.
Recommendation
Validate that incoming conections come from trusted hosts already defined in the known_hosts file.
Threat
Authenticated attacker from the Internet.
Expected Remediation Time
⌚ 15 minutes.
Score
Default score using CVSS 3.1. It may change depending on the context of the vulnerability.
Base
- Attack vector: N
- Attack complexity: L
- Privileges required: L
- User interaction: N
- Scope: U
- Confidentiality: L
- Integrity: L
- Availability: N
Temporal
- Exploit code madurity: P
- Remediation level: O
- Report confidence: C
Result
- Vector string: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N/E:P/RL:O/RC:C
- Score:
- Base: 5.4
- Temporal: 4.9
- Severity:
- Base: Medium
- Temporal: Medium
Code Examples
Compliant code
Only if the application must allow connections to insecure hosts for legacy reasons, these should be specified in the subdomains
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">insecure.example.com</domain>
<domain includeSubdomains="true">insecure.cdn.example.com</domain>
</domain-config>
</network-security-config>
Adittionally, the app should perform host validation using methods like getDefaultHostnameVerifier() or similar
SSLSocketFactory ssf = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) ssf.createSocket("my.host.name", 443);
socket.startHandshake();
SSLSession session = socket.getSession();
StrictHostnameVerifier verifier = new StrictHostnameVerifier();
if (!verifier.verify(session.getPeerHost(), session)) {
// Throw some exception
}
Non compliant code
The application allows connections to arbitrary insecure hosts
<network-security-config>
<domain-config cleartextTrafficPermitted="false">
<domain includeSubdomains="true">example.com</domain>
<domain includeSubdomains="true">cdn.example2.com</domain>
</domain-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
Requirements
Search for vulnerabilities in your apps for free with our automated security testing! Start your 21-day free trial and discover the benefits of our Continuous Hacking Machine Plan. If you prefer a full service that includes the expertise of our ethical hackers, don't hesitate to contact us for our Continuous Hacking Squad Plan.