Prevent insecure deserialization attacks | Veracode Docs (2024)

Insecure Deserialization is an attack where a manipulated object is injected into the context of the web application.

Security assessment

Prevent insecure deserialization attacks | Veracode Docs (1)

CVSS vector: AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H/CR:X/IR:X/AR:X/MAV:N/MAC:H/MPR:N/ MUI:N/MS:U/MC:H/MI:H/MA:H

Vulnerability information

Insecure deserialization is a well-known yet not commonly occurring vulnerability in which an attacker inserts malicious objects into a web application. This allows them to inflict denial-of-service (DoS) attacks, remote code execution attacks, SQL injections, Path Traversal, and Authentication Bypasses.

Deserialization attacks are a significant threat and can have severe consequences for businesses and customers. Potential vulnerabilities have been identified in the most popular programming languages, including Java, Python, .NET, PHP, Node.js, and Ruby.

Insecure deserialization has been ranked as #8 on the OWASP Top Ten List of web applications most critical security risks since 2017, along with other risks such as an injection vulnerability. In addition, it is recognized as one of the first steps that software development organizations need to take to ensure more secure coding.

Attack examples

Insecure deserialization attacks are often seen as challenging to execute and thus deemed not typical, affecting as low as 1% of applications. Yet, due to a large number of attacks, an application that can be subject to this attack shouldn't be underestimated.

The most typical example of an insecure deserialization vulnerability is when an attacker loads untrusted code into a serialized object and then forwards it to the web application. The application will deserialize the malicious input if there are no checks, allowing it to access even more of its parts. That is how it makes possible additional attacks that eventually may cause serious privacy vulnerability for the application's user base. Insecure deserialization is thus sometimes referred to as an 'object injection vulnerability.

The OWASP Insecure Deserialization Cheat Sheet contains some common attack examples:

  • A set of Spring Boot microservices is called in a React application. To make their code immutable, the programmers serialized user states, which are passed back and forth with each request. An attacker abuses the R00 Java object signature and, by employing the Java Serial Killer tool, performs remote code execution on the application server.
  • PHP object serialization is used for a PHP forum to save a super cookie loaded with data. It contains the user ID, role, password hash, and other states. An attacker modifies the serialized object to obtain admin privileges and tamper with the data.
a:4:{i:0;i:132;i:1;s:7:"Mallory";i:2;s:4:"user"; 
i:3;s:32:"b6a8b3bea87fe0e05022f8f3c88bc960";}

The attacker changes the serialized object to give themselves admin privileges:

a:4:{i:0;i:1;i:1;s:5:"Alice";i:2;s:5:"admin"; 
i:3;s:32:"b6a8b3bea87fe0e05022f8f3c88bc960";}

Prevent attacks

To protect your web application from insecure deserialization, it is crucial never to pass a serialized object manipulated with untrusted input by the user to the deserialize function. The reason is that if you do so, an untrusted user would be able to manipulate the object and can send it directly to the PHP deserialize function.

As an example how a serialized PHP object looks like, see the code block below:

Prevent insecure deserialization attacks | Veracode Docs (2)

Suppose you need to pass serialized data between the web application and a user. In that case, you can use a secure and lightweight data-interchange format like JSON (JavaScript Object Notation) instead of deserializing.

The OWASP notes that the best way to prevent insecure deserialization attacks is never to accept serialized objects from untrusted users. Alternatively, you can use serialization tools that allow only primitive data types.

In case you have to accept serialized objects, here are some tips for stopping insecure deserialization:

  • Introduce digital signatures and other integrity checks to stop malicious object creation or other data interfering.
  • Run deserialization code in low privilege environments.
  • Keep a log with deserialization exceptions and failures.
  • Execute strict constraints for the deserialization processes before object creation.
  • Limit and check all incoming and outgoing network activity from deserialization containers and servers.
  • Keep tabs on deserialization activities to identify in case there is constant deserialization by a user.
  • Use deserialization methods like JSON, XML, and YAML that are language-agnostic.

Test for insecure deserialization

You can check your application manually from the source code site and in the running state for insecure deserialization testing. You can also use a static code analysis tool. However, it would require access to your code and only see the "theoretical" view of your application in a non-executed way.

If you want to test your executed, running application, the best approach is to use a dynamic application security testing tool. It can automatically scan your web application or API.

To test if your web application is vulnerable to insecure deserialization, you can run an invasive free scan through the Vulnerability Testing Software.

The content of this section is Creative Commons Attribution-ShareAlike v4.0.

Prevent insecure deserialization attacks | Veracode Docs (2024)

FAQs

How can we avoid issues with insecure deserialization? ›

Here are some strategies and best practices to help safeguard your JavaScript applications against insecure deserialization attacks:
  • Avoid deserializing untrusted data. ...
  • Use safe deserialization libraries. ...
  • Validate and sanitize input. ...
  • Implement integrity checks. ...
  • Limit deserialization features. ...
  • Implement proper error handling.

Which of the following is a safe way to avoid insecure deserialization? ›

Avoid native formats

The only way to ensure complete protection against insecure deserialization attacks is to reject any serialized objects from an unvetted source (or to accept only the serialized objects derived from a primitive data type).

What is the most secure way to defend against deserialization attacks? ›

The most secure way to defend against deserialization attacks is to never accept serialized objects from untrusted sources or to use serialization mediums that only permit primitive data types.

Which of the following are preventative measures against insecure deserialization according to owasp? ›

Use Alternative Data Formats: Use less complex data formats such as JSON for serialization if possible. Keep Up-to-Date: Update your software with the latest security patches, which may address known deserialization vulnerabilities.

What is an example of insecure deserialization? ›

