JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
Java


JAVA.INSEC.CVO : Insecure verify Override for Certificate (Java)

Summary

A method that never throws a CertificateException is used to perform certificate validation.

A method is considered to perform certificate validation if it's annotated with @com.juliasoft.julia.checkers.unsafeConnection.ChecksPrincipalTrust.

Properties

Class Name Insecure verify Override for Certificate (Java)
Significance security
Mnemonic JAVA.INSEC.CVO
Categories
CWE CWE:295 Improper Certificate Validation
OWASP-2017 OWASP-2017:A2 Broken authentication
OWASP-2021 OWASP-2021:A7 Identification and authorization failures
OWASP-2025 OWASP-2025:A07 Authentication Failures
Availability Available for Java and Kotlin.

Android Only. Warnings of this class will only be reported in Android code: that is, code that uses the Android API.

Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Insecure verify Override for Certificate (Java)"

Example

// AuthenticationVerification.java
package com.juliasoft.julia.tests.checks.unsafeConnection;

import java.io.IOException;
import java.net.InetAddress;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.SocketFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import javax.net.ssl.X509TrustManager;

import android.net.SSLCertificateSocketFactory;
import android.net.SSLSessionCache;

public class AuthenticationVerification {
  public static void verifier(String hostname, SSLSession session) {
      new HostnameVerifier() {
          @Override
          public boolean verify(String hostname, SSLSession session) {
              return true;                            /* Use of Insecure verify for Hostname (Java) warning issued here 
                                                       * - CodeSonar treats HostnameVerifier.verify() method
                                                       *   as annotated with @VerifiesHostname, but here it always returns true
                                                       */
          }
      }.verify(hostname, session);                    /* Insecure verifier Override for Hostname (Java) warning issued here 
                                                       * - invocation of verify() method that always returns true
                                                       */
  }

  public static void manager(X509Certificate[] serverChain, X509Certificate[] clientChain, String authType) throws CertificateException {
      new X509TrustManager() {
          @Override
          public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                                                      /* Use of Insecure verify for Certificate (Java) warning issued here 
                                                       * - CodeSonar treats X509TrustManager.checkClientTrusted())
                                                       *    as annotated with @ChecksPrincipalTrust, but here it never throws CertificateException
                                                       */
          }

          @Override
          public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                                                      /* Use of Insecure verify for Certificate (Java) warning issued here 
                                                      * - CodeSonar treats X509TrustManager.checkServerTrusted()
                                                      *   as annotated with @ChecksPrincipalTrust, but here it never throws CertificateException
                                                       */
          }

          @Override
          public X509Certificate[] getAcceptedIssuers() {
              return new X509Certificate[0];
          }
      }.checkServerTrusted(serverChain, authType);    /* Insecure verifier Override for Certificate (Java) warning issued here 
                                                       * - invocation of checkServerTrusted() method that never throws CertificateException
                                                       */
  }

  public static void sockets(SSLSessionCache cache) throws IOException {
      SocketFactory factory = SSLCertificateSocketFactory.getInsecure(100, cache); /* Insecure Socket Factory (Java) warning issued here 
                                                       * - CodeSonar treats SSLCertificateSocketFactory.getInsecure()
                                                       *   as annotated with @YieldsInsecureSSLSocketFactory
                                                       */
      InetAddress addr = InetAddress.getByName("www.juliasoft.com");
      factory.createSocket(addr, 100);                /* Untrusted Network Host (Java) warning issued here 
                                                       * - CodeSonar treats the first parameter to SocketFactory.createSocket()
                                                       *   as annotated with @HostnameToBeVerified, but verification is not performed on addr here 
                                                       */
  }
}

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.

 

To report problems with this documentation, please visit https://support.codesecure.com/.