Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ jh
cdsav
kjhbvljhv
wfewqfd
acfdW
22 changes: 22 additions & 0 deletions sample-vuln/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

@app.route("/load")
from flask import request

def load():
raw = request.args.get("data", None)
if not raw:
return {"error": "no data"}, 400

import json, binascii
try:
# PRECOGS_FIX: do NOT use pickle.loads on untrusted data; expect JSON encoded in hex instead
data_bytes = bytes.fromhex(raw)
except (ValueError, TypeError):
return {"error": "invalid hex data"}, 400

try:
obj = json.loads(data_bytes.decode("utf-8"))
except Exception:
return {"error": "failed to parse JSON payload; sending pickles is not allowed"}, 400

return {"loaded": str(obj)}