CWEweakness

CWE-502 Deserialization of Untrusted Data

Medium Official page ↗
Alternate terms
Marshaling/Marshalling, Unmarshaling/Unmarshalling, Pickling, Unpickling, PHP Object Injection
Abstraction
Base
Structure
Simple
Status
Draft
Likelihood of exploit
Medium
Languages
Java, JavaScript, PHP, Python, Ruby
CWE version
5.0

Description

The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.

Common consequences

• Integrity: Modify Application Data, Unexpected State — Attackers can modify unexpected objects or data that was assumed to be safe from modification. Deserialized data or code could be modified without using the provided accessor functions, or unexpected functions could be invoked. • Availability: DoS: Resource Consumption (CPU) — If a function is making an assumption on when to terminate, based on a sentry in a string, it could easily never terminate. • Other: Varies by Context — The consequences can vary widely, because it depends on which objects or methods are being deserialized, and how they are used. Making an assumption that the code in the deserialized object is valid is dangerous and can enable exploitation. One example is attackers using gadget chains to perform unauthorized actions, such as generating a shell.

Potential mitigations

• [Architecture and Design, Implementation] If available, use the signing/sealing features of the programming language to assure that deserialized data has not been tainted. For example, a hash-based message authentication code (HMAC) could be used to ensure that data has not been modified. • [Implementation] When deserializing data, populate a new object rather than just deserializing. The result is that the data flows through safe input validation and that the functions are safe. • [Implementation] Explicitly define a final object() to prevent deserialization. • [Architecture and Design, Implementation] Make fields transient to protect them from deserialization. An attempt to serialize and then deserialize a class containing transient fields will result in NULLs where the transient data should be. This is an excellent way to prevent time, environment-based, or sensitive variables from being carried over and used improperly. • [Implementation] Avoid having unnecessary types or gadgets (a sequence of instances and method invocations that can self-execute during the deserialization process, often found in libraries) available that can be leveraged for malicious ends. This limits the potential for unintended or unauthorized types and gadgets to be leveraged by the attacker. Add only acceptable classes to an allowlist. Note: new gadgets are constantly being discovered, so this alone is not a sufficient mitigation. • [Architecture and Design, Implementation] Employ cryptography of the data or code for protection. However, it's important to note that it would still be client-side security. This is risky because if the client is compromised then the security implemented on the client (the cryptography) can be bypassed. • [Operation] Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481].

Detection methods

• Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Observed examples

• CVE-2024-37052: insecure deserialization in platform for managing AI/ML applications and models allows code execution via a crafted pickled object in a model file • CVE-2024-37288: deserialization of untrusted YAML data in dashboard for data query and visualization of Elasticsearch data • CVE-2024-9314: PHP object injection in WordPress plugin for AI-based SEO • CVE-2019-12799: Chain: bypass of untrusted deserialization issue (CWE-502) by using an assumed-trusted class (CWE-183) • CVE-2015-8103: Deserialization issue in commonly-used Java library allows remote execution. • CVE-2015-4852: Deserialization issue in commonly-used Java library allows remote execution. • CVE-2013-1465: Use of PHP unserialize function on untrusted input allows attacker to modify application configuration. • CVE-2012-3527: Use of PHP unserialize function on untrusted input in content management system might allow code execution. • CVE-2012-0911: PHP-based content management system written in PHP uses unserialize function on untrusted input to generate arbitrary objects, possibly allowing code execution. • CVE-2011-2520: Python script allows local users to execute code via pickled data. • CVE-2012-4406: Unsafe deserialization using pickle in a Python script. • CVE-2003-0791: Web browser allows execution of native methods via a crafted string to a JavaScript function that deserializes the string.

Related

Attack pattern · CAPEC (1)

