Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Fix: Okio CVE-2023-3635 + OkHttp Jar Update #23796

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

Mariamalmesfer
Copy link
Contributor

@Mariamalmesfer Mariamalmesfer commented Oct 9, 2024

Description

This PR fixes the Okio security vulnerability (CVE-2023-3635) by upgrading from version 1.17.2 to 3.6.0. It also includes an update to the OkHttp jar from 3.9.0 to 4.12.0

Motivation and Context

A flaw was found in Okio’s GzipSource class that doesn’t handle exceptions properly, allowing potential Denial of Service (DoS) attacks with malformed files.

CVE-2023-3635: Details

Impact

Image Scan showed the vulnerability have been removed.
correlation-report-ibm-lh-presto-okie check.csv

Test Plan

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

 == RELEASE NOTES == =
Security Changes
* Upgrade okio to 3.6.0 in response to `CVE-2023-3635 <https://github.com/advisories/GHSA-w33c-445m-f8w7>`_. :pr:`23796`
* Upgrade okhttp to 4.12.0 in response to `CVE-2023-3635 <https://github.com/advisories/GHSA-w33c-445m-f8w7>`_.  :pr:`23796`

Copy link

linux-foundation-easycla bot commented Oct 9, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Mariamalmesfer / name: Mariam AlMesfer (4bbd3de)

@Mariamalmesfer Mariamalmesfer force-pushed the okie-fix branch 2 times, most recently from 1e17bcc to 8bed2f9 Compare October 13, 2024 09:24
@Mariamalmesfer Mariamalmesfer marked this pull request as ready for review October 13, 2024 09:34
@Mariamalmesfer Mariamalmesfer requested a review from a team as a code owner October 13, 2024 09:34
@ZacBlanco ZacBlanco self-requested a review October 14, 2024 17:14
@Mariamalmesfer Mariamalmesfer force-pushed the okie-fix branch 3 times, most recently from f8715a8 to e3b47f0 Compare October 15, 2024 13:51
@Mariamalmesfer Mariamalmesfer marked this pull request as draft October 24, 2024 08:04
@Mariamalmesfer Mariamalmesfer force-pushed the okie-fix branch 5 times, most recently from e13efb9 to dab801a Compare November 4, 2024 06:46
@steveburnett
Copy link
Contributor

Thanks for the release note entry! Nit to remove # from the PR number.

 == RELEASE NOTES == =

Security Changes
* Upgrade okio to 3.6.0 :pr:`23796`
* Upgrade okhttp to 4.12.0 :pr:`23796`

@Mariamalmesfer Mariamalmesfer force-pushed the okie-fix branch 12 times, most recently from af5b4c3 to ef04384 Compare November 7, 2024 22:14
@Mariamalmesfer Mariamalmesfer force-pushed the okie-fix branch 2 times, most recently from 5de7a82 to a0525f5 Compare December 10, 2024 21:41
@Mariamalmesfer Mariamalmesfer force-pushed the okie-fix branch 2 times, most recently from 5549d70 to 472111e Compare December 25, 2024 10:32
@Mariamalmesfer Mariamalmesfer force-pushed the okie-fix branch 4 times, most recently from 9b55b09 to 83aa236 Compare January 15, 2025 18:18
@Mariamalmesfer Mariamalmesfer marked this pull request as ready for review January 15, 2025 20:22
pom.xml Show resolved Hide resolved
pom.xml Show resolved Hide resolved
@Mariamalmesfer Mariamalmesfer force-pushed the okie-fix branch 2 times, most recently from 85bca20 to f3d345d Compare January 21, 2025 09:53
aaneja
aaneja previously approved these changes Jan 22, 2025
@tdcmeehan tdcmeehan merged commit 01bdab4 into prestodb:master Jan 28, 2025
52 checks passed
@@ -2352,6 +2352,7 @@
<exclude>com.fasterxml.jackson.core:jackson-annotations</exclude>
<exclude>com.fasterxml.jackson.core:jackson-core</exclude>
<exclude>com.fasterxml.jackson.core:jackson-databind</exclude>
<exclude>org.jetbrains.kotlin:kotlin-stdlib-jdk8</exclude>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mariamalmesfer Please do not ignore depdendency conflicts. It causes problems in projects using various Presto libraries as a dependency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ignored this because OkHttp brings in two versions of this dependency. It seems to be entirely within the OkHttp libraries: #23796 (comment)

If our enforcer plugin complains about this, how would you fix it? It seems to be a problem with the upstream dependency and not something Presto should control.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a known issue upstream but they don't seem to plan on fixing it in the 4.x line. square/okhttp#8288 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the runtime you cannot have two versions of the same class. At the end of the day the VM will have to pick one, possibly in a non deterministic way. Silencing the check doesn't make the problem go away. We need to pick a single version explicitly and exclude the other one to resolve the problem.

Copy link
Member

@arhimondr arhimondr Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZacBlanco I looked at a problem a little bit more. As you mentioned it looks like okio-jvm depends on a different version of the kotlin-stdlib-jdk8 and the kotlin-stdlib-common libraries. okio-jvm depends on version 1.9.10 while the okhttp depends on 1.8.21.

Consider excluding kotlin-stdlib-jdk8, kotlin-stdlib-common from the okio-jvm in the dependency management section of the main pom:

            <dependency>
                <groupId>com.squareup.okio</groupId>
                <artifactId>okio-jvm</artifactId>
                <version>3.6.0</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.jetbrains.kotlin</groupId>
                        <artifactId>kotlin-stdlib-jdk8</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.jetbrains.kotlin</groupId>
                        <artifactId>kotlin-stdlib-common</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

And including this dependency in the presto-client/pom.xml:

        <dependency>
            <groupId>com.squareup.okio</groupId>
            <artifactId>okio-jvm</artifactId>
        </dependency>

Unfortunately once you do this the dependency checker complains that the okio-jvm is unused. However due to Kotlin quirks it has to stay in compile scope. To workaround that consider referencing a class from the okio-jvm in a Dummy class:

import okio.ByteString;

 public class Dummy
 {
    static {
        okio.ByteString byteString = new ByteString(new byte[] {});
        System.out.println(byteString);
    }
 }

This should hopefully resolve the conflict. This approach is better as it doesn't push the problem down to the presto-jdbc consumers.

Additionally you need to shade kotlin dependencies (kotlin.) as well as Jetbrains annotations (org.intellij., org.jetbrains.*) here to avoid class name conflicts in presto-jdbc.

@@ -55,6 +55,12 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<exclusions>
<exclusion>
<groupId>org.jetbrains</groupId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What issue does this dependency cause? Is this dependency needed in runtime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exclusion prevents a build failure due to scope conflicts. Without it, Maven reports scope issues that lead to build failures. This dependency isn't needed at runtime; it's only required to pass the build checks.

@prestodb-ci
Copy link

@ethanyzhang imported this issue into IBM GitHub Enterprise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from:IBM PR from IBM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants