rules:
- id: bypass-tls-verification
  message: >-
    Checks for redefinitions of functions that check TLS/SSL certificate verification. This can lead to
    vulnerabilities,
    as simple errors in the code can result in lack of proper certificate validation.
    This should only be used for debugging purposes because it leads to vulnerability to MTM attacks.
  severity: WARNING
  metadata:
    likelihood: HIGH
    impact: MEDIUM
    confidence: MEDIUM
    category: security
    cwe: 'CWE-319: Cleartext Transmission of Sensitive Information'
    owasp: 'A03:2017 - Sensitive Data Exposure'
    references:
    - https://stackoverflow.com/questions/4072585/disabling-ssl-certificate-validation-in-spring-resttemplate
    - https://stackoverflow.com/questions/35530558/how-to-fix-unsafe-implementation-of-x509trustmanager-in-android-app?rq=1
    subcategory:
    - vuln
    technology:
    - spring
    vulnerability: Insecure Transport
  languages: [java]
  pattern-either:
  - pattern: |
      new HostnameVerifier() {
        ...
        public boolean verify(String hostname, SSLSession session) {
          ...
        }
        ...
      };
  - pattern: |
      public RestTemplate restTemplate() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
        ...
        TrustStrategy $FUNCNAME = (X509Certificate[] chain, String authType) -> ...;
        ...
      }
  - pattern: |
      TrustStrategy $FUNCNAME= new TrustStrategy() {
        ...
        public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
          ...
        }
        ...
      };
