/

CVE-2026-31020

Severity:

CRITICAL RISK

(9.8)

Server-Side Template Injection (CWE-94) in DocsGPT

CVE-2026-31020

Deferred

Vulnerability type

Category:

Server-Side Template Injection

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

DocsGPT's custom prompt feature renders user-controlled prompt content as a Jinja template without sufficient sanitization or sandboxing. An unauthenticated attacker may inject template expressions that execute server-side, potentially resulting in remote code execution and compromise of the application host.

Affected context

The vulnerability occurs in DocsGPT deployments that expose the custom prompt functionality and process user-defined prompt content through a Jinja template engine. Risk is highest when prompt data can be submitted without authentication and is rendered with access to server-side objects, functions, or operating-system capabilities.

Exploit preconditions

  • Attack surface: The application's custom prompt feature and associated chatbot interaction endpoint
  • Required access: No authentication may be required when the affected functionality is publicly accessible
  • Trigger point: Server-side rendering of attacker-controlled prompt content as a Jinja template
  • Why exploitation is possible: Template expressions are evaluated without adequate input isolation, sanitization, or sandbox restrictions

Why this happens

The underlying issue is the treatment of user-controlled prompt text as executable template source rather than inert data. When a template engine evaluates untrusted content with access to a powerful execution context, attacker-supplied expressions may traverse objects or invoke capabilities beyond the intended prompt-rendering behavior. This is consistent with CWE-94: Improper Control of Generation of Code, because externally influenced input can affect server-side code or expression execution.

Potential impact

  • An attacker may execute arbitrary commands on the DocsGPT server
  • The application process could be fully compromised
  • Sensitive files, credentials, or environment data may be exposed
  • The attacker could alter chatbot behavior or stored application data
  • The vulnerable host could be used for lateral movement or further attacks

General mitigation guidance

Mitigation generally focuses on ensuring that user-provided prompt content remains data and cannot become executable template source.

Common defensive patterns include:

  • Rendering untrusted values through fixed, developer-controlled templates
  • Using a restricted template environment with minimal objects, filters, and capabilities
  • Avoiding evaluation of user-supplied template syntax whenever possible
  • Applying strict allowlists and contextual validation to custom prompt fields
  • Separating prompt composition from server-side expression evaluation
  • Running the application with least-privilege operating-system and service permissions
  • Limiting access to secrets, filesystems, subprocess interfaces, and network resources
  • Applying authentication and authorization controls to prompt-management functionality

How teams detect issues like this

Detection approaches can include:

  • Static analysis rules that identify template rendering of request parameters or user-controlled fields
  • Code review checks for dynamic template compilation and unrestricted Jinja environments
  • Tests that submit template metacharacters and verify they remain inert data
  • Runtime monitoring for unexpected template errors, process launches, or outbound connections from the application
  • Policy enforcement preventing untrusted input from reaching template-compilation APIs
  • Automated security review tools that flag server-side template injection patterns

Sources

SourceLink
arc53.comarc53.com
github.comgithub.com/PhDg1410/CVE/tree/main/CVE-2026-31020

Frequently asked

questions

Yes, when the custom prompt functionality is publicly reachable and accepts unauthenticated input, an attacker may be able to trigger the vulnerable server-side rendering path over the network.

The described issue does not require authentication when the affected custom prompt feature is exposed without access controls. Deployment-specific routing and authorization may limit the reachable attack surface.

Treat custom prompt content strictly as data and render it only through fixed, trusted templates. If templating is required, use a tightly restricted environment with no access to dangerous objects or execution capabilities.

Include template-injection checks in code review and automated testing, restrict template APIs by policy, validate untrusted input, and run the application with minimal privileges and limited access to sensitive resources.

Find out what's already
exploitable in your codebase.