A serious security vulnerability has been discovered in the Apache DolphinScheduler, an open-source distributed big data visual workflow scheduler system, specifically in the HttpUtils class that deals with outgoing HTTPS connections. This vulnerability (CVE-2023-49250) could allow an attacker to perform a Man-in-the-Middle (MITM) attack on outgoing HTTPS connections by impersonating the server. The vulnerability affects Apache DolphinScheduler versions before 3.2..

In this post, we will explore the details of this vulnerability and provide code snippets and recommendations to help you understand and mitigate this issue.

Vulnerability Details

The issue lies in the HttpUtils class, which does not verify certificates for outgoing HTTPS connections. In this case, an attacker could exploit this vulnerability by performing a Man-in-the-Middle (MITM) attack, intercepting outgoing HTTPS connections, and impersonating the server that the connection is attempting to reach.

Here is a simple code snippet that demonstrates the lack of certificate verification in the affected HttpUtils class:

public static String httpsGet(String url) throws Exception {
    HttpsURLConnection conn = null;
    try {
        // Create a URL object for the requested URL
        URL httpsUrl = new URL(url);
        // Open a connection to the URL
        conn = (HttpsURLConnection) httpsUrl.openConnection();
        // Set up the connection options
        conn.setDoOutput(false);
        conn.setDoInput(true);
        conn.setUseCaches(false);
        conn.setInstanceFollowRedirects(true);
        // !!! Missing Certificate Verification !!!
        // The HttpUtils code should include certificate verification here
        // Read the response from the server
        InputStream inputStream = conn.getInputStream();
        String result = readFromInputStream(inputStream);
        return result;
    } finally {
        if (conn != null) {
            conn.disconnect();
        }
    }
}

As you can see, the HttpUtils code above is missing the necessary certificate verification needed to prevent this MITM attack.

Original References and Exploit Details

More information about the vulnerability, along with additional technical details, can be found in the following references:
1. Apache DolphinScheduler Official GitHub Repository
2. CVE Details - CVE-2023-49250
3. National Vulnerability Database NVD - CVE-2023-49250

Mitigation and Recommendations

To secure your Apache DolphinScheduler instance and prevent possible attacks exploiting this vulnerability, it is strongly recommended that you upgrade to version 3.2.1, which includes a fix for the issue.

Here is a code snippet from the updated HttpUtils class, where certificate verification has been added to secure outgoing HTTPS connections:

public static String httpsGet(String url) throws Exception {
    HttpsURLConnection conn = null;
    try {
        // Create a URL object for the requested URL
        URL httpsUrl = new URL(url);
        // Open a connection to the URL
        conn = (HttpsURLConnection) httpsUrl.openConnection();
        // Set up the connection options
        conn.setDoOutput(false);
        conn.setDoInput(true);
        conn.setUseCaches(false);
        conn.setInstanceFollowRedirects(true);

        // Certificate Verification
        // The HttpUtils code in version 3.2.1 now includes certificate verification
        SSLContext sslContext = SSLContext.getInstance("TLS");
        sslContext.init(null, new TrustManager[] { new DefaultTrustManager() }, null);
        conn.setSSLSocketFactory(sslContext.getSocketFactory());
        // Read the response from the server
        InputStream inputStream = conn.getInputStream();
        String result = readFromInputStream(inputStream);
        return result;
    } finally {
        if (conn != null) {
            conn.disconnect();
        }
    }
}

After upgrading to Apache DolphinScheduler version 3.2.1, you can confirm the security of your instance by reviewing the updated HttpUtils class in the source code.

Conclusion

This blog post explained the CVE-2023-49250 vulnerability found in the Apache DolphinScheduler affecting versions before 3.2., provided code snippets to demonstrate the issue, and recommended upgrading to version 3.2.1 to mitigate the vulnerability. By taking these steps, you can ensure the security of your Apache DolphinScheduler and help protect your system against potential Man-in-the-Middle attacks.

Timeline

Published on: 02/20/2024 10:15:08 UTC
Last modified on: 02/20/2024 19:50:53 UTC