CVE-2026-35477
Arbitrary Code Execution via Template Injection in InvenTree
Publication date: 2026-04-08
Last updated on: 2026-04-20
Assigner: GitHub, Inc.
Description
Description
CVSS Scores
EPSS Scores
| Probability: | |
| Percentile: |
Meta Information
Affected Vendors & Products
| Vendor | Product | Version / Range |
|---|---|---|
| inventree_project | inventree | From 1.2.3 (inc) to 1.2.6 (inc) |
Helpful Resources
Exploitability
| CWE ID | Description |
|---|---|
| CWE-1336 | 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. |
Attack-Flow Graph
AI Powered Q&A
Can you explain this vulnerability to me?
CVE-2026-35477 is a Server-Side Template Injection (SSTI) vulnerability in the PART_NAME_FORMAT feature of InvenTree versions 1.2.3 to 1.2.6.
Although the PART_NAME_FORMAT validator was updated to use Jinja2's sandboxed environment to prevent code injection, the actual template renderer still used the non-sandboxed environment. This mismatch allows a staff user with settings access to create a template that passes validation but executes arbitrary code during rendering.
Additionally, the validator uses a dummy Part instance with pk=None, causing conditional template expressions to behave differently during validation versus production rendering, which enables bypassing validation checks.
This vulnerability requires high privileges (staff user with settings access) but no user interaction.
How can this vulnerability impact me? :
This vulnerability allows a privileged staff user to execute arbitrary code on the server during template rendering.
The impact includes potential unauthorized code execution leading to confidentiality and integrity breaches, although availability is not affected.
Because the attack requires staff-level access, the risk is limited to users with elevated permissions, but the attack complexity is low and the attack vector is network-based.
How can this vulnerability be detected on my network or system? Can you suggest some commands?
This vulnerability involves a Server-Side Template Injection (SSTI) in the PART_NAME_FORMAT feature of InvenTree versions 1.2.3 to 1.2.6, exploitable by a staff user with settings access. Detection would focus on identifying if the vulnerable versions are in use and monitoring for suspicious template modifications by privileged users.
To detect the vulnerability on your system, first verify the InvenTree version running on your servers. You can check the version by running a command such as:
- grep -i version /path/to/inventree/version/file or check the application UI for version info.
Additionally, you can audit the PART_NAME_FORMAT setting for suspicious or unexpected template strings that might exploit the SSTI. For example, querying the database or configuration files for the PART_NAME_FORMAT value could be done with commands like:
- sqlite3 /path/to/inventree/db.sqlite3 "SELECT value FROM settings WHERE key='PART_NAME_FORMAT';"
Monitoring logs for template rendering errors or unusual activity by staff users with settings access may also help detect exploitation attempts.
How does this vulnerability affect compliance with common standards and regulations (like GDPR, HIPAA)?:
This vulnerability allows a staff user with settings access to execute arbitrary code via crafted templates, potentially leading to unauthorized access or modification of sensitive data.
Such unauthorized code execution and potential data manipulation could impact compliance with standards and regulations like GDPR and HIPAA, which require protection of data confidentiality and integrity.
However, the vulnerability requires high privileges (staff user with settings access), limiting the risk to authorized users only.
What immediate steps should I take to mitigate this vulnerability?
To mitigate this vulnerability immediately, you should upgrade InvenTree to version 1.2.7 or later, where the issue is fixed by updating the template renderer to use the sandboxed environment and modifying the dummy Part instance to prevent bypasses.
If upgrading is not immediately possible, as a workaround, system administrators can override the PART_NAME_FORMAT setting at the system level to a default safe value, which prevents staff users from editing this setting via the client interface and thus blocks exploitation.
Additionally, restrict staff user permissions to limit access to settings where possible, and monitor for any suspicious template changes.