The most typical example of an insecure deserialization vulnerability is when an attacker loads untrusted code into a serialized object and then forwards it to the web application. The application will deserialize the malicious input if there are no checks, allowing it to access even more of its parts.

Which of the following is valid mitigation against deserialization attacks? ›

Use a Web Application Firewall (WAF)

WAFs are able to recognize and block attempts to exploit deserialization vulnerabilities. By scrutinizing data packets for known attack patterns or anomalies, they prevent malicious data from reaching the application.

How to avoid deserialization in Java? ›

In your code, override the ObjectInputStream#resolveClass() method to prevent arbitrary classes from being deserialized. This safe behavior can be wrapped in a library like SerialKiller.

Which serialization method is safer to mitigate the risk of unsafe deserialization vulnerabilities? ›

Use Secure Serialization Mechanisms: Avoid using serialization mechanisms known to be vulnerable, such as binary serialization or XML deserialization with DTD processing enabled. Opt for secure serialization methods, such as JSON, which are less prone to deserialization attacks.

Which of the following is the least secure method of authentication? ›

Historically the most common form of authentication, Single-Factor Authentication, is also the least secure, as it only requires one factor to gain full system access. It could be a username and password, pin-number or another simple code.

Which content types are vulnerable to deserialization? ›

Applications written in Java, PHP, ASP.NET and other languages can also be susceptible to insecure deserialization vulnerabilities. Serialization and deserialization vary greatly depending on the programming language, serialization formats and software libraries used.

In what ways can tampering of serialized objects be prevented? ›

Leverage robust security measures, including advanced Web Application Firewalls (WAFs) and digital signatures, to authenticate serialized objects and thwart tampering attempts. Execute deserialized objects and code within secure, low-privilege environments to minimize potential exploitation impacts.

What is the difference between serialization and deserialization? ›

Data serialization is the process of converting an object into a stream of bytes to more easily save or transmit it. The reverse process—constructing a data structure or object from a series of bytes—is deserialization.

How can the risk of insecure deserialization attacks be reduced by using what? ›

One key measure that can be taken to reduce risk is to avoid the native deserialization formats employed by programming languages. By using XML or JSON, language-agnostic, data-only formats, the risk of exploiting deserialization logic as a mode of attack gets significantly reduced.

Which of the following actions should developers complete to avoid issues with insecure deserialization? ›

By using non-standard data formats, you lessen the chances of being susceptible to insecure deserialization. This is because your attacker in unlikely to know what methods you have used within the code without first having to review it. This can frustrate an attacker and make you a more difficult target.

Which is the top most common vulnerability? ›

Top 10 web application vulnerabilities in 2021–2023
  • Broken Access Control.
  • Sensitive Data Exposure.
  • Server-Side Request Forgery (SSRF)
  • SQL Injection.
  • Cross-Site Scripting (XSS)
  • Broken Authentication.
  • Security Misconfiguration.
  • Insufficient Protection from Brute-Force Attacks.
Mar 12, 2024

How can organizations avoid the security risks of insecure design? ›

INSECURE DESIGN PREVENTION TECHNIQUES

Application development teams should build different tier layers to establish a privilege separation for users that require different permissions. The segregation should be applied to the system and network layers to enhance isolation based on exposure and protection needs.

What are the risks of insecure deserialization web application? ›

Insecure deserialization is a security vulnerability that occurs when untrusted data is used to abuse the logic of an application by manipulating serialized objects. This can lead to various types of attacks, such as remote code execution (RCE), denial of service (DoS), and privilege escalation.

What are the problems with deserialization? ›

Insecure deserialization is when user-controllable data is deserialized by a website. This potentially enables an attacker to manipulate serialized objects in order to pass harmful data into the application code.

Top Articles
Build Generational Wealth In 6 Best Ways - A Guide
List of Cryptocurrencies You Need to Know
Fat Hog Prices Today
Federal Fusion 308 165 Grain Ballistics Chart
Teenbeautyfitness
The Idol - watch tv show streaming online
Mylife Cvs Login
The Many Faces of the Craigslist Killer
Ucf Event Calendar
Premier Boating Center Conroe
Morocco Forum Tripadvisor
Nebraska Furniture Tables
Uc Santa Cruz Events
Craigslist In Flagstaff
Jet Ski Rental Conneaut Lake Pa
Juicy Deal D-Art
Project, Time & Expense Tracking Software for Business
Reptile Expo Fayetteville Nc
Timeforce Choctaw
Empire Visionworks The Crossings Clifton Park Photos
Touchless Car Wash Schaumburg
Sussyclassroom
Rimworld Prison Break
Ac-15 Gungeon
SN100C, An Australia Trademark of Nihon Superior Co., Ltd.. Application Number: 2480607 :: Trademark Elite Trademarks
When Does Subway Open And Close
Craigslist Pasco Kennewick Richland Washington
Doctors of Optometry - Westchester Mall | Trusted Eye Doctors in White Plains, NY
TMO GRC Fortworth TX | T-Mobile Community
Airg Com Chat
Robert A McDougal: XPP Tutorial
Taktube Irani
Bozjan Platinum Coins
Kstate Qualtrics
Weekly Math Review Q4 3
Tendermeetup Login
Drabcoplex Fishing Lure
Colorado Parks And Wildlife Reissue List
Afspraak inzien
My.lifeway.come/Redeem
Stafford Rotoworld
Fifty Shades Of Gray 123Movies
Cygenoth
Omaha Steaks Lava Cake Microwave Instructions
Barstool Sports Gif
Nami Op.gg
Here's Everything You Need to Know About Baby Ariel
Penny Paws San Antonio Photos
Fatal Accident In Nashville Tn Today
Booknet.com Contract Marriage 2
Star Sessions Snapcamz
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated:

Views: 6273

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.