Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

A scanner flags jackson-databind: how to upgrade it in Gradle

Errorjackson-databind vulnerability reported by a dependency scanner

Short answer

Find where the old jackson-databind comes from, then raise it. A dependency constraint raises a transitive version without adding a new dependency. In a Spring Boot project the version is managed by the BOM, so change its Jackson version property, or use a resolution rule if you use Gradle's own BOM support.

  • Applies to Gradle 8.x, Spring Boot 3.x/4.x, Java 21
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask Gradle which version is resolved and which dependency asked for it. The arrow in the output (1.2 -> 1.3) shows an upgrade.

    ./gradlew -q dependencyInsight --dependency jackson-databind --configuration runtimeClasspath
  2. 2Match what you see, then jump to its fix

    1. 1dependencyInsight shows jackson-databind reached only through another libraryA transitive dependency pulls in the old versionFix
    2. 2The project applies the io.spring.dependency-management plugin and the version matches the Boot release, not a libraryThe Spring Boot dependency management pins JacksonFix
    3. 3The version property is set but nothing changes, and the build uses platform(SpringBootPlugin.BOM_COORDINATES)Gradle's native BOM support ignores the Boot propertyFix

What does the error look like?

  • jackson-databind vulnerability reported by a dependency scanner

Cause 1 of 3

A transitive dependency pulls in the old version

1Check

Read the dependency paths in the insight output and note the library on top of the path.

./gradlew -q dependencyInsight --dependency jackson-databind --configuration runtimeClasspath

2Fix

Add a dependency constraint. A constraint sets a version requirement without adding the module as a direct dependency, and has no effect if the module is not in the graph.

dependencies {
    constraints {
        implementation("com.fasterxml.jackson.core:jackson-databind:2.18.2") {
            because("fixes the reported vulnerability")
        }
    }
}

3Verify

Run the insight again: the selection reason shows By constraint and the version is the new one.

./gradlew -q dependencyInsight --dependency jackson-databind --configuration runtimeClasspath

Confirmed by docs.gradle.org

Did this fix it?

Cause 2 of 3

The Spring Boot dependency management pins Jackson

1Check

Spring Boot's BOM manages the Jackson version through a property. Find the property name for your Boot version in the dependency versions properties appendix (it lists a Jackson Bom row, jackson-bom.version, and a separate Jackson 2 Bom row, jackson-2-bom.version; pick the one that manages the com.fasterxml jackson-databind you see).

./gradlew -q dependencyInsight --dependency jackson-databind --configuration runtimeClasspath

2Fix

Set the managed version property in the build script. Spring warns that overriding versions can cause compatibility problems, so choose a patch release of the same Jackson line.

// build.gradle
ext['jackson-bom.version'] = '2.18.2'

3Verify

Run the insight task again and confirm the version changed.

./gradlew -q dependencyInsight --dependency jackson-databind --configuration runtimeClasspath

Confirmed by docs.spring.io

Did this fix it?

Cause 3 of 3

Gradle's native BOM support ignores the Boot property

1Check

Spring's docs state that with Gradle's bom support the properties from spring-boot-dependencies cannot control the managed versions.

grep -n -E "BOM_COORDINATES|spring-boot-dependencies" build.gradle*

2Fix

Use a mechanism Gradle provides, such as a resolution strategy rule that forces the group to a version.

configurations.all {
    resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.fasterxml.jackson.core') {
            details.useVersion '2.18.2'
        }
    }
}

3Verify

Run the insight task; the selection reason shows a rule.

./gradlew -q dependencyInsight --dependency jackson-databind --configuration runtimeClasspath

Confirmed by docs.spring.io

Did this fix it?

How do I stop it coming back?

  • Run dependencyInsight on any flagged library before changing versions, so you fix the real source.
  • Prefer upgrading the library that brings Jackson in when a newer release exists.
  • Keep Jackson modules on one version: jackson-core, databind and annotations should move together.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

Spring Boot will not start because port 8080 is already taken

Action: Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.

Spring Boot listens on 8080 unless told otherwise, and only one process can own a port.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.