Deserialization of Untrusted DataID: 502 | Date: (C)2012-05-14 (M)2022-10-10 |
Type: weakness | Status: DRAFT |
Abstraction Type: Variant |
Description
The application deserializes untrusted data without
sufficiently verifying that the resulting data will be
valid.
Extended DescriptionIt is often convenient to serialize objects for communication or to save
them for later use. However, deserialized data or code can often be modified
without using the provided accessor functions if it does not use
cryptography to protect itself. Furthermore, any cryptography would still be
client-side security -- which is a dangerous security assumption.Data that is untrusted can not be trusted to be well-formed.
Likelihood of Exploit: Medium
Applicable PlatformsLanguage Class: All
Time Of Introduction
- Architecture and Design
- Implementation
Common Consequences
Scope | Technical Impact | Notes |
---|
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. |
AuthorizationOther | Other | Code could potentially make the assumption that information in the
deserialized object is valid. Functions which make this dangerous
assumption could be exploited. |
Detection MethodsNone
Potential Mitigations
Phase | Strategy | Description | Effectiveness | Notes |
---|
Requirements | | A deserialization library could be used which provides a cryptographic
framework to seal serialized data. | | |
Implementation | | Use the signing features of a language to assure that deserialized
data has not been tainted. | | |
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 final readObject() to prevent deserialization. An
example of this is: | | |
Architecture and DesignImplementation | | 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. | | |
Relationships
Related CWE | Type | View | Chain |
---|
CWE-502 ChildOf CWE-896 | Category | CWE-888 | |
Demonstrative Examples (Details)
- This code snippet deserializes an object from a file and uses it as
a UI button:
White Box Definitions None
Black Box Definitions None
Taxynomy Mappings
Taxynomy | Id | Name | Fit |
---|
CLASP | | Deserialization of untrusted data | |
CERT Java Secure Coding | SER01-J | Do not deviate from the proper signatures of serialization
methods | |
CERT Java Secure Coding | SER03-J | Do not serialize unencrypted, sensitive
data | |
CERT Java Secure Coding | SER06-J | Make defensive copies of private mutable components during
deserialization | |
CERT Java Secure Coding | SER08-J | Do not use the default serialized form for implementation
defined invariants | |
References:None