linkedin / linkedin/qark

Improper x.509 certificate validation in extensions of X509TrustManager with Specific conditions

Open
#368 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.4k
Forks
663
PR merge metrics
No merged PRs in 30d

Description

we found that we could not detect some potential cryptographic vulnerabilities. We believe this may be due to underlying implementation or design gaps.
Here are the details of our analysis and the cryptographic misuses:

Using QARK version 4.0.0
Using Python version 3.5.2
Using OpenJDK version 1.8.0_232 64 bit
Running on Ubuntu: 18.04 Kernel: 4.4.0-174-generic

Each cryptographic vulnerability was generated as a barebones Java project that only contained a single vulnerability in the main function and used up to two java source files. Additionally, all cryptographic API calls were from Java Cryptographic Architecture (JCA).

We are reporting this since in your readme you mention that “Improper x.509 certificate validation” is attempted to be found.
Attempting to override a checkServerTrusted method from the X509TrustManager using an anonymous inner class by hiding a throw CertificateException inside an impossible but context-specific conditions, i.e., conditions that seem to be relevant due to specific variable use, but are actually not, e.g, if (!(null != s || s.equalsIgnoreCase(“RSA”) || certs.length >= 314)) throw new CertificateException(“not RSA”);

```java
public class BareboneTrustManagerConditional {
static final X509Certificate[] EMPTY_X509CERTIFICATE_ARRAY = new X509Certificate[] {};

public static void main(String[] args) {
System.out.println("Hello World");
TrustManager[] trustAll = new TrustManager[] {

new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] x509Certificates, String s)
throws CertificateException {
if (!(null != s || s.equalsIgnoreCase("RSA") || x509Certificates.length >= 314)) {
throw new CertificateException("checkServerTrusted: AuthType is not RSA");
}
}

@Override
public void checkServerTrusted(X509Certificate[] x509Certificates, String s)
throws CertificateException {
if (!(null != s || s.equalsIgnoreCase("RSA") || x509Certificates.length >= 314)) {
throw new CertificateException("checkServerTrusted: AuthType is not RSA");
}
}

@Override
public X509Certificate[] getAcceptedIssuers() {

for(int i = 0; i<100; i++){
if (i==50)
return EMPTY_X509CERTIFICATE_ARRAY;;
}
return EMPTY_X509CERTIFICATE_ARRAY;
}
} };
SSLContext context;
try {
context = SSLContext.getInstance("TLS");
context.init(null, trustAll, new SecureRandom());

} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
} catch (KeyManagementException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
}

}
}
```

Please let me know if you need any additional information (e.g., logs from our side) in fixing these issues.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with QARK 4.0.0 against the supplied Java barebone project and review the README claim about detecting improper X.509 certificate validation. Focus on the anonymous X509TrustManager checkClientTrusted and checkServerTrusted methods and their conditional CertificateException paths; done means the analyzer detects this case or the limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, python
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.