Written by: Mio Kanzaki(Security Analyst (AI))Reviewed by: 千葉圭介Updated
Insecure deserialization is a flaw that lets bad data cause harm when a program restores it. Deserialization is the processing that turns data converted for storage or transmission back into a form the program can handle. OWASP explains that it occurs when untrusted data is restored using the language's built-in method.
How does insecure deserialization work?
Flat-pack furniture is taken apart, boxed, shipped, and assembled where it arrives. Boxing it is the conversion and assembling it is the restoring. If you assemble a box from a stranger without checking what is inside, you cannot tell if a doctored part is mixed in.
According to OWASP, the language's standard restoring mechanism includes features that can be abused. As a result it can lead to a service outage, a bypass of access control, and even remote code execution.
MITRE CWE names the cause as processing data in an untrusted format without sufficiently checking that the result is valid. The problem is that processing no one intended runs during restoration. How to check is organized on the insecure deserialization vulnerability page.
Why does insecure deserialization matter?
It is hard to notice, because it happens inside the received data and does not show on the screen. In the 2021 OWASP Top 10 it is handled as part of software and data integrity failures (A08), a newly created category.
OWASP's guide advises that for untrusted data you avoid the language's standard format and use a plain data format such as JSON or XML. It also lists narrowing what may be restored with an allow list, and restoring only after confirming with a signature or the like that the data is genuine.
MITRE CWE's measures are to detect tampering with a signature or seal, and to create a new object and then fill it with verified values. When you cannot fix it at once, a WAF can help, but its effect is described as moderate. To see how up to date your site looks from outside, you can use the free URL check.
Related terms
- Remote code execution (RCE): an attack that runs commands of the attacker's choice on someone else's machine from outside
- HMAC signature: a mark that confirms data is genuine and was not changed on the way
- WAF: a wall that stops suspicious traffic at the entrance
- Vulnerability: a weakness in how a program is built or configured that can be an entrance for attack
Frequently asked questions
If I use JSON, can this flaw not occur?
OWASP explains that using a plain data format such as JSON or XML greatly lowers the risk. But depending on the library or configuration that reads it, other problems can remain, so keep the components updated too.
Does signing the data prevent it well enough?
It is one effective measure. MITRE CWE lists checking that data has not been altered with a signature or seal such as an HMAC. A signature loses its meaning if its key leaks, so managing the key is also essential.
Next step
The concrete way to check is organized on the insecure deserialization vulnerability page. The free URL check shows only what is visible from outside, and for a review of the components your site uses, contact us.
Frequently asked questions
If I use JSON, can this flaw not occur?
OWASP explains that using a plain data format such as JSON or XML greatly lowers the risk. But depending on the library or configuration that reads it, other problems can remain, so keep the components updated too.
Does signing the data prevent it well enough?
It is one effective measure. MITRE CWE lists checking that data has not been altered with a signature or seal such as an HMAC. A signature loses its meaning if its key leaks, so managing the key is also essential.