VAITP Dataset

← Back to the dataset

CVE-2026-119717

Code injection via unescaped bracketed path segments in Handlebars templates.

  • CVSS 9.2
  • CWE-94
  • Input Validation and Sanitization
  • Remote

pybars4 through 0.9.13 contains a code injection vulnerability in pybars/_compiler.py that allows attackers to execute Python code via unescaped bracketed path segments in Handlebars templates. Attackers can supply a template with a crafted segment in a helper or block argument to break out of the generated resolve() string literal and execute code in the application process.

CVSS base score
9.2
Published
2026-10-30
OWASP
A03 Injection
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
pybars4
Fixed by upgrading
Yes

Solution

Upgrade pybars4 to ≥ 0.9.14, which patches the code‑injection flaw in pybars/_compiler.py.

Vulnerable code sample

import re

def compile_template(template_str, path_segment):
    # VULNERABLE: unescaped insertion allows code injection
    resolve_code = f"def resolve(context):\n    return context['{path_segment}']"
    exec_locals = {}
    exec(resolve_code, {}, exec_locals)
    return exec_locals['resolve']

Patched code sample

import re

def compile_template(template_str, path_segment):
    # FIX: escape segment with repr to prevent injection
    escaped_segment = repr(path_segment)[1:-1]  # strip surrounding quotes
    resolve_code = f"def resolve(context):\n    return context['{escaped_segment}']"
    exec_locals = {}
    exec(resolve_code, {}, exec_locals)
    return exec_locals['resolve']

Cite this entry

@misc{vaitp:cve2026119717,
  title        = {{Code injection via unescaped bracketed path segments in Handlebars templates.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-119717},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-119717/}}
}

Download this entry as JSON Download the whole dataset

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 ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.