Jinja is an extensible templating engine. Prior to 3.1.6, an oversight in how the Jinja sandboxed environment interacts with the |attr filter allows an attacker that controls the content of a template to execute arbitrary Python code. To exploit the vulnerability, an attacker needs to control the content of a template. Whether that is the case depends on the type of application using Jinja. This vulnerability impacts users of applications which execute untrusted templates. Jinjas sandbox does catch calls to str.format and ensures they dont escape the sandbox. However, its possible to use the |attr filter to get a reference to a strings plain format method, bypassing the sandbox. After the fix, the |attr filter no longer bypasses the environments attribute lookup. This vulnerability is fixed in 3.1.6.
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.
Name | Vendor | Start Version | End Version |
---|---|---|---|
Ansible Automation Platform Execution Environments | RedHat | ansible-automation-platform/ee-minimal-rhel8:2.16.14-11 | * |
Ansible Automation Platform Execution Environments | RedHat | ansible-automation-platform/ee-minimal-rhel9:2.16.14-12 | * |
Red Hat Ansible Automation Platform 2.4 for RHEL 8 | RedHat | automation-controller-0:4.5.20-1.el8ap | * |
Red Hat Ansible Automation Platform 2.4 for RHEL 8 | RedHat | python3x-jinja2-0:3.1.6-1.el8ap | * |
Red Hat Ansible Automation Platform 2.4 for RHEL 8 | RedHat | ansible-automation-platform-24/lightspeed-rhel8:2.4.250225-5 | * |
Red Hat Ansible Automation Platform 2.4 for RHEL 9 | RedHat | automation-controller-0:4.5.20-1.el9ap | * |
Red Hat Ansible Automation Platform 2.4 for RHEL 9 | RedHat | python-jinja2-0:3.1.6-1.el9ap | * |
Red Hat Ansible Automation Platform 2.5 for RHEL 8 | RedHat | automation-controller-0:4.6.10-1.el8ap | * |
Red Hat Ansible Automation Platform 2.5 for RHEL 8 | RedHat | python3.11-jinja2-0:3.1.6-1.el8ap | * |
Red Hat Ansible Automation Platform 2.5 for RHEL 8 | RedHat | ansible-automation-platform-25/lightspeed-rhel8:2.5.250318-2 | * |
Red Hat Ansible Automation Platform 2.5 for RHEL 9 | RedHat | automation-controller-0:4.6.10-1.el9ap | * |
Red Hat Ansible Automation Platform 2.5 for RHEL 9 | RedHat | python3.11-jinja2-0:3.1.6-1.el9ap | * |
Red Hat Enterprise Linux 9 | RedHat | fence-agents-0:4.10.0-76.el9_5.6 | * |
Red Hat Enterprise Linux 9.0 Update Services for SAP Solutions | RedHat | fence-agents-0:4.10.0-20.el9_0.21 | * |
Red Hat Enterprise Linux 9.2 Extended Update Support | RedHat | fence-agents-0:4.10.0-43.el9_2.12 | * |
Red Hat Enterprise Linux 9.4 Extended Update Support | RedHat | fence-agents-0:4.10.0-62.el9_4.11 | * |
Red Hat OpenStack Platform 17.1 for RHEL 9 | RedHat | openstack-ansible-core-0:2.14.2-4.7.el9ost | * |
Jinja2 | Ubuntu | devel | * |
Jinja2 | Ubuntu | esm-infra-legacy/trusty | * |
Jinja2 | Ubuntu | esm-infra/bionic | * |
Jinja2 | Ubuntu | esm-infra/xenial | * |
Jinja2 | Ubuntu | focal | * |
Jinja2 | Ubuntu | jammy | * |
Jinja2 | Ubuntu | noble | * |
Jinja2 | Ubuntu | oracular | * |
Jinja2 | Ubuntu | upstream | * |
Many web applications use template engines that allow developers to insert externally-influenced values into free text or messages in order to generate a full web page, document, message, etc. Such engines include Twig, Jinja2, Pug, Java Server Pages, FreeMarker, Velocity, ColdFusion, Smarty, and many others - including PHP itself. Some CMS (Content Management Systems) also use templates. Template engines often have their own custom command or expression language. If an attacker can influence input into a template before it is processed, then the attacker can invoke arbitrary expressions, i.e. perform injection attacks. For example, in some template languages, an attacker could inject the expression “{{7*7}}” and determine if the output returns “49” instead. The syntax varies depending on the language. In some cases, XSS-style attacks can work, which can obscure the root cause if the developer does not closely investigate the root cause of the error. Template engines can be used on the server or client, so both “sides” could be affected by injection. The mechanisms of attack or the affected technologies might be different, but the mistake is fundamentally the same.