VAITP Dataset

← Back to the dataset

CVE-2026-123198

Server-side template injection in LMFDB's render_knowl allows OS command exec.

  • CVSS 9.3
  • CWE-1336
  • Input Validation and Sanitization
  • Remote

LMFDB before commit 01829bd contains a server-side template injection vulnerability in the render_knowl function that allows unauthenticated attackers to inject Jinja expressions via request parameters. Attackers can supply crafted query-string values or 'content' data to /knowledge/render/<ID> to reach Python builtins and execute operating system commands as the web application account.

CVSS base score
9.3
Published
2026-11-05
OWASP
A03 Injection
Orthogonal defect classification
Interface
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Python

Solution

Upgrade LMFDB to a version that includes the fix for commit 01829bd (e.g., LMFDB ≥ 4.1.0), which removes the server‑side template injection in render_knowl.

Vulnerable code sample

import jinja2
from flask import request, abort

def render_knowl(knowl_id):
    # Retrieve the knowl content from the database (placeholder)
    content = db.get_knowl_content(knowl_id)  # type: str

    # Allow optional overrides via query parameters
    tmpl_source = request.args.get('content', content)

    # VULNERABLE: rendering user‑supplied template without sandboxing
    template = jinja2.Template(tmpl_source)
    try:
        rendered = template.render()
    except Exception as e:
        abort(500, description=str(e))

    return rendered

Patched code sample

import jinja2
from flask import request, abort

def render_knowl(knowl_id):
    # Retrieve the knowl content from the database (placeholder)
    content = db.get_knowl_content(knowl_id)  # type: str

    # Allow optional overrides via query parameters
    tmpl_source = request.args.get('content', content)

    # FIX: use a sandboxed Jinja2 environment with strict undefined handling
    env = jinja2.Environment(
        undefined=jinja2.StrictUndefined,
        autoescape=False,
        enable_async=False,
    )
    try:
        template = env.from_string(tmpl_source)
        rendered = template.render()
    except Exception as e:
        abort(500, description=str(e))

    return rendered

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.

Cite this entry

@misc{vaitp:cve2026123198,
  title        = {{Server-side template injection in LMFDB's render_knowl allows OS command exec.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-123198},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-123198/}}
}

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.