Summary
T2.1 hardening sub-task of parent epic #73. This is defense-in-depth for the 15 CVEs in commons-tika 2.9.x (the latest 1.8-compatible line). The CVEs are in the parser implementations (XML XXE, ZIP-bomb, embedded scripts, SSRF, etc.); closing them requires either a library upgrade (no 1.8-compatible fix available) or defensive code patterns in the few call sites.
This issue covers the 7 production files in the project that use Tika. The hardening is to wrap the input stream with a size cap so that an attacker-controlled file (e.g., a 10 GB uploaded file) is rejected before Tika's parsers see it.
What changes
1. New utility class (1 file, +50)
A small utility that wraps an InputStream with a configurable size cap:
// in PSTikaTextConvertor.getConvertedText(InputStream is, String mimetype):
try (InputStream safe = PSTikaCap.truncate(is, MAX_PARSE_INPUT_BYTES);
TikaInputStream tis = TikaInputStream.get(safe)) {
... // Tika sees a stream that is bounded; if a parser tries to read past the cap,
// it gets EOF
}
The utility uses a simple byte-counting wrapper that returns EOF after the configured cap is exceeded. Tika handles the EOF gracefully (returns a short parsed result rather than OOM).
2. Apply at the 3 production call sites (3 files)
The 3 files that do full parsing (vs. just mime detection):
| File |
What it does |
system/.../PSTikaTextConvertor.java |
Uses AutoDetectParser to extract text from uploaded files for Lucene indexing. Main attack surface (untrusted file content). |
system/services/.../PSDbStorageService.java |
Uses AutoDetectParser to re-parse metadata from files stored in the DB. |
system/services/.../aaclient/PSHashedFileWidgetHandler.java |
Indirect use; verify the call site. |
The 2 files that do only mime detection (AssetsResource.java, PSDbStorageService.java detection half) do not need the size cap — they read only the first few KB to sniff the magic bytes.
The 2 files that are just type definitions (PSMeta.java, PSBinary.java) and the streaming helper (ProxyInputStream.java) do not need changes.
Verification
Out of scope (separate issues under #73)
References
Co-Authored by Mavis v1.0.0 using minimax-m3 with agent mavis.
Summary
T2.1 hardening sub-task of parent epic #73. This is defense-in-depth for the 15 CVEs in commons-tika 2.9.x (the latest 1.8-compatible line). The CVEs are in the parser implementations (XML XXE, ZIP-bomb, embedded scripts, SSRF, etc.); closing them requires either a library upgrade (no 1.8-compatible fix available) or defensive code patterns in the few call sites.
This issue covers the 7 production files in the project that use Tika. The hardening is to wrap the input stream with a size cap so that an attacker-controlled file (e.g., a 10 GB uploaded file) is rejected before Tika's parsers see it.
What changes
1. New utility class (1 file, +50)
A small utility that wraps an InputStream with a configurable size cap:
The utility uses a simple byte-counting wrapper that returns EOF after the configured cap is exceeded. Tika handles the EOF gracefully (returns a short parsed result rather than OOM).
2. Apply at the 3 production call sites (3 files)
The 3 files that do full parsing (vs. just mime detection):
system/.../PSTikaTextConvertor.javaAutoDetectParserto extract text from uploaded files for Lucene indexing. Main attack surface (untrusted file content).system/services/.../PSDbStorageService.javaAutoDetectParserto re-parse metadata from files stored in the DB.system/services/.../aaclient/PSHashedFileWidgetHandler.javaThe 2 files that do only mime detection (
AssetsResource.java,PSDbStorageService.javadetection half) do not need the size cap — they read only the first few KB to sniff the magic bytes.The 2 files that are just type definitions (
PSMeta.java,PSBinary.java) and the streaming helper (ProxyInputStream.java) do not need changes.Verification
./mvn-env.sh clean install -DskipTestssucceeds on Java 1.8./mvn-env.sh spotless:checkpassesPSTikaTextConvertor.getConvertedTextreturns a short result (the cap is 100 MB; parser sees EOF at 100 MB) rather than OOM or hangingUnsupportedClassVersionErrorin the build log (Tika 2.9.x is Java 8 compatible)Out of scope (separate issues under #73)
StringSubstitutorwhich the project doesn't use) — N/Acommons-beanutils 1.11.0— the 1.x line is still maintained (1.11.0 in May 2025); issue deps: EOL replace commons-beanutils 1.11.0 with commons-beanutils2 2.0.0 (closes 3 CVEs + drops transitive SnakeYAML 16 CVEs) #91 was closedcommons-configuration 1.10— the project doesn't use it; N/AReferences
docs/ai-generated/tasks/PR#-DependencyVulnerabilityAnalysis/issues/02-epic-non-upgradeable.md#t21--apache-tika-29x-hardening