Site AI Auditمن Internet Solutions

Insecure Deserialization Explained in Plain Language

19 أكتوبر 2026وقت القراءة: 8 دالأمان وSSL
Insecure Deserialization Explained in Plain Language

Short answer: Serialization turns an object in a program into text or bytes so that it can be stored or sent, and deserialization rebuilds the object. When an application rebuilds objects from data that an outsider controls, the attacker may change how the program behaves, and in the worst case run their own code. The safest approach is to avoid deserializing untrusted data, use plain formats such as JSON, verify the origin of the data and keep all software updated.

What serialization and deserialization mean

Programs work with objects: a shopping cart, a user session, a settings record. To save an object in a database, put it in a cookie or send it to another system, the program has to convert it into a flat format. That conversion is called serialization. The reverse step, which reads the flat data and builds the object again, is deserialization.

Every popular language has its own mechanism for this. PHP has serialize and unserialize. Java, Python, Ruby and .NET have similar tools, and many of them can rebuild almost any type of object found in the application. That flexibility is the source of the problem. The data does not only say what the values are. It can also say which kind of object to create, and creating an object can trigger code.

For website owners the idea is easy to remember: data that comes from outside must never be allowed to decide what kind of object your application creates or what that object does.

Why it becomes a security problem

Insecure deserialization happens when an application accepts serialized data from a source it cannot trust, such as a cookie, a form field, a URL parameter, an uploaded file or an API request, and rebuilds objects from it without checking.

Objects in many languages have special methods that run automatically at certain moments, for example when an object is created, destroyed or converted to text. An attacker who can choose the object type can make those methods run with values that the attacker also chose. A method that deletes a file, writes to a log or runs a database query then does so on the attacker’s behalf.

The attacker does not need to inject new code into the application. They reuse code that is already there and combine existing methods into a chain, which is why the technique is often called object injection and the chains are called gadget chains. The more classes and libraries your application loads, the more material there is for such a chain.

What attackers can achieve

The result depends on the application and on the classes available to it. Typical outcomes include:

These outcomes are close relatives of other injection flaws. Our articles on command injection and SQL injection describe similar goals reached by different routes.

Where it shows up on PHP and WordPress sites

PHP has a long history with this flaw. Its unserialize function creates objects from a string, and many older plugins and themes passed data from cookies, forms or remote servers straight into it. WordPress itself stores many settings in a serialized format in the database and uses helper functions to read them, which is safe as long as the stored values come from trusted sources.

Real-world risks usually appear in the following places:

Most of the time the vulnerable code is in a plugin and not in WordPress core, which is why updates and a short plugin list matter so much.

A simple example in everyday terms

Imagine a website that stores a visitor’s cart in a cookie. Instead of saving only the product numbers, the developer saves the whole cart object as serialized text, including a field that says what to do with a discount code. When the visitor returns, the site rebuilds the object from the cookie. A curious visitor opens the browser’s developer tools, edits the text and changes the discount field or the object type. If the site rebuilds whatever it receives, the edited object now exists inside the application. The visitor never broke into the server. The server simply believed a note that came from outside. This is why developers say that data from the browser is a suggestion and never an instruction.

How developers prevent it

The strongest protection is to avoid the problem altogether. These measures are listed from the most to the least effective.

  1. Do not deserialize untrusted data. If outside data must enter the application, use a plain data format such as JSON, which holds values and cannot create arbitrary objects.
  2. Restrict allowed classes. When serialized data is unavoidable, use the option of the language that lists which classes may be created, and allow none or only a few harmless ones.
  3. Sign the data. Add a signature created with a secret key, and check it before reading the data. An attacker who does not know the key cannot produce valid data. Never rely on encryption without integrity checking.
  4. Keep the server-side state. Store the session and the user role on the server and give the browser only a random identifier.
  5. Update libraries. Many gadget chains are removed in later versions of popular libraries.
  6. Limit privileges. Run the application with the smallest file and network permissions, so that a successful chain can do less damage. See file permissions on a web server.
  7. Log and monitor. Unusual errors in deserialization code and sudden file changes are warning signs.

What website owners can do without coding

Even if you never write code, you control several important factors.

If a site is already compromised, find the entry point before restoring. Our article on web shells and backdoor removal describes what to look for after a successful attack.

Signs that something is wrong

