CWE-502: Deserialization of Untrusted Data

BaseDraftExploit Likelihood: Medium🏆 #19 in Top 25 (2024)

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

View on MITRE
237Related CVEs
10.29Severity Score
Back to CWE Lookup

Technical Details

Structure
Simple
Vulnerability Mapping
ALLOWED

Applicable To

Languages
JavaRubyPHPPythonJavaScript
Platforms

🏆 CWE Top 25 Historical Ranking

2023:#15
Score: 5.56
219 CVEs
2024:#19↓4
Score: 10.29
237 CVEs
Trend:Improving (moved up 4 ranks)

Source-backed guidance

Additional facts reviewed against primary or authoritative security sources.

Combine review and analysis around the CWE-502 trust boundary

MITRE identifies automated static analysis as applicable detection approaches. Use them to locate native object deserialization at trust boundaries and inspect type resolution, gadget availability, integrity checks, and callbacks executed while rebuilding object graphs. Require a reproducible source-to-sink or policy-to-enforcement trace, record coverage gaps, and confirm suspected findings dynamically where safe; no single scanner can establish complete coverage for this weakness.

CWE-502: detection methods and operational guidanceMITRE CWE

Do not deserialize attacker-controlled object graphs

Prefer a simple data format over native object serialization when crossing a trust boundary. Verify integrity or authenticity before deserialization, allow only expected data types, and reject unexpected polymorphic or type metadata. If legacy deserialization cannot be removed, isolate it in a low-privilege process and monitor for unexpected classes or execution paths.

Deserialization Cheat SheetOWASP Foundation

Apply lessons from CVE-2025-49113 in Roundcube Webmail

NVD maps CVE-2025-49113 to CWE-502; an authenticated user could influence a URL parameter that reached unsafe deserialization and achieve remote code execution. Use the case to trace seemingly ordinary settings and upload parameters into serialization APIs, remove native object parsing, and test authenticated low-privilege paths for gadget execution.

CVE-2025-49113 DetailNIST National Vulnerability Database

Prioritize CWE-502 using its 2025 CWE Top 25 evidence

CWE-502 ranked #15 in the 2025 CWE Top 25 with a score of 5.23. The ranking table recorded 11 mapped vulnerabilities in CISA KEV for this measurement window. Use the rank to prioritize systemic prevention, detection coverage, and recurring-root-cause metrics across the portfolio, while retaining asset exposure and business impact for individual finding severity decisions.

2025 CWE Top 25 Most Dangerous Software WeaknessesMITRE CWE

Constrain and exercise Java deserialization filters

For Java native serialization that cannot yet be removed, define allowlists and graph limits with process-wide or stream-specific filters, then test expected classes, rejected classes, proxies, arrays, depth, references, and byte limits. Exercise nested and oversized graphs in isolation, verify rejection occurs before dangerous callbacks, and confirm every deserialization entry point installs the intended filter.

Java Serialization FilteringOracle Java

Frequently Asked Questions

What is CWE-502: Deserialization of Untrusted Data?+

CWE-502: Deserialization of Untrusted Data is a Common Weakness Enumeration (CWE) entry maintained by MITRE. The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.

Is CWE-502 in the CWE Top 25 Most Dangerous Software Weaknesses?+

Yes. CWE-502 ranked #19 in the CWE Top 25 for 2024, associated with 237 CVEs that year. The CWE Top 25 highlights the most common and impactful software weaknesses based on real-world vulnerability data.

What are the security consequences of Deserialization of Untrusted Data?+

If exploited, CWE-502 (Deserialization of Untrusted Data) it can compromise Integrity, Availability and Other, leading to outcomes such as Modify Application Data, Unexpected State, DoS: Resource Consumption (CPU) and Varies by Context.

How do you prevent or mitigate Deserialization of Untrusted Data?+

Recommended mitigations for CWE-502 include: 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. 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. Explicitly define a final object() to prevent deserialization.

Which programming languages are affected by Deserialization of Untrusted Data?+

CWE-502 commonly affects Java, Ruby, PHP, Python and JavaScript. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.

What are real-world examples of Deserialization of Untrusted Data?+

MITRE documents real CVEs mapped to CWE-502, including CVE-2024-37052, CVE-2024-37288, CVE-2024-9314, CVE-2019-12799 and CVE-2015-8103. You can look up the full details of each CVE, including CVSS scores and remediation guidance, on our CVE Lookup tool.

What is the difference between a CWE and a CVE?+

A CWE (Common Weakness Enumeration) like CWE-502 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.

Learn More

Advertisement