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

Fix PRISMA-2023-0067 upgrade jackson core to 2.15.4 #23753

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Mariamalmesfer
Copy link

@Mariamalmesfer Mariamalmesfer commented Oct 1, 2024

Description

fixes the jackson-core security vulnerability PRISMA-2023-0067 by upgrading from version 2.11.0 to 2.15.4
PRISMA-2023-0067: Details

Motivation and Context

Reasons for upgradation:
This PR upgrades jackson-core to address a Denial of Service (DoS) vulnerability caused by improper input validation during numeric type conversions. This upgrade prevents resource exhaustion by ensuring proper input validation.

Impact

Image Scan showed the vulnerability have been removed.
Image scan report :
Image-scan-report-9 Sep.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

 == RELEASE NOTES == =

Security Changes
* Upgrade Jackson-core to 2.15.4 :pr:`23753`

Copy link

linux-foundation-easycla bot commented Oct 1, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Mariamalmesfer / name: Mariam AlMesfer (de07533)

Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

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

Why not a later version like 2.17.1?

@elharo elharo changed the title Fix PRISMA-2023-0067 upgrade jackson core to 2.0.15 Fix PRISMA-2023-0067 upgrade jackson core to 2.15.0 Oct 1, 2024
@elharo
Copy link
Contributor

elharo commented Oct 1, 2024

I know @steveburnett disagrees with me about this, but I really don't think we should be including dependency upgrades in the release notes.

@elharo
Copy link
Contributor

elharo commented Oct 1, 2024

Looks like the most recent version is 2.18.0

@Mariamalmesfer
Copy link
Author

Looks like the most recent version is 2.18.0

The CVS scan suggests upgrading to version 2.15.0, as that's where the vulnerability was fixed. But if we want the latest updates, we can go with 2.18.0. Let me know your preference

elharo
elharo previously approved these changes Oct 4, 2024
Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

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

I'd prefer to go to the latest (honestly I'd prefer not to depend on jackson at all) but this is still an improvement.

@agrawalreetika
Copy link
Member

@Mariamalmesfer @elharo Maybe we can update to the one version before the very latest which is 2.17.2 what do you think?

@Mariamalmesfer
Copy link
Author

@Mariamalmesfer @elharo Maybe we can update to the one version before the very latest which is 2.17.2 what do you think?

Sounds good to me. We can go with 2.17.2 if that works for everyone.
cc: @elharo

@Mariamalmesfer Mariamalmesfer force-pushed the jackson-core-fix branch 3 times, most recently from 6531651 to 840291d Compare October 7, 2024 11:54
@elharo elharo changed the title Fix PRISMA-2023-0067 upgrade jackson core to 2.15.0 Fix PRISMA-2023-0067 upgrade jackson core to 2.17.2 Oct 7, 2024
pom.xml Outdated
@@ -76,7 +76,7 @@
<dep.ratis.version>2.2.0</dep.ratis.version>
<dep.errorprone.version>2.18.0</dep.errorprone.version>
<dep.guava.version>32.1.0-jre</dep.guava.version>
<dep.jackson.version>2.11.0</dep.jackson.version>
<dep.jackson.version>2.17.2</dep.jackson.version>
Copy link
Contributor

Choose a reason for hiding this comment

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

why not 2.18.0?

Copy link
Author

Choose a reason for hiding this comment

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

@Mariamalmesfer @elharo Maybe we can update to the one version before the very latest which is 2.17.2 what do you think?

We can proceed with either version, but since Reetika mentioned updating to 2.17.2, Let me know what you think.

Copy link
Member

Choose a reason for hiding this comment

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

@elharo Since version 2.18.0 is the very latest, I was thinking we could use the previous version instead to avoid potential issues with the latest release.

Copy link
Author

Choose a reason for hiding this comment

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

@elharo, @agrawalreetika pointed out the option to update to 2.17.2 instead of the latest 2.18.0. Please advise on the preferred version.

