GHSA-cpwx-vrp4-4pq7: Pip/jinja2 vulnerability
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.
Jinja's sandbox does catch calls to str.format and ensures they don't escape the sandbox. However, it's possible to use the |attr filter to get a reference to a string's plain format method, bypassing the sandbox. After the fix, the |attr filter no longer bypasses the environment's attribute lookup.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/Jinja2to a version that resolves this vulnerability.Fixed in 3.1.6
Event History
Frequently Asked Questions
What is the severity of GHSA-cpwx-vrp4-4pq7?
GHSA-cpwx-vrp4-4pq7 is classified as a high severity vulnerability due to its ability to allow arbitrary code execution.
How do I fix GHSA-cpwx-vrp4-4pq7?
To fix GHSA-cpwx-vrp4-4pq7, upgrade Jinja2 to version 3.1.6 or later.
What causes GHSA-cpwx-vrp4-4pq7?
GHSA-cpwx-vrp4-4pq7 is caused by an oversight in how the Jinja sandboxed environment interacts with the |attr filter.
Who is affected by GHSA-cpwx-vrp4-4pq7?
GHSA-cpwx-vrp4-4pq7 affects users of Jinja2 versions up to and including 3.1.5.
Can GHSA-cpwx-vrp4-4pq7 be exploited remotely?
Yes, GHSA-cpwx-vrp4-4pq7 can be exploited remotely if an attacker can control the content of a template.