Add sequence nesting depth limit for parsing
Applied-Upstream:
885ff0f10372bd589b5f44cea974f28a3964cb0f
Last-Update: 2026-04-11
Bug: https://support.dcmtk.org/redmine/issues/1191
Bug-Debian: https://bugs.debian.org/
1138713
Reviewed-By: Étienne Mollier <emollier@debian.org>
Track sequence nesting depth on DcmInputStream during parsing. When the
depth exceeds a configurable limit, parsing is aborted with
EC_NestingDepthLimitExceeded. This prevents stack overflow from
excessively nested DICOM sequences.
The default limit is controlled by the compile-time macro
DCMTK_MAX_SEQUENCE_NESTING (default: 64). It can be overridden per parse
operation via the runtime API:
- DcmInputStream::setMaxNestingDepth() for direct stream access
- DcmItem::setMaxNestingDepth() (inherited by DcmDataset) for loadFile()
and read()
- DcmFileFormat::setMaxNestingDepth() for loadFile() and read(),
forwarded to the contained dataset
- DcmSCP::setMaxNestingDepth() and DcmSCU::setMaxNestingDepth() for
datasets received over the network via receiveDIMSEDataset()
The runtime setter uses Sint32 semantics:
0 = compile-time default, -1 = unlimited, >0 = limit
Note: the specific EC_NestingDepthLimitExceeded error code is not yet
surfaced through the DIMSE layer; DIMSE_receiveDataSetInMemory() maps
all parse errors to DIMSE_RECEIVEFAILED.
Thanks to the IN-CYPHER OSS Security Team for the report, detailed
analysis and proof of concept.
This closes DCMTK Bug #1191.
Gbp-Pq: Name CVE-2026-10528-partial.patch