CVE-2023-25657
Executive Summary
CVE-2023-25657 is a remote code execution (RCE) vulnerability affecting Nautobot, a Network Source of Truth and Network Automation Platform. All users running Nautobot versions prior to 1.5.7 are impacted by insufficient sandboxing of the Jinja2 template rendering engine used internally for various object types. Successful exploitation could allow an attacker with access to template creation or modification capabilities to execute arbitrary code on the underlying server, potentially leading to full system compromise. Nautobot 1.5.7 addresses this by enforcing the use of Jinja2's SandboxedEnvironment for all template rendering operations.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Technical Analysis
The vulnerability stems from Nautobot's failure to properly sandbox Jinja2 template rendering. Jinja2 is a widely used Python templating engine that, by default, operates in an unrestricted environment where template code can access Python objects and methods. When user-supplied or indirectly controlled template content is rendered without sandboxing, an attacker can craft template expressions that invoke dangerous Python functions or access restricted attributes to achieve code execution.
Specifically, Nautobot used the standard jinja2.Template class directly in various internal operations. The affected objects include extras.ComputedField, extras.CustomLink, extras.ExportTemplate, extras.Secret, and extras.Webhook. These objects accept template code as part of their configuration, and when rendered by the system's internal template engine, unsandboxed Jinja2 could interpret malicious expressions with full Python access.
The core issue is that Jinja2 templates, when rendered with a standard Environment object, allow access to Python's built-in functions and object introspection mechanisms. Techniques such as __class__, __mro__, __subclasses__, or similar attribute traversal chains can be leveraged to reach dangerous modules such as os or subprocess, enabling arbitrary command execution.
The fix in Nautobot 1.5.7 modifies the template engine to use a SandboxedEnvironment, which restricts access to unsafe attributes and methods at the language level. This change is applied globally through the helper function nautobot.utilities.utils.render_jinja2, ensuring that all internal template rendering — regardless of the originating object type — is sandboxed. For installations unable to upgrade immediately, Nautobot provides a configuration-level workaround:
TEMPLATES[1]["OPTIONS"]["environment"] = "jinja2.sandbox.SandboxedEnvironment"
This setting must be added to nautobot_config.py followed by a restart of all Nautobot services. Note that while the sandbox provides significant protection, the exact attack surface is limited to users who can create or modify the affected object types (ComputedField, CustomLink, ExportTemplate, Secret, Webhook), which typically requires authenticated access with appropriate permissions.
The NVD description notes that "no active exploits of this vulnerability are known" and that the change was made as a "preventative measure to protect against any potential remote code execution attacks utilizing maliciously crafted template code." This indicates the vulnerability was discovered through code audit rather than observed exploitation, but the severity rating of 7.5 (High) reflects the criticality of the potential impact if exploited.
Exploitation Scenarios
Attack Chain:
Reconnaissance/Target Identification: An attacker must first gain access to a Nautobot instance (version < 1.5.7) — typically a network appliance management portal exposed to internal or potentially external networks. Shodan search queries such as
http.title:"Nautobot"can identify exposed instances. The attacker would also need valid credentials or the ability to reach an endpoint that allows template creation or modification.Flaw Trigger: The attacker authenticates to the Nautobot web interface and navigates to one of the vulnerable object types —
extras.ComputedField,extras.CustomLink,extras.ExportTemplate,extras.Secret, orextras.Webhook. The attacker creates a new object or modifies an existing one, injecting malicious Jinja2 template code into the template field.Payload Execution at Vulnerability-Class Level: A classic Jinja2 SSTI (Server-Side Template Injection) payload attempts to escape the template context and access Python internals. At the class level, this involves:
- Accessing the
__class__attribute of a template object to obtain its Python class - Traversing
__mro__(method resolution order) to reach the root object - Using
__subclasses__()to enumerate loaded classes within the Python interpreter - Locating a class that provides access to system functions (e.g., subprocess module classes) and invoking them with attacker-controlled arguments
Since no public PoC is available and specific implementation details are not disclosed in the NVD description, the exact chain is inferred from the Jinja2 SSTI vulnerability class. The result is arbitrary command execution on the Nautobot server with the privileges of the web application process.
- Accessing the
Post-Exploitation Impact: Successful exploitation grants the attacker code execution on the Nautobot server. Given that Nautobot is a "Network Source of Truth" storing device configurations, credentials, and network topology data, the attacker would gain access to sensitive network infrastructure information. Further post-exploitation could involve lateral movement to managed network devices, credential harvesting from stored secrets, or pivoting to other systems within the network perimeter.
Limiting Factors: The attack requires authenticated access with permissions to create or modify the affected object types. The NVD description does not specify whether unauthenticated access can reach any of these template-rendering functions, so conservative assessment assumes authentication is required. No public exploit code is currently available.
Impact Assessment
CVSS Score: 7.5 (High) — Reflecting the network attack vector, low attack complexity, and high confidentiality/integrity/availability impact. The UI:R component suggests some user interaction or a specific user context is required.
Business Impact:
- Confidentiality: Complete loss — attacker can exfiltrate network device configurations, stored credentials, secrets, and platform data
- Integrity: Complete loss — attacker can modify templates, device records, and potentially inject persistent backdoors
- Availability: Complete loss — attacker can disrupt platform operations or destroy data within the application context
Affected Systems: All Nautobot deployments running versions earlier than 1.5.7. This includes production network automation platforms that are central to IT operations.
Blast Radius: Given Nautobot's role as a Network Source of Truth, the blast radius extends beyond the platform itself. Compromise of the platform could lead to:
- Exposure of network credentials stored in
extras.Secretobjects - Manipulation of network device configurations through
extras.ExportTemplateandextras.Webhookobjects (which may trigger configuration pushes) - Lateral movement into network infrastructure management systems
- Operational disruption of network automation workflows
EPSS Context: The EPSS score of 0.01526 (72.3rd percentile) indicates low immediate exploitation likelihood, consistent with the absence of known active exploitation. However, the high severity and the platform's critical role in network operations warrant proactive patching.
Detection Guidance
Sigma Rule
title: Nautobot Jinja2 Template Injection Exploitation Attempt
id: 4f8c8b2a-6d3e-4a9f-8c2b-1e5d7a9b3c4d
status: experimental
description: Detects suspicious Jinja2 template syntax in Nautobot object creation/modification requests targeting ComputedField, CustomLink, ExportTemplate, Secret, or Webhook endpoints
references:
- https://nvd.nist.gov/vuln/detail/CVE-2023-25657
author: Valtersit Threat Intelligence
date: 2024/01/15
tags:
- attack.t1203
- cve.2023-25657
logsource:
category: web
product: nautobot
detection:
selection_template_patterns:
- request.body|contains:
- '__class__'
- '__mro__'
- '__subclasses__'
- 'os.system'
- 'os.popen'
- 'subprocess.Popen'
- '{{'
- '{%'
selection_endpoints:
- request.uri|contains:
- '/api/extras/computed-fields/'
- '/api/extras/custom-links/'
- '/api/extras/export-templates/'
- '/api/extras/secrets/'
- '/api/extras/webhooks/'
condition: selection_template_patterns and selection_endpoints
level: high
falsepositives:
- Legitimate use of Jinja2 template syntax in authorized configurations
- Development environments with intentional template customization
YARA Rule
rule CVE_2023_25657_Nautobot_Jinja2_SSTI
{
meta:
author = "Valtersit Threat Intelligence"
description = "Detects Jinja2 Server-Side Template Injection payloads targeting Nautobot"
reference = "https://nvd.nist.gov/vuln/detail/CVE-2023-25657"
date = "2024-01-15"
cve = "CVE-2023-25657"
score = 60
strings:
// Jinja2 injection primitives
$s1 = "__class__.__mro__" ascii wide
$s2 = "__subclasses__()" ascii wide
$s3 = "{{" ascii wide
$s4 = "{%" ascii wide
// Python code execution attempts
$s5 = "os.popen" ascii wide
$s6 = "os.system" ascii wide
$s7 = "subprocess" ascii wide
$s8 = "__import__" ascii wide
// Nautobot object context markers
$s9 = "ComputedField" ascii wide
$s10 = "ExportTemplate" ascii wide
$s11 = "CustomLink" ascii wide
$s12 = "Webhook" ascii wide
condition:
(any of ($s1, $s2, $s3, $s4) and any of ($s5, $s6, $s7, $s8)) or
(any of ($s1, $s2, $s3, $s4) and any of ($s9, $s10, $s11, $s12))
}
Suricata IDS Rule
alert http any any -> any any (msg:"CVE-2023-25657 Nautobot Jinja2 SSTI Exploitation Attempt"; flow:established,to_server; content:"POST"; http_method; content:"/api/extras/"; http_uri; nocase; pcre:"/(computed-fields|custom-links|export-templates|secrets|webhooks)\//i"; content:"__class__"; http_client_body; nocase; content:"__mro__"; http_client_body; nocase; content:"__subclasses__"; http_client_body; nocase; reference:cve,2023-25657; reference:url,https://nvd.nist.gov/vuln/detail/CVE-2023-25657; classtype:attempted-admin; sid:202325657; rev:1;)
Elastic Detection
sequence by source.ip with maxspan=5m
[http where http.request.method == "POST" and
startsWith(http.request.uri, "/api/extras/") and
(contains(http.request.uri, "computed-fields") or
contains(http.request.uri, "custom-links") or
contains(http.request.uri, "export-templates") or
contains(http.request.uri, "secrets") or
contains(http.request.uri, "webhooks")) and
(stringContains(http.request.body.content, "__class__") or
stringContains(http.request.body.content, "__mro__") or
stringContains(http.request.body.content, "__subclasses__") or
stringContains(http.request.body.content, "os.popen") or
stringContains(http.request.body.content, "os.system") or
stringContains(http.request.body.content, "subprocess"))]
[process where event.type == "start" and
(process.name in ("bash", "sh", "python", "python3") or
process.command_line contains "curl" or
process.command_line contains "wget")]
Splunk SPL Query
index=security sourcetype=nautobot:audit OR sourcetype=*http*
| where match(uri, "(?i)/api/extras/(computed-fields|custom-links|export-templates|secrets|webhooks)/")
| search (body="*__class__*" OR body="*__mro__*" OR body="*__subclasses__*" OR body="*os.popen*" OR body="*os.system*" OR body="*subprocess*")
| eval threat_severity = "high"
| eval cve_id = "CVE-2023-25657"
| table _time, src_ip, user, uri, body, threat_severity, cve_id
| sort -_time
Wazuh OSSEC Rule
<group name="nautobot,rce,">
<rule id="100257" level="15">
<if_sid>100255</if_sid>
<regex>(__class__|__mro__|__subclasses__|os\.popen|os\.system|subprocess\.Popen)</regex>
<description>CVE-2023-25657: Nautobot Jinja2 template injection exploitation attempt detected</description>
<group>attacker,t1203,rce,</group>
<options>no_full_log</options>
</rule>
</group>
Mitigation & Patch Guidance
Patch Confidence: 2/4 — CLAIMED (single source claims patch, not independently confirmed).
Immediate Mitigations (if unable to upgrade):
- Add the following setting to
nautobot_config.pyto enforce sandboxed Jinja2 environments:TEMPLATES[1]["OPTIONS"]["environment"] = "jinja2.sandbox.SandboxedEnvironment" - Restart all Nautobot services after applying the configuration change.
- Audit existing
extras.ComputedField,extras.CustomLink,extras.ExportTemplate,extras.Secret, andextras.Webhookobjects for suspicious or unknown template code. - Review user permissions and remove template-creation privileges from accounts that do not require them.
- Restrict network access to Nautobot web interfaces to trusted networks/users.
Patch/Upgrade Steps:
- Upgrade to Nautobot 1.5.7 or newer immediately. This is the definitive fix.
- After upgrade, verify that all template rendering now uses the
SandboxedEnvironmentby reviewing system logs or performing a regression test on template rendering. - Confirm the upstream CNA patch is legitimate and monitor Nautobot's official channels for any subsequent security advisories.
Long-Term Hardening:
- Implement least-privilege access control for all Nautobot objects, especially those involving template execution.
- Conduct regular security audits of template content across all Nautobot objects.
- Monitor CISA KEV and vendor advisories for any updates regarding active exploitation.
- Deploy network segmentation to isolate Nautobot from general user networks and the internet.
- Enable comprehensive audit logging for all template-rendering operations and review logs for anomalous patterns.
- Maintain an up-to-date inventory of all Nautobot deployments and their versions to facilitate rapid patching.
References
- NVD Entry: https://nvd.nist.gov/vuln/detail/CVE-2023-25657
- Nautobot Official Documentation — Security Advisory (referenced via CNA disclosure)
- Nautobot Release Notes (v1.5.7) — https://docs.nautobot.com/projects/core/en/stable/release-notes/
- OWASP Server-Side Template Injection Guide — https://owasp.org/www-community/attacks/Server_Side_Template_Injection
- CISA Known Exploited Vulnerabilities Catalog — https://www.cisa.gov/known-exploited-vulnerabilities-catalog (CVE-2023-25657 not currently listed)
Exploit-in-the-Wild Evidence: Per the NVD description, "no active exploits of this vulnerability are known." CISA KEV does not list this CVE. No public exploit code or PoC is confirmed available at the time of this report. The patch confidence is 2/4, indicating the fix is claimed by a single source (the CNA) without independent verification.
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.