CVE-2025-49142
Executive Summary
CVE-2025-49142 is a critical server-side template injection (SSTI) vulnerability in Nautobot, a Network Source of Truth and Network Automation Platform. The flaw resides in the Jinja2 templating feature used in computed fields, custom links, and similar components. Due to insufficient security configuration, a malicious user with appropriate permissions can craft Jinja2 templates that, when rendered, expose the values of Secrets defined in Nautobot or call Python APIs to modify data, bypassing object permissions. This allows for unauthorized data exfiltration and potential data manipulation. The vulnerability affects all Nautobot versions prior to 1.6.32 and 2.4.10. A partial mitigation involves strict object permission controls, but a full patch is required.
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
Supply Chain & Package Security
Nautobot is a Python-based application distributed via PyPI. The vulnerability is inherent in the application's use of Jinja2 templating. Users should ensure they are using the latest patched versions (1.6.32 or 2.4.10) from the official PyPI repository. Verify package integrity via checksums provided by the Nautobot project.
CVSS Breakdown & Threat Level
While the official CVSS score is 0.0 (likely unassigned at time of analysis), based on the vulnerability description, a reasonable CVSS v3.1 vector would be:
CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N (Base Score: 8.1 - High)
- Attack Vector (AV): Network - The vulnerability can be exploited remotely.
- Attack Complexity (AC): Low - No special conditions are required.
- Privileges Required (PR): Low - An attacker needs a valid user account with permissions to configure computed fields or custom links.
- User Interaction (UI): None - No user interaction is required.
- Scope (S): Unchanged - The vulnerable component and the impacted component are the same.
- Confidentiality (C): High - Secrets can be exposed.
- Integrity (I): High - Data can be modified via Python API calls.
- Availability (A): None - The vulnerability does not directly impact availability.
Threat Level: High. The ability to exfiltrate secrets and modify data without proper authorization poses a significant risk to network automation environments.
Deep Dive & Mechanics
The vulnerability is a classic Server-Side Template Injection (SSTI) in Jinja2. Nautobot uses Jinja2 to render dynamic content in computed fields, custom links, and similar features. The template engine is configured with insufficient sandboxing, allowing access to Python objects and functions.
Mechanism:
- Privileged User Action: A user with permission to create or edit computed fields or custom links injects a malicious Jinja2 template.
- Template Rendering: When a user views an object that uses this computed field or custom link, Nautobot renders the template server-side.
- Exploitation: The malicious template can access the Jinja2 environment's built-in functions and Python objects. For example:
- Secret Exposure:
{{ secrets.get("my_secret_key") }}or by iterating through thesecretsobject. - Data Manipulation:
{{ __import__('os').system('nautobot-server shell --command "..."') }}or by calling Nautobot's internal APIs to modify objects.
- Secret Exposure:
- Bypass of Permissions: The template executes in the context of the server, not the viewing user. Therefore, it can access data and perform actions that the viewing user would not normally be authorized to do.
Vulnerable vs. Patched Code
Vulnerable Code (Conceptual):
# In a view or template rendering function
from jinja2 import Environment
env = Environment()
template = env.from_string(user_provided_template)
rendered = template.render(context)
The Environment is created with default settings, which allow access to Python built-ins and objects.
Patched Code (Conceptual):
from jinja2 import Environment, BaseLoader, sandbox
# Use a sandboxed environment
env = Environment(loader=BaseLoader(), undefined=StrictUndefined)
env.globals.clear()
env.filters.clear()
env.tests.clear()
# Or use the SandboxedEnvironment
from jinja2.sandbox import SandboxedEnvironment
env = SandboxedEnvironment()
template = env.from_string(user_provided_template)
rendered = template.render(context)
The patched version uses a SandboxedEnvironment or explicitly clears globals, filters, and tests to prevent access to dangerous functions. Additionally, the secrets object should be explicitly excluded from the template context or made inaccessible.
Exploitation & Lab Setup
Red Team (Attack Simulation)
Prerequisites:
- A Nautobot instance (version < 1.6.32 or < 2.4.10).
- A user account with permissions to create/edit computed fields or custom links.
Steps:
- Login: Authenticate to the Nautobot web interface.
- Navigate: Go to Customization > Computed Fields or Custom Links.
- Create Malicious Template:
- For Secret Exposure, create a computed field with the following Jinja2 template:
{% for secret in secrets.all() %} {{ secret.name }}: {{ secret.value }} {% endfor %} - For Data Manipulation, create a custom link with:
{{ __import__('os').popen('nautobot-server shell --command "from dcim.models import Device; Device.objects.filter(name=\'target_device\').update(status=\'decommissioned\')"').read() }}
- For Secret Exposure, create a computed field with the following Jinja2 template:
- Trigger: View any object (e.g., a device) that has this computed field or custom link assigned.
- Observe: The secrets will be displayed in the computed field, or the data modification will occur.
Note: The exact syntax may vary based on Nautobot's internal structure. Use {{ dir() }} or {{ config }} to explore available objects.
Blue Team (Defense & Detection)
Detection Steps:
- Audit Computed Fields and Custom Links: Regularly review all computed fields and custom links for suspicious Jinja2 syntax, especially those containing
__import__,os.,subprocess, or direct access tosecrets. - Monitor Logs: Look for unusual template rendering errors or access to sensitive objects.
- Honeypot: Create a fake secret with a unique value and monitor for its exposure in logs or network traffic.
Mitigation Steps:
- Patch Immediately: Upgrade to Nautobot 1.6.32 or 2.4.10.
- Restrict Permissions: Limit the ability to create/edit computed fields and custom links to only highly trusted administrators.
- Network Segmentation: Ensure Nautobot is not directly accessible from the internet.
- Web Application Firewall (WAF): Deploy a WAF with rules to detect SSTI payloads (e.g.,
{{,{%,__import__).
Indicators of Compromise (IOCs)
- Log Entries: Template rendering errors containing
jinja2.exceptions.UndefinedErrororjinja2.exceptions.SecurityError(if sandbox is partially enabled). - Network Traffic: Outbound connections from the Nautobot server to unexpected destinations (if the attacker uses
os.popento exfiltrate data). - File System: Unexpected files created in the Nautobot media or temporary directories.
- Database: Unauthorized changes to objects (e.g., device status, IP addresses) that cannot be attributed to legitimate users.
- Secrets Exposure: Secrets appearing in computed field outputs or in HTTP responses where they should not be.
Detection Engineering
YARA Rule
rule CVE_2025_49142_Jinja2_SSTI {
meta:
description = "Detects malicious Jinja2 templates targeting Nautobot CVE-2025-49142"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-49142"
strings:
$ssti1 = /{{.*__import__.*}}/
$ssti2 = /{{.*os\..*}}/
$ssti3 = /{{.*subprocess.*}}/
$ssti4 = /{{.*secrets\..*}}/
$ssti5 = /{%\s*for.*secrets.*%}/
condition:
any of them
}
Sigma Rule
title: Nautobot Jinja2 SSTI Exploitation Attempt
id: 8a4b3c2d-1e5f-6a7b-8c9d-0e1f2a3b4c5d
status: experimental
description: Detects attempts to exploit CVE-2025-49142 via malicious Jinja2 templates in Nautobot logs.
author: Valters IT
date: 2025-04-10
logsource:
category: application
product: nautobot
detection:
selection:
EventID: 1000 # Example: Nautobot template rendering event
Message|contains:
- '__import__'
- 'os.popen'
- 'secrets.all'
- 'subprocess'
condition: selection
falsepositives:
- Legitimate use of Jinja2 filters that may contain similar strings (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"Nautobot CVE-2025-49142 SSTI Payload in Request"; flow:to_server,established; content:"POST"; http_method; content:"/api/"; http_uri; pcre:"/{{.*(?:__import__|os\.|subprocess|secrets\.).*}}/"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Patch: Upgrade to Nautobot version 1.6.32 or 2.4.10 immediately.
- Restrict Access: If patching is not possible, revoke permissions for creating/editing computed fields and custom links from all non-administrative users.
- Audit: Review all existing computed fields and custom links for malicious content. Remove any suspicious entries.
Long-Term Measures:
- Principle of Least Privilege: Ensure that only necessary users have permissions to modify templating features.
- Input Validation: Implement strict validation and sanitization of Jinja2 templates before rendering.
- Sandboxing: Use a properly configured
SandboxedEnvironmentin Jinja2 to restrict access to dangerous functions. - Monitoring: Continuously monitor logs for template rendering anomalies.
- Security Training: Educate administrators about the risks of SSTI and secure coding practices.
Valters IT
Securing Your Digital Infrastructure