Comment on lines 302 to 304
<ignoredClassPatterns>
<ignoredClassPattern>module-info</ignoredClassPattern>
<ignoredClassPattern>META-INF.versions.9.module-info</ignoredClassPattern>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make <ignoredClassPatterns combine.children="append"> so we don't duplicate this in the submodules?

Copy link
Author

Choose a reason for hiding this comment

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

done

@tdcmeehan tdcmeehan self-assigned this Oct 7, 2024
@steveburnett
Copy link
Contributor

Please update the release note entry to the version being updated to. For example

 == RELEASE NOTES == =

Security Changes
* Upgrade Jackson-core to 2.17.2 :pr:`#23753`

@elharo
Copy link
Contributor

elharo commented Oct 10, 2024

I prefer 2.18.0 but I'm not sure others agree with this. Don't overthink it. Either 2.17.2 or 2.18 is better than what we have now.

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.3.0</version>
<dependencies>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this addition to the enforcer plugin?

Copy link
Author

Choose a reason for hiding this comment

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

to prevent issues with different Java versions. Java 8 was trying to load JDK 11-specific classes

Copy link
Contributor

Choose a reason for hiding this comment

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

Where were the the JDK 11 specific classes being loaded, inside the enforcer plugin? By the way, why is the version of the enforcer plugin upgraded as well?

Copy link
Author

@Mariamalmesfer Mariamalmesfer Oct 23, 2024

Choose a reason for hiding this comment

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

The JDK 11-specific classes were being loaded as part of Jackson's multi-release JAR (META-INF/versions/11/). These classes are intended to be loaded only on JDK 11 and above, but Maven was attempting to load them in my JDK 8 environment, causing compatibility issues.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please root cause why we are attempting to load JDK 11 classes and revert this change?

Copy link
Author

Choose a reason for hiding this comment

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

The root cause of the issue lies in the multi-release JAR feature in Jackson. The JDK 11-specific classes (located under META-INF/versions/11/) were being loaded even though the build was running on Java 8. This happened because Maven was attempting to load these classes during the build, which caused compatibility issues.

Upgrading the Enforcer plugin to version 3.3.0, along with the extra-enforcer-rules dependency, ensures that Java 8 doesn't attempt to load these JDK 11 classes, as it properly handles multi-release JARs by excluding versioned classes not compatible with the current JDK version.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you not override the configuration, and use plugin management to update the version?

Copy link
Author

Choose a reason for hiding this comment

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

The enforcer plugin and its version upgrade are already managed in the pluginManagement section

Copy link
Author

Choose a reason for hiding this comment

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

I have removed the section, but I suggest keeping the extra-enforcer-rules dependency. It helps resolve compatibility issues with multi-release JARs.This prevents build failures. Would it be okay to keep it for stability?

Copy link
Contributor

Choose a reason for hiding this comment

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

SG

pom.xml Outdated
@@ -2357,6 +2408,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>com.google.api.grpc:proto-google-common-protos</exclude>
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this related to the Jackson upgrade?

Copy link
Author

Choose a reason for hiding this comment

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

to prevent conflicts between multiple versions. Different versions were causing a RequireUpperBoundDeps error in the build, and excluding it ensures the correct version is used.

Copy link
Contributor

Choose a reason for hiding this comment

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

Where was the conflict originating from? I don't understand how a Jackson upgrade causes a Google proto conflict.

Copy link
Author

Choose a reason for hiding this comment

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

The conflict originates from transitive dependencies in Google Cloud libraries, specifically google-cloud-bigquery and related modules like google-cloud-core and gax-grpc, which bring in different versions of proto-google-common-protos. When upgrading Jackson, the build system caught these conflicts due to the RequireUpperBoundDeps rule, which enforces the use of a single version for shared dependencies. Excluding the older version ensures that the build uses the latest, compatible version of proto-google-common-protos.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this excluding the enforcement of duplicate dependencies, not "excluding the older version"?

Copy link
Author

Choose a reason for hiding this comment

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

You're right that this is more about managing duplicate dependencies than directly "excluding the older version." When I say "excluding the older version," I mean that by using the tag, we're preventing Maven from including conflicting transitive versions of proto-google-common-protos. This ensures that the build system selects the correct, non-conflicting version that is compatible with the rest of the dependencies.

