Denial of Service in Spring Batch FlatFileItemReader via Malformed Input File

MEDIUM | AUGUST 20, 2026 | CVE-2026-47881

Description

Spring Batch's FlatFileItemReader supports files where a single logical record spans multiple physical lines — for example, a CSV field that contains embedded newlines wrapped in quotes. A specially crafted input file could exploit the way the reader assembles those multi-line records to consume excessive CPU time and memory, causing the batch job to stall or run out of memory.

This issue affects applications that use DefaultRecordSeparatorPolicy or JsonRecordSeparatorPolicy. The default policy (SimpleRecordSeparatorPolicy) is not affected.

Affected Spring Products and Versions

Spring Batch:

  • 6.0.0 - 6.0.4
  • 5.2.0 - 5.2.6
  • 4.3.0 - 4.3.13

Mitigation

Users of affected versions should upgrade to the corresponding fixed version.
Fix versionAvailability
6.0.5OSS
6.0.4.1Enterprise Support Only
5.2.7Enterprise Support Only
4.3.14Enterprise Support Only

The fix is included in these releases and requires no code changes for most applications. After upgrading, the reader enforces safe default limits on how large a single multi-line record may grow: at most 1 000 physical lines and 1 MiB of accumulated text. If a file exceeds either limit, the reader stops immediately with a clear error message instead of continuing to process a potentially malicious input.

If your application might read files with records larger than these defaults, you can raise the limits on the reader:

// Direct use
FlatFileItemReader<MyItem> reader = new FlatFileItemReader<>(lineMapper);
reader.setMaxLinesPerRecord(5_000);   // raise the line cap
reader.setMaxBytesPerRecord(5 * 1024 * 1024);  // raise the size cap to 5 MiB

// Via the builder
FlatFileItemReader<MyItem> reader = new FlatFileItemReaderBuilder<MyItem>()
        .name("myReader")
        .resource(resource)
        .maxLinesPerRecord(5_000)
        .maxBytesPerRecord(5 * 1024 * 1024)
        // ... rest of configuration
        .build();

Setting either limit to Integer.MAX_VALUE effectively disables it; this is not recommended when processing files from untrusted sources.

If upgrading is not immediately possible, add an application-level check that rejects files above a safe size threshold before they are opened by the reader, or switch to SimpleRecordSeparatorPolicy if multi-line record support is not required by your use case.

History

  • 2026-08-20: Initial vulnerability report published.

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

Tanzu Spring offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all