Skip to main content
Vulnerability Database/CVE-2024-56363

CVE-2024-56363: APTRS Jinja2 Template RCE Vulnerability

CVE-2024-56363 is a remote code execution vulnerability in APTRS 1.0 caused by improper sanitization of user input in Jinja2 templates. Attackers can inject malicious code through CKEditor fields to execute arbitrary Python commands. This article covers technical details, exploitation methods, affected versions, and mitigation strategies.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-56363 Overview

CVE-2024-56363 is a Server-Side Template Injection (SSTI) vulnerability in APTRS (Automated Penetration Testing Reporting System) version 1.0. APTRS is a Python and Django-based automated reporting tool used by penetration testers and security organizations. The flaw resides in the web application's handling of user-supplied input that is incorporated into a Jinja2 template without proper sanitization. Attackers who can submit input through the CKEditor template fields can inject Jinja2 expressions that the server evaluates, leading to arbitrary Python code execution. The weakness is classified as [CWE-97] (Improper Neutralization of Server-Side Includes).

Critical Impact

An authenticated local user can inject Jinja2 syntax into CKEditor-controlled template fields and execute arbitrary Python code on the server hosting APTRS.

Affected Products

  • APTRS (Automated Penetration Testing Reporting System) version 1.0
  • Deployments using CKEditor-driven template fields passed to Jinja2
  • Django-based report generation workflows in APTRS

Discovery Timeline

  • 2024-12-23 - CVE-2024-56363 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2024-56363

Vulnerability Analysis

APTRS renders user-supplied report content through Jinja2 templates during document generation. CKEditor fields accept rich text that is passed directly into template rendering without a sandbox. An attacker with report-editing privileges can embed Jinja2 expressions such as {{ config }} or {{ self.__class__.__mro__[1].__subclasses__() }} to walk the Python object graph. From there, payloads can reach os.system, subprocess.Popen, or __builtins__ to execute shell commands. Because APTRS runs the renderer server-side, exploitation yields code execution in the context of the Django application process.

Root Cause

The root cause is the use of an unsandboxed jinja2.Environment to render untrusted CKEditor input. HTML sanitization alone does not strip Jinja2 delimiters, so template directives survive and are evaluated. The patch replaces the default environment with jinja2.sandbox.SandboxedEnvironment, which blocks access to unsafe attributes and callables.

Attack Vector

Exploitation requires an authenticated local user with permission to edit report fields in APTRS. The attacker submits crafted Jinja2 payloads in any CKEditor-backed field. When the report is rendered, the server evaluates the injected expressions and executes attacker-controlled Python code with the privileges of the APTRS process.

python
# Security patch in APTRS/project/report.py - switch to a sandboxed Jinja2 environment
 from docxtpl import DocxTemplate, RichText
 from django.shortcuts import get_object_or_404
 from datetime import datetime
-import jinja2
+from jinja2.sandbox import SandboxedEnvironment
 import html
 import traceback
# Source: https://github.com/APTRS/APTRS/commit/9f6b6e4a56a9119eb12126a4909441e83b6d7c11

The patch introduces SandboxedEnvironment, which restricts access to Python internals such as __class__, __mro__, and __subclasses__, blocking the standard SSTI escape chain.

Stop Remote Code Execution Before It Runs

Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.

Stop Exploit Attempts

Detection Methods for CVE-2024-56363

Indicators of Compromise

  • CKEditor field content containing Jinja2 delimiters such as {{, }}, {%, or %} paired with Python attribute lookups like __class__, __mro__, or __subclasses__.
  • Unexpected child processes (for example sh, bash, python) spawned by the Django application worker during report generation.
  • Outbound network connections initiated by the APTRS process to attacker-controlled hosts shortly after a report is rendered.
  • Django application logs showing template rendering errors referencing jinja2.exceptions.UndefinedError on report fields.

Detection Strategies

  • Inspect database records for stored CKEditor payloads matching common SSTI patterns before they are rendered.
  • Instrument the report rendering code path to log the raw template context and flag Jinja2 metacharacters in user-supplied fields.
  • Correlate report generation events with process creation telemetry on the host running APTRS.

Monitoring Recommendations

  • Monitor the APTRS service account for anomalous shell, interpreter, or network activity.
  • Alert on file writes outside the expected APTRS working directories by the Django process.
  • Review audit logs for user accounts repeatedly editing report fields with suspicious markup.

How to Mitigate CVE-2024-56363

Immediate Actions Required

  • Upgrade APTRS to a build that includes commit 9f6b6e4a56a9119eb12126a4909441e83b6d7c11, which introduces the sandboxed Jinja2 environment.
  • Restrict access to the APTRS web interface to trusted penetration testers and remove unused accounts.
  • Rotate any secrets, API tokens, or credentials accessible to the APTRS process if exploitation is suspected.

Patch Information

The maintainers addressed CVE-2024-56363 by replacing the default jinja2.Environment with jinja2.sandbox.SandboxedEnvironment in the report rendering code. Review the fix in the GitHub commit details and the GitHub Security Advisory GHSA-h4w2-hvcg-938j.

Workarounds

  • If patching is not immediately possible, sanitize CKEditor input server-side to strip Jinja2 delimiters ({{, }}, {%, %}) before persistence.
  • Run the APTRS Django process under a dedicated, low-privilege operating system account with no shell access.
  • Place APTRS behind network controls that limit access to authenticated internal users only.
bash
# Example: pin to a patched revision when deploying APTRS from source
git clone https://github.com/APTRS/APTRS.git
cd APTRS
git checkout 9f6b6e4a56a9119eb12126a4909441e83b6d7c11
pip install -r requirements.txt
python manage.py migrate

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.