CVE-2019-3797: Spring Framework SQL Injection Vulnerability

MODERATE
Advisory Identifier: GHSA-jgmr-wrwx-mgfj
CVSS 5.3
CWE-89 CWE-200
Published
Advisory Summary

CVE-2019-3797 is a MODERATE (CVSS 5.3) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Spring Framework libraries in the Maven ecosystem. The issue involves exposure of sensitive information to an unauthorized actor and sql injection in spring data jpa. Remediation is available by upgrading affected packages to version 1.11.20, 2.0.14, 2.1.6.

CVE-2019-3797 at a Glance

CVE Identifier CVE-2019-3797
GHSA Identifier GHSA-jgmr-wrwx-mgfj
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product Spring Framework
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2019-3797

To remediate this vulnerability, upgrade all affected Spring Framework dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

org.springframework.data:spring-data-jpa fixed: 1.11.20
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <version>1.11.20</version>
</dependency>
org.springframework.data:spring-data-jpa fixed: 2.0.14
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <version>2.0.14</version>
</dependency>
org.springframework.data:spring-data-jpa fixed: 2.1.6
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <version>2.1.6</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=org.springframework.data

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2019-3797, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=org.springframework.data

Analyze the terminal output to locate any version of Spring Framework in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.11.20), your application is affected.

Note: The mvn dependency:tree -Dincludes=org.springframework.data command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Spring Framework, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

This affects Spring Data JPA in versions up to and including 2.1.5, 2.0.13 and 1.11.19. Derived queries using any of the predicates ?startingWith?, ?endingWith? or ?containing? could return more results than anticipated when a maliciously crafted query parameter value is supplied. Also, LIKE expressions in manually defined queries could return unexpected results if the parameter values bound did not have escaped reserved characters properly.

CVE-2019-3797 Affected Spring Framework Versions

3 component(s)
Fixed Versions:
1.11.202.0.142.1.6
Product / Package Ecosystem Affected Versions Fixed Version
org.springframework.data:spring-data-jpa
Maven
< 1.11.20
1.11.20
org.springframework.data:spring-data-jpa
Maven
≥ 2.0.0
< 2.0.14
2.0.14
org.springframework.data:spring-data-jpa
Maven
≥ 2.1.0
< 2.1.6
2.1.6

References

Frequently Asked Questions

What is CVE-2019-3797?
CVE-2019-3797 is a security vulnerability in Spring Framework involving Exposure of Sensitive Information to an Unauthorized Actor and SQL Injection in Spring Data JPA under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which Spring Framework versions are affected?
Affected versions include releases prior to 1.11.20, 2.0.14, 2.1.6 across affected packages: org.springframework.data:spring-data-jpa.
What version fixes CVE-2019-3797?
Upgrading to 1.11.20, 2.0.14, 2.1.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is spring-data-jpa affected?
Yes, org.springframework.data:spring-data-jpa is affected in releases prior to 1.11.20, 2.0.14, 2.1.6. Upgrade your dependency to 1.11.20, 2.0.14, 2.1.6 or later.
What is the CVSS score of CVE-2019-3797?
CVE-2019-3797 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2019-3797?
CVE-2019-3797 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check Maven dependencies for CVE-2019-3797?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.springframework.data'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-jgmr-wrwx-mgfj",
  "modified" : "2021-08-03T21:46:37Z",
  "published" : "2019-05-14T04:02:35Z",
  "aliases" : [ "CVE-2019-3797" ],
  "summary" : "Exposure of Sensitive Information to an Unauthorized Actor and SQL Injection in Spring Data JPA",
  "details" : "This affects Spring Data JPA in versions up to and including 2.1.5, 2.0.13 and 1.11.19. Derived queries using any of the predicates ?startingWith?, ?endingWith? or ?containing? could return more results than anticipated when a maliciously crafted query parameter value is supplied. Also, LIKE expressions in manually defined queries could return unexpected results if the parameter values bound did not have escaped reserved characters properly.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework.data:spring-data-jpa"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.11.20"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework.data:spring-data-jpa"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.0.14"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework.data:spring-data-jpa"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.1.0"
      }, {
        "fixed" : "2.1.6"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2019-3797"
  }, {
    "type" : "WEB",
    "url" : "https://pivotal.io/security/cve-2019-3797"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200", "CWE-89" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2019-05-10T04:22:00Z",
    "nvd_published_at" : "2019-05-06T16:29:00Z"
  }
}