Copy link
Contributor

Choose a reason for hiding this comment

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

I do not follow. Isn't this just excluding enforcement of upper bound dependencies? What tag?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry for the confusion. What I meant is that the tag in the enforcer plugin is used to manage conflicting transitive dependencies by preventing Maven from enforcing the upper-bound rule on specific dependencies like proto-google-common-protos. This way, the build process doesn’t fail due to multiple versions being pulled in from different Google Cloud libraries. ensures that Maven doesn’t enforce a version mismatch for proto-google-common-protos, allowing the correct version to be used without causing a conflict.Let me know if this clears things up!

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry but I still don't understand, how does this exclusion ensure only one version is being used? Aren't multiple being used and we're just ignoring the dependency? What happens if you remove this line of code?

Copy link
Author

Choose a reason for hiding this comment

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

The exclusion is not just ignoring the dependency it helps resolve a version conflict that occurs specifically in the presto-bigquery module. This conflict arises because different transitive dependencies (like google-cloud-core, gax-grpc, and others) pull in multiple versions of proto-google-common-protos. Without the exclusion, Maven fails the build due to version conflicts, as seen in the error log for presto-bigquery.

image

By excluding this from the enforcer's upper-bound rule, Maven allows the correct version to be selected during dependency resolution. This issue only occurs in presto-bigquery, so we could limit this exclusion to that module in the enforcer configuration.

Would it be okay to apply it just to presto-bigquery ?

pom.xml Outdated
@@ -2357,6 +2408,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>com.google.api.grpc:proto-google-common-protos</exclude>
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry but I still don't understand, how does this exclusion ensure only one version is being used? Aren't multiple being used and we're just ignoring the dependency? What happens if you remove this line of code?

@Mariamalmesfer Mariamalmesfer force-pushed the jackson-core-fix branch 2 times, most recently from cae6933 to 7b94b04 Compare October 25, 2024 23:10
@tdcmeehan
Copy link
Contributor

LGTM but please fix this typo in the commit message: [Upgraded jakcson-core to 2.15.4](https://github.com/prestodb/presto/pull/23753/commits/7b94b0459c7024b8e3880a06dbb3dbcecc49d8a0). jakcson->jackson

@Mariamalmesfer Mariamalmesfer force-pushed the jackson-core-fix branch 2 times, most recently from 66e4caa to 9aca2fa Compare October 28, 2024 20:45
tdcmeehan
tdcmeehan previously approved these changes Oct 28, 2024
@@ -258,6 +258,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.14.3</version>
Copy link
Member

Choose a reason for hiding this comment

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

I see this is already included in root pom - https://github.com/prestodb/presto/pull/23753/files#diff-9c5fb3d1b7e3b0f54bc5c4182965c4fe1f9023d449017cece3005d3f90e8e4d8R795

Do we still need version here? Is it coming in higher version as transitive dependency from other place?

Copy link
Author

@Mariamalmesfer Mariamalmesfer Nov 4, 2024

Choose a reason for hiding this comment

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

The specific issue with jackson-databind 2.15.0 and above affects Presto-Hive tests. Downgrading jackson-databind to 2.14.3 here has stabilized the tests without impacting the rest of the engine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems the serialized test data should be updated instead. This is going in the wrong direction

pom.xml Show resolved Hide resolved
@Mariamalmesfer Mariamalmesfer force-pushed the jackson-core-fix branch 8 times, most recently from 1b2a46e to 8208d1e Compare November 4, 2024 11:23
@steveburnett
Copy link
Contributor

Nit I didn't notice earlier, please remove the # from the release note entry

 == RELEASE NOTES == =

Security Changes
* Upgrade Jackson-core to 2.15.4. :pr:`23753`

@Mariamalmesfer Mariamalmesfer force-pushed the jackson-core-fix branch 5 times, most recently from 592392b to b0b5b17 Compare November 4, 2024 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants