Add sequence nesting depth limit for parsing
authorMichael Onken <onken@open-connections.de>
Wed, 3 Jun 2026 19:54:21 +0000 (21:54 +0200)
committerÉtienne Mollier <emollier@debian.org>
Wed, 3 Jun 2026 19:54:21 +0000 (21:54 +0200)
commit6456a3ede2d3b0a8d6343301030f580ecbd225f5
treefcfb085a30883a7ea5d6d778536a8c3ce6f25bad
parentcbc92dbf892b653483565ed31e7d956f3b4d29b9
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
24 files changed:
config/docs/macros.txt
dcmdata/include/dcmtk/dcmdata/dcerror.h
dcmdata/include/dcmtk/dcmdata/dcfilefo.h
dcmdata/include/dcmtk/dcmdata/dcistrma.h
dcmdata/include/dcmtk/dcmdata/dcitem.h
dcmdata/include/dcmtk/dcmdata/dcobject.h
dcmdata/libsrc/dcdatset.cc
dcmdata/libsrc/dcerror.cc
dcmdata/libsrc/dcfilefo.cc
dcmdata/libsrc/dcistrma.cc
dcmdata/libsrc/dcitem.cc
dcmdata/libsrc/dcsequen.cc
dcmdata/tests/CMakeLists.txt
dcmdata/tests/Makefile.dep
dcmdata/tests/Makefile.in
dcmdata/tests/tests.cc
dcmdata/tests/tnesting.cc [new file with mode: 0644]
dcmnet/include/dcmtk/dcmnet/scp.h
dcmnet/include/dcmtk/dcmnet/scu.h
dcmnet/libsrc/dimse.cc
dcmnet/libsrc/scp.cc
dcmnet/libsrc/scu.cc
dcmnet/tests/tests.cc
dcmnet/tests/tscuscp.cc