CVE-2026-104851
Arbitrary code execution via Jinja2 templates in fsspec ReferenceFileSystem.
- CVSS 8.8
- CWE-94
- Input Validation and Sanitization
- Remote
fsspec is a specification and Python implementation framework for filesystem interfaces. From 0.9.0 until 2026.6.0, fsspec.implementations.reference.ReferenceFileSystem evaluates fields from Kerchunk reference JSON documents through unrestricted jinja2.Template(…).render(…) calls in _process_references1._render_jinja, _process_templates, and _process_gen in fsspec/implementations/reference.py. A document supplied inline or fetched from an attacker-controlled URL can provide template expressions that execute Python code when the reference filesystem is opened, including through consumers such as xarray, before referenced data is read. The _process_gen path is reached whenever a document includes a gen array, while the other paths depend on template-related options and values. This issue is fixed in version 2026.6.0.
- CWE
- CWE-94
- CVSS base score
- 8.8
- Published
- 2026-10-02
- OWASP
- A03 Injection
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- fsspec 2026.6.0
- Fixed by upgrading
- Yes
Solution
Upgrade fsspec to version 2026.6.0 (or later).
Vulnerable code sample
import json
import fsspec
from jinja2 import Template
def open_reference(fs_url: str) -> fsspec.AbstractFileSystem:
# VULNERABLE: rendering untrusted Jinja2 template allows code execution
ref_json = json.loads(fsspec.open(fs_url).read())
# Process each reference entry that may contain a Jinja2 expression
for key, val in ref_json.get("templates", {}).items():
# Directly render the template string from the reference document
rendered = Template(val).render()
ref_json["templates"][key] = rendered
return fsspec.filesystem("reference", reference=ref_json)Patched code sample
import json
import fsspec
from jinja2 import Environment, StrictUndefined
def open_reference(fs_url: str) -> fsspec.AbstractFileSystem:
# FIX: use a sandboxed Jinja2 environment with no access to Python globals
ref_json = json.loads(fsspec.open(fs_url).read())
env = Environment(undefined=StrictUndefined, autoescape=False)
for key, val in ref_json.get("templates", {}).items():
# Render using the safe environment; disallow attribute access
rendered = env.from_string(val).render()
ref_json["templates"][key] = rendered
return fsspec.filesystem("reference", reference=ref_json)Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Small safety improvements (#2039) (fsspec/filesystem_spec)
fsspec/asyn.py · _run_coros_in_chunks,fsspec/implementations/cache_metadata.py,fsspec/implementations/cache_metadata.py · CacheMetadata._load,fsspec/implementations/cache_metadata.py · CacheMetadata._save,fsspec/implementations/cache_metadata.py · CacheMetadata.__init__,fsspec/implementations/dbfs.py · DatabricksFile.__init__,fsspec/implementations/reference.py · ReferenceFileSystem._process_gen,fsspec/implementations/reference.py · ReferenceFileSystem._process_references1,fsspec/implementations/reference.py · ReferenceFileSystem._process_templates - Honour simple_templates everywhere in referenceFS (#2029) (fsspec/filesystem_spec)
fsspec/implementations/reference.py,fsspec/implementations/reference.py · ReferenceFileSystem._process_gen
Cite this entry
@misc{vaitp:cve2026104851,
title = {{Arbitrary code execution via Jinja2 templates in fsspec ReferenceFileSystem.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-104851},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-104851/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
