Summary
CVE-2026-31020 is a critical Server-Side Template Injection (SSTI) vulnerability in DocsGPT, an open-source AI-powered document chat/agent platform. The custom prompt feature renders user-supplied prompt content using Jinja templates without sanitization or sandboxing, allowing an unauthenticated attacker to inject malicious Jinja expressions and achieve full remote code execution on the server. The flaw carries a CVSS v3.1 base score of 9.8 (Critical).
Technical details
- Root cause: DocsGPT’s custom prompt functionality passes user-supplied prompt text directly into a Jinja template rendering engine without input sanitization or use of a sandboxed template environment.
- Trigger conditions: An attacker submits a crafted custom prompt containing Jinja template syntax/expressions (e.g., accessing Python object internals) through the exposed prompt configuration feature.
- Attack vector: Network-based, requires no authentication and no user interaction (AV:N, PR:N, UI:N).
- Impact: Successful exploitation allows arbitrary code execution on the underlying server, giving the attacker full compromise of confidentiality, integrity, and availability of the application and host — including potential access to stored documents, API keys/credentials, and connected backend systems.
- Classification: CWE-94 (Improper Control of Generation of Code / Code Injection).
Affected software
- DocsGPT versions 0.15.0 and earlier (custom prompt / Jinja templating feature).
Severity
- CVSS v3.1 Base Score: 9.8 (Critical)
- Vector:
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Mitigation and recommended actions
- Immediate: Upgrade DocsGPT to the latest available release, and verify that the version in use no longer renders user-supplied custom prompt content through an unsandboxed Jinja
Environment. At the time of writing, no vendor security advisory or dedicated patched version number has been publicly confirmed for this specific CVE — organizations should track the official DocsGPT repository and release notes for a fix addressing this issue and apply it as soon as it is available. - If no patch is available:
- Disable or restrict access to the custom prompt configuration feature until a fix is confirmed and applied.
- Do not expose DocsGPT instances (especially the prompt/admin configuration endpoints) directly to the public internet; restrict access via VPN, IP allow-listing, or authentication at a reverse proxy/gateway layer.
- Deploy the application with least-privilege service account permissions and run it in an isolated/sandboxed environment (e.g., container with restricted filesystem/network access) to limit the impact of code execution if exploited.
- Monitor logs for anomalous prompt content containing template syntax (e.g.,
{{,{%, references to Python builtins/class internals) as an indicator of exploitation attempts.

