CVE-2026-59345
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
- Product: Spring AI
- Affected packages:
org.springframework.ai:spring-ai-commons - Affected versions: >=1.0.0 <=1.0.10, >=1.1.0 <=1.1.9, >=2.0.0 <=2.0.2
- GitHub repository: https://github.com/spring-projects/spring-ai
- Published packages: https://central.sonatype.com/artifact/org.springframework.ai/spring-ai-commons
- Package manager: Maven
- Fixed in:
- OSS Spring AI 2.0.3
- NES for Spring AI
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
- Add
org.springframework.ai:spring-ai-commons1.1.8 (or any other affected version) to the classpath. - 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);
}
}- Observe that the program fails with
java.lang.StackOverflowErrorthrown fromjava.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)