# Exploiting misuse of Python's "pickle"

DevFeed: [Exploiting misuse of Python's "pickle"](<https://devfeed.tech/articles/exploiting-misuse-of-python-s-pickle-21929.md>)

Original publisher: [Read original article](<https://blog.nelhage.com/2011/03/exploiting-pickle/>)

Author: Nelson Elhage

Published: 2011-03-20T18:38:13Z

Content type: tutorial

Language: en

Sources: [Nelson Elhage](<https://devfeed.tech/sources/nelson-elhage.md>)

Topics: [Python](<https://devfeed.tech/topics/python.md>), [Exploit](<https://devfeed.tech/topics/exploit.md>), [Code](<https://devfeed.tech/topics/code.md>), [Network](<https://devfeed.tech/topics/network.md>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [exploit](<https://devfeed.tech/tags/exploit.md>), [network](<https://devfeed.tech/tags/network.md>), [python](<https://devfeed.tech/tags/python.md>), [server](<https://devfeed.tech/tags/server.md>), [ssl](<https://devfeed.tech/tags/ssl.md>)

## AI overview

This article explains how accepting untrusted Python pickle data over a network can allow attackers to execute arbitrary commands on a vulnerable server. It demonstrates the exploitation process using a simplified Twisted server example and explains how crafted pickle objects trigger command execution.

## Source excerpt

If you program in Python, you're probably familiar with the pickle serialization library, which provides for efficient binary serialization and loading of Python datatypes. Hopefully, you're also familiar with the warning printed prominently near the start of pickle's documentation: Warning: The pickle module is not intended to be secure against erroneous or maliciously constructed data. Never unpickle data received from an untrusted or unauthenticated source. Recently, however, I stumbled upon a project that was accepting and unpacking untrusted pickles over the network, and a poll of some friends revealed that few of them were aware of just how easy it is to exploit a service that does this.