Understanding Insecure Deserialization Vulnerability

Anatomy of Insecure Deserialization

Serialization is the procedure of changing complex data structures, such as objects and their fields into an “easier” format so they can be sent and received as a sequential stream of bytes. When user-controllable data is deserialized by a website, this is known as insecure deserialization. This could give an attacker the ability to alter serialized objects and inject malicious codes into the application.

Insecure deserialization is one of the initial steps software development companies must take to ensure better safe code. Regardless of which class was anticipated, any class objects that are accessible to a website will be instantiated and deserialized. For this reason. unsafe deserialization is occasionally referred to as “object injections” vulnerability.

An exception might be brought about by an unexpected class object. But by then, perhaps the damage is already done. Numerous deserialization-based assaults are finished before the end of deserialization. Even if the functionality of the website doesn’t interact directly with the malicious item, the deserialization process itself may start an attack. As a result, websites with strongly typed language-based logic may potentially be susceptible to similar tactics.

Insecure Deserialization Types

Insecure deserialization often falls into three categories:

  • Blind Deserialization

Blind deserialization assaults take place behind a firewall-protected network or system that has rigorous security management procedures in place. To enable remote code execution, the attacker changes the transformer chain or exploits the Java payload.

  • Asynchronous Deserialization

Serialized devices are stored in databases during asynchronous deserialization assaults. A series of devices intended to control the deserialization procedure are launched in a JMS broker client library when target web apps start the process. Oracle OpenMQ, Pivotal RabbitMQ, Oracle Weblogic, and Apache QPID JMS are just a few of the JMS libraries that may be at risk.

  • Deferred-Execution Deserialization

This involves the subsequent implementation of gadget chains into weak programs. A chain of return-oriented programming (ROP) gadgets that ends with a return-from-procedure instruction is referred to as a gadget.

This makes it possible for the attacker to get beyond non-executable security measures, such as read-only memory and kernel-code coherence. With ROP gadgets, code execution can be enabled by linking an executable address to the necessary data parameters rather than by injecting binary code.

 

Preventing Insecure Deserialization

User input deserialization should generally be avoided until essential as it may permit serious attacks that are challenging to defend against. If you must deserialize any data from an unidentified or unreliable source, take the following precautions to ensure that data hasn’t been altered by an attacker:

  • Use digital signatures to confirm the accuracy of the data; however, this method only functions if checks are made before the deserialization procedure starts.
  • Wherever feasible, stay away from general deserialization techniques. It is advised that you control the exposure of individual fields because serialized data frequently contains private fields holding sensitive information. You can achieve this by developing a class-specific serialization method on your own.
  • Be sure to sanitize your inputs. Given the expected complexity of the cross-library dependence structure, it is not practical to plug every gadget chain. Given the possibility of memory corruption exploits, which may be publicly disclosed, your program may be exposed at any time. Always concentrate your preventative efforts on the real issue that requires attention.