Severity:

HIGH RISK

(7.3)

OS Command Injection in DCMTK storescp Service

CVE-2026-5663

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-77, CWE-78

Impact:

Remote Code Execution

Severity:

HIGH RISK

(7.3)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A command injection vulnerability in the DCMTK storescp component allows crafted input to influence OS command execution in the executeOnReception/executeOnEndOfStudy logic.

In networked deployments where untrusted DICOM data or remote peers can reach storescp, an attacker may trigger arbitrary command execution with the privileges of the storescp process.

Affected context

This vulnerability affects deployments using the DCMTK storescp application up to version 3.7.0 where:

  • The executeOnReception and/or executeOnEndOfStudy features are enabled to run external commands
  • Command strings are constructed based on incoming DICOM association parameters or file metadata
  • storescp is reachable over the network from untrusted or semi-trusted DICOM peers

The issue is most relevant in PACS, gateways, or test environments where storescp is exposed as a general DICOM receiver and not strictly isolated.

Exploit preconditions

  • Attack surface: Network-accessible DICOM Storage SCP (storescp) service.
  • Required access: Ability to establish a DICOM association and send crafted DICOM traffic or parameters to the vulnerable storescp instance.
  • Trigger point: Invocation of executeOnReception or executeOnEndOfStudy hooks that build and execute shell commands using untrusted data.
  • Why exploitation is possible: User-controlled or protocol-derived values are interpolated into shell command lines without proper quoting, escaping, or safer API usage, allowing attackers to break out of expected arguments and inject additional commands.

Why this happens

The underlying bug is an OS command injection issue, aligning with CWE-78.

In the affected storescp code path, external commands are assembled as shell strings that incorporate values influenced by DICOM associations or file metadata.

Because these values are not robustly validated or safely passed as separate arguments to a process-spawning API, the shell interprets embedded metacharacters (e.g., separators, redirection operators) as additional commands or options.

Conceptually, this represents an insecure pattern where application logic mixes trusted templates with untrusted input to form executable command lines instead of using parameterized or non-shell invocation mechanisms.

Potential impact

  • Execution of arbitrary OS commands with the privileges of the storescp process
  • Exposure or modification of medical imaging data handled by the affected system
  • Compromise of the host running DCMTK (e.g., installing backdoors, pivoting further into the network)
  • Disruption of DICOM services through data deletion, service stoppage, or resource exhaustion
  • Use of the compromised host as a foothold for lateral movement in healthcare or imaging networks

General mitigation guidance

Effective mitigation focuses on eliminating command injection patterns and reducing the trust boundary of external command hooks:

  • Replace shell-based command composition with APIs that execute programs using argument arrays (e.g., exec-style calls) to avoid shell parsing where possible.
  • Treat all data derived from DICOM peers or files as untrusted: perform strict validation, allowlists, and normalization before including values in any command context.
  • Avoid passing raw user-controlled strings into command templates; if external tools must be invoked, map inputs to pre-defined safe options instead of free-form arguments.
  • Limit or disable executeOnReception/executeOnEndOfStudy behavior in environments where it is not strictly required.
  • Run storescp under a dedicated, least-privileged account with constrained filesystem and network access to minimize blast radius if exploitation occurs.
  • Isolate DICOM receiver services via network segmentation and application-layer access controls to reduce exposure to untrusted senders.

How teams detect issues like this

Detection can combine code-centric and deployment-centric approaches:

  • Static analysis and manual review to flag patterns where:
  • Command strings are built via string concatenation/formatting using data derived from network input or file metadata.
  • Shell interpreters (e.g., system(), popen(), /bin/sh) are invoked with a single string parameter.
  • Configuration and policy checks that:
  • Identify use of executeOnReception/executeOnEndOfStudy or similar hooks that run external commands.
  • Enforce secure coding guidelines for external process execution (e.g., require argument-array APIs and allowlists).
  • Runtime monitoring:
  • Capture and inspect process creation events from storescp, looking for unexpected commands, arguments, or spikes in process spawning.
  • Use host-based intrusion detection or EDR agents to alert on suspicious shell activity originating from storescp processes.
  • CI/CD integration:
  • Incorporate automated scanners that understand C/C++ process-spawning APIs and flag high-risk command construction patterns early in development.

Sources

SourceLink
github.comgithub.com/DCMTK/dcmtk/commit/edbb085e45788dccaf0e64d71534cfca925784b8
machinespirits.commachinespirits.com/advisory/2e1627/
support.dcmtk.orgsupport.dcmtk.org/redmine/issues/1194
vuldb.comvuldb.com/submit/786061
vuldb.comvuldb.com/vuln/355486
vuldb.comvuldb.com/vuln/355486/cti

Frequently asked

questions

Yes. If the storescp service is exposed over the network and reachable by untrusted or malicious DICOM peers, an attacker can remotely send crafted DICOM traffic to trigger the vulnerable command execution paths.

The attacker typically needs the ability to initiate a DICOM association with the affected storescp instance and control fields or content that are later incorporated into the executeOnReception/executeOnEndOfStudy command templates.

No local shell access is required if the service is network-accessible.

The most robust fix is to avoid constructing shell command strings with untrusted data.

Use process-spawning APIs that accept argument arrays, apply strict validation and allowlists to any values that influence external commands, and remove or refactor any feature that relies on free-form command concatenation.

Define and enforce secure coding guidelines for external command execution, including:

  • Prohibiting direct shell invocation with interpolated strings.
  • Mandating strict input validation and canonicalization for all network-derived data.
  • Incorporating static analysis rules focused on command construction patterns.
  • Conducting security-focused code reviews for components that interact with the OS or spawn subprocesses, especially in network-facing services.
Find out what's already
exploitable in your codebase.