Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command injection in from_string function (SSTI) #947

Closed
mostafa opened this issue Feb 18, 2019 · 1 comment
Closed

Command injection in from_string function (SSTI) #947

mostafa opened this issue Feb 18, 2019 · 1 comment

Comments

@mostafa
Copy link

mostafa commented Feb 18, 2019

Expected Behavior

The from_string accepts parameters that are not escaped, so an attacker can inject code into the template.

Actual Behavior

Should escape anything passed.

Extra Information and Proof of Concept

https://github.com/JameelNabbo/Jinja2-Code-execution
https://www.exploit-db.com/exploits/46386

@mostafa mostafa changed the title Jinja2 Command injection from_string function (SSTI) Command injection in from_string function (SSTI) Feb 18, 2019
@davidism
Copy link
Member

davidism commented Feb 18, 2019

The user who created that repo and CVE doesn't know what they're talking about, and unfortunately now we're going to have to keep addressing it since they irresponsibly notified a bunch of people about a non-issue in an official sounding way. See https://github.com/JameelNabbo/Jinja2-Code-execution/issues/1 for a response to them. I've sent in a request to MITRE to have the CVE invalidated.

Saying Jinja has a vulnerability because from_string exists is like saying every dynamic language is vulnerable because eval exists, or every SQL library is vulnerable because they evaluate SQL strings. The issue isn't with those libraries, which all provide proper tools for handling user input. A SQL library doesn't have an injection vulnerability, a project using a SQL library improperly does.

SandboxedEnvironment should be used if you still want to risk compiling untrusted templates, and autoescape should be used when rendering untrusted variables.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants