Severity:

HIGH RISK

(7.8)

Code Injection (CWE-94) in uproot ROOT file parsing

CVE-2026-9147

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Arbitrary Code Execution

Severity:

HIGH RISK

(7.8)

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 code injection flaw in uproot's ROOT file parsing allows attacker-controlled metadata fields to be interpolated directly into dynamically generated Python source code.

When a crafted ROOT file is opened and processed through affected uproot code paths, the injected Python expressions can be executed in the context of the application, leading to arbitrary code execution.

Affected context

This vulnerability occurs in applications that use uproot to open and process ROOT files, particularly where TStreamerInfo records are parsed and corresponding Python reader classes are generated at runtime.

It becomes relevant when streamer metadata fields from the file, such as element names, are inserted into the generated Python source without safe quoting or escaping.

The risk is most pronounced in environments that consume untrusted or externally supplied ROOT files, such as data ingestion pipelines, shared analysis platforms, or automated batch-processing systems.

Exploit preconditions

  • Attack surface: ROOT file parsing via uproot, specifically code paths that dynamically generate and compile Python classes from TStreamerInfo.
  • Required access: Ability to supply or influence ROOT files processed by the application (e.g., upload, file drop, or control over input datasets).
  • Trigger point: Opening and reading a crafted ROOT file that contains malicious streamer metadata; uproot generates and invokes a reader method using interpolated, unsafely quoted metadata.
  • Why exploitation is possible: Certain streamer metadata fields are interpolated into Python source code without protective quoting (e.g., via repr() or !r), enabling attacker-supplied content to break out of expected expressions and introduce arbitrary Python code that is compiled and executed.

Why this happens

The underlying bug stems from unsafe construction of executable Python source code using data fields drawn directly from a file format without appropriate sanitization or quoting.

In affected uproot code paths, metadata from ROOT TStreamerInfo records, such as element names, are interpolated into dynamically generated Python class definitions as if they were trusted identifiers or literals.

Without using mechanisms like repr() or the !r format specifier to safely quote these values, an attacker can embed expression-breaking characters and Python syntax into the metadata fields.

This behavior maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), where external input is allowed to shape executable code in a way that permits unintended execution of attacker-provided logic.

Potential impact

  • Arbitrary Python code execution within the application process that opens the malicious ROOT file
  • Compromise of the local runtime environment, including access to in-memory data and application secrets
  • Unauthorized file access, modification, or deletion on the host system, subject to process privileges
  • Use of the compromised application as a pivot for wider system or network attacks
  • Manipulation or corruption of scientific or analytical data processed from ROOT files

General mitigation guidance

Effective mitigation focuses on separating untrusted file metadata from executable code and constraining how dynamic code is generated:

  • Ensure all file-controlled metadata fields used in dynamic source generation are safely quoted or escaped, for example via repr() or equivalent mechanisms that treat them as data rather than code.
  • Prefer structured code generation patterns that do not directly embed raw strings from the input into executable expressions, using parameterization or template systems with strict escaping rules.
  • Reduce reliance on dynamic compilation where possible in favor of static, schema-driven parsing logic that treats metadata as data-only.
  • Run file-parsing components with least privilege and isolated execution contexts (e.g., sandboxed workers or restricted environments) so that, if a parsing defect is present, the impact is constrained.
  • Apply stricter input validation and sanity checks on streamer metadata fields before they are used in any code-generation routines, rejecting or safely handling unexpected or malformed values.

How teams detect issues like this

Organizations can detect similar vulnerabilities through a mix of static analysis, targeted code review, and policy enforcement:

  • Use static analysis rules or linters to flag patterns where dynamic source code is constructed using f-strings, format(), or string concatenation with untrusted inputs.
  • During code review, pay attention to any logic that generates or compiles code at runtime (e.g., exec, eval, compile) and verify that all interpolated values are properly quoted, escaped, or otherwise constrained.
  • Define internal security guidelines that discourage unrestricted dynamic code generation, requiring justification and defensive patterns (such as strict input normalization and sandboxing) when it is unavoidable.
  • Employ automated security scanning tools that understand common code injection patterns and can alert on use of dangerous APIs combined with external data sources like file formats.

Sources

SourceLink
github.comgithub.com/SaiTeja-Erukude/CVE-2026-9147-uproot-rce
github.comgithub.com/scikit-hep/uproot5
github.comgithub.com/scikit-hep/uproot5/commit/c045c2824295d907d2e705f31110c742928e50e7
github.comgithub.com/scikit-hep/uproot5/security/advisories/GHSA-6946-mq52-g438
vulncheck.comvulncheck.com/advisories/uproot-and-before-code-injection-via-tstreamerinfo-metadata

Frequently asked

questions

Exploitability depends on how ROOT files are supplied to the application. If an attacker can remotely upload, submit, or otherwise cause a crafted ROOT file to be processed by an uproot-based service, then the vulnerability can be exploited remotely. In purely local workflows where files are fully trusted, the practical risk is lower.

The attacker must be able to provide or influence one or more ROOT files that the application will open with uproot using affected code paths. No direct interactive shell access is required; control over the input files is the key prerequisite.

The safest approach is to prevent untrusted data from shaping executable code. Concretely, this means ensuring that any metadata embedded in generated Python source is strictly treated as data—using safe quoting (such as repr() or !r), escaping, or non-code-bearing representations—combined with minimizing or eliminating the use of dynamic compilation for parsing tasks.

Design parsing systems so that file contents are never directly incorporated into executable expressions. Adopt a defensive pattern where complex file metadata is processed via well-defined schemas, normalized and validated before use, and kept separate from control logic. Enforce coding standards that restrict dynamic code generation, require security review for any use of exec/eval/compile, and integrate static analysis tools that highlight injection-prone constructs during development.

Find out what's already
exploitable in your codebase.