Vulnerabilities in pkg:maven/org.springframework.restdocs/spring-restdocs-webtestclient

PACKAGE
Advisory Identifier: GHSA-6rpq-6vv2-5222
Advisory Summary

CVE-2026-40991 is a MODERATE (CVSS 5.9) spring rest docs rest assured vulnerability (CWE-611: Improper Restriction of XML External Entity Reference) affecting Spring Framework libraries in the Maven ecosystem. The issue involves spring rest docs rest assured & webflux are vulnerable to improper restriction of xml external entity reference. Remediation is available by upgrading affected packages to version 4.0.1, 3.0.6.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:maven/org.springframework.restdocs/spring-restdocs-webtestclient

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:maven/org.springframework.restdocs/spring-restdocs-webtestclient. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-6rpq-6vv2-5222 CVE-2026-40991 MODERATE Spring REST Docs REST Assured & WebFlux are vulnerable to Improper Restriction of XML External Entity Reference

CVE-2026-40991 at a Glance

CVE Identifier CVE-2026-40991
GHSA Identifier GHSA-6rpq-6vv2-5222
Severity MODERATE
CVSS v3.1 Base Score 5.9
CWE Classification CWE-611: Improper Restriction of XML External Entity Reference
Affected Product Spring Framework
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 5.9

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

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

How to Fix CVE-2026-40991

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.restdocs:spring-restdocs-webtestclient fixed: 4.0.1
<dependency>
    <groupId>org.springframework.restdocs</groupId>
    <artifactId>spring-restdocs-webtestclient</artifactId>
    <version>4.0.1</version>
</dependency>
org.springframework.restdocs:spring-restdocs-webtestclient fixed: 3.0.6
<dependency>
    <groupId>org.springframework.restdocs</groupId>
    <artifactId>spring-restdocs-webtestclient</artifactId>
    <version>3.0.6</version>
</dependency>
org.springframework.restdocs:spring-restdocs-webtestclient fixed: Latest secure release
<dependency>
    <groupId>org.springframework.restdocs</groupId>
    <artifactId>spring-restdocs-webtestclient</artifactId>
    <version>Latest secure release</version>
</dependency>
org.springframework.restdocs:spring-restdocs-restassured fixed: 4.0.1
<dependency>
    <groupId>org.springframework.restdocs</groupId>
    <artifactId>spring-restdocs-restassured</artifactId>
    <version>4.0.1</version>
</dependency>
org.springframework.restdocs:spring-restdocs-restassured fixed: 3.0.6
<dependency>
    <groupId>org.springframework.restdocs</groupId>
    <artifactId>spring-restdocs-restassured</artifactId>
    <version>3.0.6</version>
</dependency>
org.springframework.restdocs:spring-restdocs-restassured fixed: Latest secure release
<dependency>
    <groupId>org.springframework.restdocs</groupId>
    <artifactId>spring-restdocs-restassured</artifactId>
    <version>Latest secure release</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.restdocs

How to Check if You Are Affected

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

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

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 4.0.1), your application is affected.

Note: The mvn dependency:tree -Dincludes=org.springframework.restdocs 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-611: Improper Restriction of XML External Entity Reference, where the product processes an xml document that can contain xml entities with uris that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. 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

When using spring-restdocs-webtestclient or spring-restdocs-restassured to document a remote API accessed over HTTP, an attacker who compromises the API or tricks the user into documenting a malicious API can perform an XXE injection attack when the documentation-generating tests are next executed. Affected versions: Spring REST Docs 4.0.0; 3.0.0 through 3.0.5; 2.0.0.RELEASE through 2.0.8.RELEASE.

CVE-2026-40991 Affected Spring Framework Versions