Insecure deserialization attacks are quiet, and the first sign is often a side effect. Watch for unexplained changes in user roles, new administrator accounts, new files in upload or plugin folders, unexpected outgoing connections from the server, sudden spikes in memory or CPU usage after requests to one endpoint and error messages about unexpected classes or malformed data in the log. A security plugin or your host’s malware scanner can alert you to file changes, which is often the earliest reliable indicator.

What Site AI Audit can and cannot tell you

Site AI Audit examines your website from the outside. It checks the SSL certificate and its expiry, the redirect from HTTP to HTTPS, security headers and exposed software versions. It does not send crafted serialized data to your application, so it cannot confirm or exclude a deserialization flaw. The exposed software version check helps indirectly, since software that announces an old version is a good candidate for an update. You can run a free check of your website or see the plans.

Related reading

The bottom line

Insecure deserialization turns trusted-looking data into a way to run code that was never meant to run. Avoid rebuilding objects from outside data, prefer JSON, sign anything you must trust and keep plugins and libraries updated. For most site owners the practical defence is simple: fewer plugins, regular updates and no pirated software.

الأسئلة الشائعة

What is the difference between serialization and encryption?

Serialization only converts an object into a storable format. It does not hide or protect the data. Encryption hides the content. A serialized value in a cookie can be read and changed by anyone unless it is also signed or kept on the server.

Is JSON safe against deserialization attacks?

Standard JSON parsing only produces plain values such as text, numbers, lists and records, so it cannot create arbitrary objects with hidden behaviour. Applications can still misuse the values, but the specific object injection risk is removed.

Does WordPress core have this problem?

WordPress stores some data in serialized form and reads it carefully. The majority of real incidents involve plugins or themes that pass untrusted input to a deserialization function. Updates and a short list of well-maintained plugins reduce the risk.

Can a firewall stop these attacks?

A web application firewall can block known attack patterns and reduce the risk, but it cannot recognise every crafted payload. Treat it as an additional layer, and still fix the underlying code or update the vulnerable component.

How do I know if a plugin is vulnerable?

Check whether it is actively maintained, read its update notes and look for published security advisories for its name and version. If it has been abandoned, replace it with a maintained alternative.

#Web vulnerabilities#Website security#WordPress security
افحص موقعك — مجانًا.ما الذي يجب إصلاحه في موقعك — ومن أين تبدأ.
ابدأ مجانًا

المزيد من المدونة

كل المقالات ←
Internet Solutions

المزيد من فريقنا

من تطوير Internet Solutions. جرّب بقية منتجاتنا — كل منها يوفّر وقتك بطريقة مختلفة.

internet-solutions.net ↗
01النشر التلقائي على وسائل التواصل
PostRSS

تنتقل المنشورات الجديدة من خلاصة RSS الخاصة بك تلقائيًا إلى Facebook وX وLinkedIn وTelegram وأكثر من 60 شبكة أخرى.

خطة مجانية · منذ 2014زيارة ←
02دردشة مباشرة بالذكاء الاصطناعي للمواقع
Talkmio

يجيب موقعك على الزوار على مدار الساعة من محتواك أنت وبلغتهم.

خطة مجانية · دون بطاقةزيارة ←
03مساعد بالذكاء الاصطناعي
Ask Mio

دردشة وبرمجة وتصميم وكتابة وبحث. يختار Mio أفضل نموذج لكل مهمة.

خطة مجانيةزيارة ←
04طيار آلي بالذكاء الاصطناعي للمدونة ووسائل التواصل
AI Blog Autopilot

يكتب الذكاء الاصطناعي مقالات SEO من 2000 إلى 3000 كلمة وينشر كل مقال على أكثر من 60 شبكة اجتماعية.

أول 3 مقالات مجانًازيارة ←
05زحف SEO متعمّق
Site SEO AI Audit

زحف SEO كامل عبر 7 مجالات، بما فيها الظهور في البحث بالذكاء الاصطناعي، مع إصلاحات مرتّبة حسب التأثير.

أول تدقيق مجانيزيارة ←
06خلاصات RSS والمنتجات
RSS Feed Creator

أنشئ RSS من أي صفحة ويب، بالإضافة إلى خلاصات منتجات لـ Google وMeta تتحدّث تلقائيًا.

خطة مجانيةزيارة ←
07تطوير المواقع وتحسين محركات البحث
Internet Solutions

مواقع ومتاجر إلكترونية وأنظمة مخصّصة، يصمّمها فريقنا ويبنيها ويديرها.

منذ 2011زيارة ←