CVE-2026-59340
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 design principles such as portability and modular design to AI applications. It provides abstractions for chat and embedding models, vector stores and document readers, including PDF readers used to ingest documents for retrieval-augmented generation (RAG).
A denial of service vulnerability (CVE-2026-59340) has been identified in the Spring AI PDF document reader, which allows attackers to exhaust the JVM heap by supplying a specially crafted PDF to PagePdfDocumentReader or ParagraphPdfDocumentReader. Depending on JVM configuration, this can cause request failures and degraded service under repeated exploitation, or immediate JVM termination when ExitOnOutOfMemoryError options are used.
Per OWASP: The Denial of Service (DoS) attack is focused on making a resource (site, application, server) unavailable for the purpose it was designed.
This issue affects multiple versions of Spring AI.
Details
Module Info
- Product: Spring AI
- Affected packages:
org.springframework.ai:spring-ai-pdf-document-reader - 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-pdf-document-reader
- Package manager: Maven
- Fixed in:
- OSS Spring AI 2.0.3
- NES for Spring AI v1.0.12, v1.1.11
Vulnerability Info
This Medium-severity vulnerability is found in the org.springframework.ai:spring-ai-pdf-document-reader package in multiple versions of Spring AI. PagePdfDocumentReader and ParagraphPdfDocumentReader extract text through ForkPDFLayoutTextStripper (via its region-based subclass PDFLayoutTextStripperByArea), which rebuilds the visual layout of each page from the positions of its glyphs. When the vertical distance between two consecutive glyphs is larger than one line, the stripper fills the gap with blank TextLine objects, each allocated with a character buffer sized to the page width:
private void iterateThroughTextList(Iterator<TextPosition> textIterator) {
List<TextPosition> textPositionList = new ArrayList<>();
while (textIterator.hasNext()) {
TextPosition textPosition = (TextPosition) textIterator.next();
int numberOfNewLines = this.getNumberOfNewLinesFromPreviousTextPosition(textPosition);
if (numberOfNewLines == 0) {
textPositionList.add(textPosition);
}
else {
this.writeTextPositionList(textPositionList);
if (numberOfNewLines > 10_000) {
// Throw rather than allocate crazy number of line objects
throw new IllegalStateException("Unreasonable number of lines (%d) computed from content of pdf"
.formatted(numberOfNewLines));
}
this.createNewEmptyNewLines(numberOfNewLines);
textPositionList.add(textPosition);
}
this.setPreviousTextPosition(textPosition);
}
...
}
private void createNewEmptyNewLines(int numberOfNewLines) {
for (int i = 0; i < numberOfNewLines - 1; ++i) {
this.addNewLine();
}
}
private TextLine addNewLine() {
TextLine textLine = new TextLine(this.getCurrentPageWidth());
this.textLineList.add(textLine);
return textLine;
}The number of lines for a gap is derived from the glyph coordinates and the glyph height, both of which are controlled by the PDF author. The only limit is the check on a single gap: a gap of up to 10,000 lines is accepted, and nothing limits how many such gaps a page may contain or how many lines addNewLine() accumulates in textLineList for the page as a whole. Each line buffer is also capped on its own, but neither cap bounds the total. A crafted page whose glyphs are separated by many large vertical gaps stays under the per-gap check each time while accumulating an unbounded number of page-width line buffers, until the JVM throws OutOfMemoryError.
Both readers drive this stripper through its subclass PDFLayoutTextStripperByArea, whose writePage() calls the parent writePage() once per region without clearing textLineList or the previous text position. Lines from earlier regions are carried into later ones, so the accumulated line list for a page grows further across regions. Any application that passes PDFs from untrusted sources (document uploads, email attachments, RAG ingestion pipelines, web crawling) to either reader is exposed.
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
- Chae Jisung (Jisung Chae) (finder)