Observed example · CVE (12)

  • CVE-2024-9314 The Rank Math SEO – AI SEO Tools to Dominate SEO Rankings plugin for WordPress is vulnerable to PHP Object Injection in all versions up to,… vulnerability
  • CVE-2024-37288 A deserialization issue in Kibana can lead to arbitrary code execution when Kibana attempts to parse a YAML document containing a crafted… vulnerability
  • CVE-2024-37052 Deserialization of untrusted data can occur in versions of the MLflow platform running version 1.1.0 or newer, enabling a maliciously… vulnerability
  • CVE-2019-12799 In createInstanceFromNamedArguments in Shopware through 5.6.x, a crafted web request can trigger a PHP object instantiation vulnerability,… vulnerability
  • CVE-2015-8103 The Jenkins CLI subsystem in Jenkins before 1.638 and LTS before 1.625.2 allows remote attackers to execute arbitrary code via a crafted… vulnerability
  • CVE-2015-4852 The WLS Security component in Oracle WebLogic Server 10.3.6.0, 12.1.2.0, 12.1.3.0, and 12.2.1.0 allows remote attackers to execute… vulnerability
  • CVE-2013-1465 The Cubecart::_basket method in classes/cubecart.class.php in CubeCart 5.0.0 through 5.2.0 allows remote attackers to unserialize arbitrary… vulnerability
  • CVE-2012-4406 OpenStack Object Storage (swift) before 1.7.0 uses the loads function in the pickle Python module unsafely when storing and loading… vulnerability
  • CVE-2012-3527 view_help.php in the backend help system in TYPO3 4.5.x before 4.5.19, 4.6.x before 4.6.12 and 4.7.x before 4.7.4 allows remote… vulnerability
  • CVE-2012-0911 TikiWiki CMS/Groupware before 6.7 LTS and before 8.4 allows remote attackers to execute arbitrary PHP code via a crafted serialized object… vulnerability
  • CVE-2011-2520 fw_dbus.py in system-config-firewall 1.2.29 and earlier uses the pickle Python module unsafely during D-Bus communication between the GUI… vulnerability
  • CVE-2003-0791 The Script.prototype.freeze/thaw functionality in Mozilla 1.4 and earlier allows attackers to execute native methods by modifying the… vulnerability

Child of · CWE (1)

  • CWE-913 Improper Control of Dynamically-Managed Code Resources weakness

Peer of · CWE (1)

  • CWE-915 Improperly Controlled Modification of Dynamically-Determined Object Attributes weakness

Referenced by CAPEC · weakness (1)