6 component(s)
Fixed Versions:
4.0.13.0.6
Product / Package Ecosystem Affected Versions Fixed Version
org.springframework.restdocs:spring-restdocs-webtestclient
Maven
≥ 4.0.0
< 4.0.1
All 1 versions
4.0.0
4.0.1
org.springframework.restdocs:spring-restdocs-webtestclient
Maven
≥ 3.0.0
< 3.0.6
3.0.6
org.springframework.restdocs:spring-restdocs-webtestclient
Maven
≤ 2.0.8.RELEASE
org.springframework.restdocs:spring-restdocs-restassured
Maven
≥ 4.0.0
< 4.0.1
All 1 versions
4.0.0
4.0.1
org.springframework.restdocs:spring-restdocs-restassured
Maven
≥ 3.0.0
< 3.0.6
3.0.6
org.springframework.restdocs:spring-restdocs-restassured
Maven
≤ 2.0.8.RELEASE

References

Frequently Asked Questions

What is CVE-2026-40991?
CVE-2026-40991 is a security vulnerability in Spring Framework involving Spring REST Docs REST Assured & WebFlux are vulnerable to Improper Restriction of XML External Entity Reference under CWE-611: Improper Restriction of XML External Entity Reference.
Which Spring Framework versions are affected?
Affected versions include releases prior to 4.0.1, 3.0.6 across affected packages: org.springframework.restdocs:spring-restdocs-webtestclient, org.springframework.restdocs:spring-restdocs-restassured.
What version fixes CVE-2026-40991?
Upgrading to 4.0.1, 3.0.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is spring-restdocs-webtestclient affected?
Yes, org.springframework.restdocs:spring-restdocs-webtestclient is affected in releases prior to 4.0.1, 3.0.6, Latest secure release. Upgrade your dependency to 4.0.1, 3.0.6, Latest secure release or later.
Is spring-restdocs-restassured affected?
Yes, org.springframework.restdocs:spring-restdocs-restassured is affected in releases prior to 4.0.1, 3.0.6, Latest secure release. Upgrade your dependency to 4.0.1, 3.0.6, Latest secure release or later.
What is the CVSS score of CVE-2026-40991?
CVE-2026-40991 has a CVSS v3.1 base score of 5.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:L.
What CWE is associated with CVE-2026-40991?
CVE-2026-40991 is classified under CWE-611: Improper Restriction of XML External Entity Reference (The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.).
How can I check Maven dependencies for CVE-2026-40991?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.springframework.restdocs'. 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-6rpq-6vv2-5222",
  "modified" : "2026-08-12T15:26:08Z",
  "published" : "2026-06-10T00:31:51Z",
  "aliases" : [ "CVE-2026-40991" ],
  "summary" : "Spring REST Docs REST Assured & WebFlux are vulnerable to Improper Restriction of XML External Entity Reference",
  "details" : "When using spring-restdocs-webtestclient or spring-restdocs-restassured to document a remote API accessed over HTTP, an attacker who compromises the API or tricks the user into documenting a malicious API can perform an XXE injection attack when the documentation-generating tests are next executed.\n\nAffected versions:\nSpring REST Docs 4.0.0; 3.0.0 through 3.0.5; 2.0.0.RELEASE through 2.0.8.RELEASE.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework.restdocs:spring-restdocs-webtestclient"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.0.1"
      } ]
    } ],
    "versions" : [ "4.0.0" ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework.restdocs:spring-restdocs-webtestclient"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "3.0.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.0.5"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework.restdocs:spring-restdocs-webtestclient"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "2.0.8.RELEASE"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework.restdocs:spring-restdocs-restassured"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.0.1"
      } ]
    } ],
    "versions" : [ "4.0.0" ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework.restdocs:spring-restdocs-restassured"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "3.0.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.0.5"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework.restdocs:spring-restdocs-restassured"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "2.0.8.RELEASE"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-40991"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/spring-projects/spring-restdocs"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/spring-projects/spring-restdocs/releases/tag/v3.0.6"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/spring-projects/spring-restdocs/releases/tag/v4.0.1"
  }, {
    "type" : "WEB",
    "url" : "https://spring.io/security/cve-2026-40991"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-611" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-08-12T15:26:08Z",
    "nvd_published_at" : "2026-06-10T00:16:50Z"
  }
}