Medium Web & API Security +400 XP

Pickle Jar

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?

51% solve it 257 hackers played 2 flags Updated Oct 12, 2026 First blood Malekith
PythonPickle DeserializationRCEPrivilege EscalationLinux
Start Your Challenge

Launch your dedicated machine to begin hacking

  1. 1Create a free account, then click "Start Lab"You'll get your own private machine with an IP address
  2. 2Explore the targetOpen the IP in your browser and look for vulnerabilities
  3. 3Find and submit flagsFlags are secret text strings hidden in the system - paste them below to score
  • ~1-2 min setup
  • Private instance
  • 30 min per session. Restart it for free, as often as you like.

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