Lab Icon

Pickle Jar

Can you exploit the insecure deserialization?

Medium Updated 10 Jun 2026 Free Access Solution (Pro)
Python Pickle Deserialization RCE Privilege Escalation Linux

DataVault Inc. lets users restore backup configurations by uploading .pkl files. The service trustingly deserializes whatever you send. Can you craft a malicious pickle to pop a shell and escalate to root?

2
Flags
400
XP
42%
Success Rate

Insecure deserialization is a critical web application vulnerability that occurs when an application deserializes untrusted data without proper validation. In Python, the pickle module is a common serialization library that is inherently unsafe when used with user-supplied data. Python's own documentation explicitly warns that pickle should never be used to deserialize data from untrusted sources, yet this warning is frequently ignored in production applications, creating severe security vulnerabilities.

Understanding Python Pickle Deserialization

Python's pickle module serializes objects into a byte stream and can reconstruct them later through deserialization. The danger lies in pickle's ability to execute arbitrary code during the deserialization process. By implementing the __reduce__ method on a custom class, an attacker can define arbitrary functions and arguments that will be called when the object is unpickled. This means a malicious pickle payload can execute system commands, establish reverse shells, or perform any operation available to the application's user - making it a direct path to Remote Code Execution (RCE).

Crafting Malicious Pickle Payloads

Creating an exploit for a pickle deserialization vulnerability involves writing a Python class with a __reduce__ method that returns a tuple containing a callable (like os.system or subprocess.Popen) and its arguments. When the application unpickles this object, the specified command is executed on the server. This technique is straightforward to implement, requiring only basic Python scripting skills, yet it yields the most severe impact - arbitrary code execution. The simplicity of the exploit makes insecure deserialization particularly dangerous.

From RCE to Full System Compromise

After achieving code execution through pickle deserialization, attackers typically establish a more stable foothold through reverse shells or SSH access. From there, Linux privilege escalation techniques - such as exploiting misconfigured sudo rules, SUID binaries, or writable system files - can elevate access to root. Understanding the complete attack chain from insecure deserialization through code execution to privilege escalation is essential for security professionals assessing Python-based web applications and services.

What You Will Learn

  • Understand Python pickle deserialization vulnerabilities and their severity
  • Learn to craft malicious pickle payloads using the __reduce__ method
  • Practice achieving Remote Code Execution through insecure deserialization
  • Explore sudo privilege enumeration on Linux systems
  • Develop skills in escalating from web application RCE to root access
  • Recognize secure alternatives to pickle for handling serialized data

Prerequisites

Basic Python scripting Web application fundamentals Linux command line Understanding of serialization concepts

Ready to hack this lab?

Create a free account and start practicing cybersecurity hands-on.

Start Hacking - It's Free
Start Your Challenge

Launch your dedicated machine to begin hacking

~1-2 min setup
Dedicated server
Private instance
Standard power
New here? Here's what to do
1
Click "Start Lab" above You'll get your own private machine with an IP address
2
Explore the target Open the IP in your browser and look for vulnerabilities
3
Find and submit flags Flags are secret text strings hidden in the system - paste them below to score

Ready to hack this lab?

Create a free account to start your own dedicated server, submit flags, and earn XP on the leaderboard.

Start Hacking Free
12,000+ Hackers 100+ Labs & Courses Free
Start Hacking Free