-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Execute arbitrary codes in template without sandbox environment. #549
Comments
You should not execute untrusted templates in a non-sandboxed environment. That's exactly why the sandbox exists (and to be honest, even with a sandbox I would not let users provide arbitrary Jinja templates) |
So, is it necessary to take measures to prevent this case? I think there some specific application would allow users to edit the template content, but there is no practical examples. |
I think it is necessary to use sandbox by defualt, because flask or another web framework used Jinja2 is not do this. |
Why would you want to use the sandbox by default? In most cases templates cannot be changed by untrusted people who don't have access to the code anyway. |
There is a case about remote code execution via Flask/Jinja2 template injection in Uber. |
Enabling sandboxing by default is not possible due to backwards compat, and also not reasonable because most templates (in Flask) are trusted. |
When i use Jinja2 template framework in my project, i found a way to call "os.popen('id')" or another functions without global register.
It's easy to get shell when attacker can control the template content. Is that such a design?
PoC:
I test this code with python2 (2.7.10) and Jinja2 (2.8), if it works will print your user's uid...
The text was updated successfully, but these errors were encountered: