Skip to main content

Insecure digital certificates - Chain of trust

Description

Due to improper implementation of the TrustManager checkServerTrusted method, methods are created that do not throw a certificate exception when invalid certificates are detected. Thanks to this it is possible to accept any incoming certificate and materialize Man in The Middle attacks.

Impact

Execute Man-in-the-middle attacks.

Recommendation

Define a processing logic for invalid certificates that includes rejecting the connection to such certificates and storing the technical details of the event in logs.

Threat

Unauthorized attacker from intranet

Expected Remediation Time

⌚ 45 minutes.

Score

Default score using CVSS 3.1. It may change depending on the context of the vulnerability.

Base

  • Attack vector: A
  • Attack complexity: H
  • Privileges required: N
  • User interaction: R
  • Scope: U
  • Confidentiality: N
  • Integrity: L
  • Availability: N

Temporal

  • Exploit code madurity: P
  • Remediation level: O
  • Report confidence: X

Result

  • Vector string: CVSS:3.1/AV:A/AC:H/PR:N/UI:R/S:U/C:N/I:L/A:N/E:P/RL:O/RC:X
  • Score:
    • Base: 2.6
    • Temporal: 2.4
  • Severity:
    • Base: Low
    • Temporal: Low

Code Examples

Compliant code

The application prevents invalid certificates to establish connections

public void checkServerTrusted(X509Certificate[] certificates, String authType)
throws CertificateException {
if ((certificates != null) && (certificates.length == 1)) {
certificates[0].checkValidity();
certificates[0].checkExpiration();
//Code to establish connection if certificate is valid
} else {
//Code to throw error and log technical details of the event
throw new Exception()
}
}

Non compliant code

Application does not correctly check if certificate is invalid or has expired and allows insecure connections

public void checkServerTrusted(X509Certificate[] certificates, String authType)
throws CertificateException {
if ((certificates != null) && (certificates.length == 1)) {
certificates[0].checkValidity();
} else {
standardTrustManager.checkServerTrusted(certificates, authType);
}
}

Requirements