Referenced by CVE · weakness (3,595)

  • CVE-2026-103693 The Frontend Dashboard WordPress plugin before 3.0.5, ProfileGrid WordPress plugin before 6.0.0.5 do not prevent an unauthenticated user… vulnerability
  • CVE-2026-104317 IBM Langflow OSS 1.0.0 through 1.12.3 could allow a remote attacker who could reach the message broker to execute arbitrary code on the… vulnerability
  • CVE-2026-104324 IBM Langflow OSS 1.0.0 through 1.12.3 could allow a remote authenticated attacker to execute arbitrary code due to deserialization of… vulnerability
  • CVE-2026-116864 Author PHP Object Injection in WPCargo Track & Trace <= 8.0.5 versions. vulnerability
  • CVE-2026-116865 Editor PHP Object Injection in Zippy <= 1.7.0 versions. vulnerability
  • CVE-2026-116866 Contributor PHP Object Injection in Extra Fees Plugin for WooCommerce <= 4.4.0 versions. vulnerability
  • CVE-2026-116867 Contributor PHP Object Injection in Dynamic QR Code &#8211; generator <= 1.0.1 versions. vulnerability
  • CVE-2026-116868 Subscriber PHP Object Injection in BuddyPress Xprofile Custom Field Types <= 1.3.1 versions. vulnerability
  • CVE-2026-116869 Shop manager PHP Object Injection in myPOS Checkout <= 1.4.5 versions. vulnerability
  • CVE-2026-118073 Subscriber PHP Object Injection in News Kit Elementor Addons <= 1.5.0 versions. vulnerability
  • CVE-2026-118074 Shop manager PHP Object Injection in Finale Lite <= 2.21.0 versions. vulnerability
  • CVE-2026-118075 Contributor PHP Object Injection in WP Media folders <= 1.1.10 versions. vulnerability
  • CVE-2026-118076 Contributor PHP Object Injection in Frisbii Pay <= 1.8.19 versions. vulnerability
  • CVE-2026-118077 Author PHP Object Injection in Sastra Essential Addons for Elementor <= 1.2.3 versions. vulnerability
  • CVE-2026-118078 Shop manager PHP Object Injection in Product Catalog Feed by PixelYourSite <= 3.1.4 versions. vulnerability
  • CVE-2026-118079 Shop manager PHP Object Injection in FV Flowplayer Video Player <= 8.3.4 versions. vulnerability
  • CVE-2026-118080 Contributor PHP Object Injection in Social Snap <= 1.5.4 versions. vulnerability
  • CVE-2026-118081 Contributor PHP Object Injection in 10Web Social Photo Feed <= 1.5.6 versions. vulnerability
  • CVE-2026-119120 Crawl4AI from 0.9.0 before 0.9.5 fails to filter the CosineStrategy model_name field in untrusted Docker API request bodies, allowing… vulnerability
  • CVE-2026-42701 Shop manager PHP Object Injection in YayMail <= 4.4.6 versions. vulnerability
  • CVE-2026-54856 Unauthenticated PHP Object Injection in RexCoin <= 1.2.6 versions. vulnerability
  • CVE-2026-54857 Unauthenticated PHP Object Injection in Quirky <= 1.23 versions. vulnerability
  • CVE-2026-54858 Unauthenticated PHP Object Injection in Printy <= 1.13.0 versions. vulnerability
  • CVE-2026-54859 Unauthenticated PHP Object Injection in Preservation <= 1.15 versions. vulnerability
  • CVE-2026-54860 Unauthenticated PHP Object Injection in Ozisti <= 1.1.10 versions. vulnerability
  • CVE-2026-61992 Unauthenticated PHP Object Injection in GEO my WordPress <= 4.5.5.3 versions. vulnerability
  • CVE-2026-61997 Unauthenticated PHP Object Injection in Legal Stone <= 1.2.11 versions. vulnerability
  • CVE-2026-61998 Unauthenticated PHP Object Injection in Le Truffe <= 1.1.7 versions. vulnerability
  • CVE-2026-62001 Unauthenticated PHP Object Injection in Marcell <= 1.2.14 versions. vulnerability
  • CVE-2026-62002 Unauthenticated PHP Object Injection in Meals & Wheels <= 1.1.13 versions. vulnerability
Show all 3,595 ›

Referenced by CWE · has member (9)

  • CWE-1200 Weaknesses in the 2019 CWE Top 25 Most Dangerous Software Errors view
  • CWE-1337 Weaknesses in the 2021 CWE Top 25 Most Dangerous Software Weaknesses view
  • CWE-1340 CISQ Data Protection Measures view
  • CWE-1350 Weaknesses in the 2020 CWE Top 25 Most Dangerous Software Weaknesses view
  • CWE-1387 Weaknesses in the 2022 CWE Top 25 Most Dangerous Software Weaknesses view
  • CWE-1425 Weaknesses in the 2023 CWE Top 25 Most Dangerous Software Weaknesses view
  • CWE-1430 Weaknesses in the 2024 CWE Top 25 Most Dangerous Software Weaknesses view
  • CWE-1435 Weaknesses in the 2025 CWE Top 25 Most Dangerous Software Weaknesses view
  • CWE-884 CWE Cross-section view

Referenced by CWE · peer of (1)

  • CWE-915 Improperly Controlled Modification of Dynamically-Determined Object Attributes weakness

Referenced by OWASP · mapped cwe (2)

  • A08:2025 Software or Data Integrity Failures Top 10 2025
  • A08:2021 Software and Data Integrity Failures Top 10 2021