CVE-2026-59345

Denial of Service
Affects
Spring AI
in
Spring
No items found.
Versions
>=1.0.0 <=1.0.10, >=1.1.0 <=1.1.9, >=2.0.0 <=2.0.2

Patch Available.

Exclamation circle icon
Patch Available

This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.

Overview

Spring AI is an application framework for AI engineering that brings Spring's design principles, such as portability and modular design, to AI applications. It includes document readers that extract text from PDFs and other files for retrieval-augmented generation (RAG) and other ingestion pipelines.

A denial of service vulnerability (CVE-2026-59345) has been identified in the ExtractedTextFormatter class of Spring AI, which allows attackers to crash the thread that processes a document by submitting a document whose extracted text contains a very long run of blank lines. Repeated submissions against a bounded worker pool can degrade or deny service to all users of the application.

Per OWASP: The Denial of Service (DoS) attack is focused on making a resource (site, application, server) unavailable for the purpose it was designed. There are many ways to make a service unavailable for legitimate users by manipulating network packets, programming, logical, or resources handling vulnerabilities, among others.

This issue affects multiple versions of Spring AI.

Details

Module Info

Vulnerability Info

This High-severity vulnerability is found in the org.springframework.ai:spring-ai-commons package in multiple versions of Spring AI. ExtractedTextFormatter cleans up the text that document readers such as TikaDocumentReader, PagePdfDocumentReader and ParagraphPdfDocumentReader extract from a file. Its format() method always calls trimAdjacentBlankLines(), and calls alignToLeft() when left alignment is enabled. Both methods collapse runs of blank lines with a regular expression that contains a quantified group:

public static String trimAdjacentBlankLines(String pageText) {
    return pageText.replaceAll("(?m)(^ *\n)", "\n").replaceAll("(?m)^$([\r\n]+?)(^$[\r\n]+?^)+", "$1");
}

public static String alignToLeft(String pageText) {
    return pageText.replaceAll("(?m)(^ *| +(?= |$))", "").replaceAll("(?m)^$(\t?)(^$[\r\n]+?^)+", "$1");
}

Java's backtracking regular expression engine matches each repetition of the group (^$[\r\n]+?^)+ with a further recursive call, so the stack depth grows with the number of consecutive blank lines in the input. The extracted text comes straight from the document, so an attacker who can supply a document only needs to include tens of thousands of consecutive blank lines to exhaust the calling thread's stack. The resulting StackOverflowError is not handled and kills the thread processing the document. This works regardless of the file type, because the blank lines only need to survive text extraction. Any application that ingests untrusted documents, for example through document uploads, email attachment processing, RAG ingestion or web crawling, can be driven into repeatedly losing its worker threads.

Steps to Reproduce

  1. Add org.springframework.ai:spring-ai-commons 1.1.8 (or any other affected version) to the classpath.
  2. Run the following program:
import org.springframework.ai.reader.ExtractedTextFormatter;

public class Repro {
    public static void main(String[] args) {
        String text = "Header\n" + "\n".repeat(50_000) + "Footer";
        ExtractedTextFormatter.defaults().format(text);
    }
}
  1. Observe that the program fails with java.lang.StackOverflowError thrown from java.util.regex.Pattern.

Mitigation

Only recent versions of Spring AI receive community support. Older lines are End-of-Life and will not receive public updates to address this issue.

Users of the affected components should apply one of the following mitigations:

  • Upgrade to a currently supported version of Spring AI.
  • Leverage a commercial support partner like HeroDevs for post-EOL security support.

Credits

  • Sai Sreewathsa Kovalluri from Innspark Solutions (finder)
  • Kannan K from Innspark Solutions (finder)
  • Shon Babu from Innspark Solutions (finder)
Vulnerability Details
Severity
Level
CVSS Assessment
Low
>=0 <4
Medium
>=4 <6
High
>=6 <8
Critical
>=8 <10
High
ID
CVE-2026-59345
PROJECT Affected
Spring AI
Versions Affected
>=1.0.0 <=1.0.10, >=1.1.0 <=1.1.9, >=2.0.0 <=2.0.2
NES Versions Affected
Published date
November 20, 2026
≈ Fix date
Category
Denial of Service
Vex Document
Download VEXHow do I use it?
Sign up for the latest vulnerability alerts fixed in
NES for Spring
Rss feed icon
Subscribe via RSS
or

By submitting the form I acknowledge receipt of our Privacy Policy.

Thanks for signing up for our Newsletter! We look forward to connecting with you.
Oops! Something went wrong while submitting the form.