Safe parsing verifies that incoming data matches an expected schema before the application uses it. Unsafe deserialization accepts the data first and only discovers problems after objects are reconstructed, which can revive malicious or malformed payloads. The practical difference is whether trust is established before or after data becomes application state.
Why safe parsing and unsafe deserialization fail in different ways
Safe JSON parsing treats incoming data as untrusted input and checks it against an expected structure before the application turns it into usable state. That preserves control over types, fields, and shape. Unsafe deserialization does the opposite, letting the runtime rebuild objects first, which can activate unexpected behaviour if the payload is crafted to exploit that reconstruction step.
The practical difference is not just timing. Parsing is about accepting or rejecting a data document. Deserialization is about reconstructing executable object state, so the failure mode is broader: type confusion, unexpected object graphs, and gadget-based abuse become possible when the application assumes the payload is already trustworthy.
In security terms, safe parsing keeps validation in front of trust. Unsafe deserialization moves trust earlier than it should be, which is why the same payload can be harmless as JSON text but dangerous once a framework interprets it as structured application objects.
What changes when data becomes object state
With safe parsing, the application can inspect the payload as plain data, compare it to a schema, and reject anything that does not fit. That means the program decides which fields are allowed, which types are acceptable, and which defaults or coercions are safe before any business logic sees the value.
With unsafe deserialization, the platform or library may perform those decisions implicitly. If the input can influence class selection, object construction, polymorphic typing, or callback behaviour, then the boundary between data and code becomes much thinner. In practice, that is why deserialization flaws often lead to much more than malformed input handling.
For JSON specifically, the safest mental model is to treat it as a data format, not an object-reconstruction mechanism. If the code path requires rich object graphs or automatic binding, Secure Deserialisation Guide is the better reference for the design choices that keep reconstruction fail-closed.
Where unsafe deserialization turns into a real security issue
Unsafe deserialization becomes dangerous when the application allows untrusted input to influence object type, constructor logic, or post-load behaviour. That can enable gadget chains, unexpected method invocation, or object injection, even when the source data looks syntactically valid. The issue is often not the transport format itself, but the trust granted to the reconstructed object.
This is why deserialization is usually discussed alongside integrity failures rather than simple input validation. The risk is that a payload can be accepted as “valid enough” to rebuild internal state, then trigger behaviour that the developer never intended to expose to external input. The OWASP Top 10 A08 Guide is useful here because it frames deserialization as part of a broader software and data integrity problem.
For teams that build or review applications using serializers, the control question is whether the code ever lets untrusted input choose implementation details. If the answer is yes, the issue is no longer just parsing quality, it is object trust boundary design.
Risk and Threat Considerations
Unsafe deserialization can turn a routine input-handling path into an execution path. The threat is strongest where frameworks support polymorphism, automatic binding, or object hooks, because attackers do not need the data to be human-readable, they only need it to be interpreted in the wrong way.
Failure mechanism: The application reconstructs objects before validating the payload’s type, structure, or allowable behaviour, which can activate gadgets, corrupt state, or expose a code path the developer assumed was unreachable.
Impact: The result can range from application crashes and data corruption to remote code execution, privilege abuse, or secondary compromise of sessions, secrets, and downstream systems that trust the application state.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
MITRE ATT&CK addresses the attack and risk surface, while OWASP ASVS and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V1 — Encoding and Sanitization | Covers validating untrusted input before processing it as application data. |
| V15 — Secure Coding and Architecture | Applies because unsafe deserialization is a design flaw in trust boundaries and object handling. | |
| V16 — Security Logging and Error Handling | Relevant for detecting and triaging malformed or malicious payloads during parsing and deserialization. | |
| Recommendation — Validate JSON against a strict schema before binding it to application state. Remove dynamic type loading and keep object construction fail-closed. Log rejected payload patterns and deserialization failures for investigation. | ||
| CIS Controls v8 | CIS-16 — Application Software Security | Directly supports secure handling of application input and deserialization risks. |
| Recommendation — Review application data-handling paths for unsafe object deserialization. | ||
| MITRE ATT&CK | T1055 — Process Injection | Unsafe deserialization can enable code execution behaviours that resemble attacker-controlled execution paths. |
| Recommendation — Map deserialization-triggered execution to ATT&CK techniques during hunting and response. | ||
Practitioner Guidance
What to verify: Check whether the code path accepts untrusted input into a deserializer, mapper, or ORM-like binder. If the library can instantiate types or invoke callbacks from the payload, treat that as a high-risk design until proven otherwise.
Decision rule: If the application only needs structured data, prefer explicit schema validation and fixed-type binding. If it truly needs object reconstruction, constrain the allowable types, disable dangerous polymorphism, and make failure closed the default.
Common mistake: Teams often assume “JSON” automatically means safe. JSON is only safer when the parser is used as a parser, not as a back door into dynamic object creation.
Practitioner takeaway: The security boundary should be crossed only after the input has been validated as data, not when a library decides to turn it into application state.
Related resources from NHI Mgmt Group
- Guide: Insecure Deserialisation Guide
- What is the difference between safe YAML parsing and unsafe Java deserialization in application security?
- Why does unsafe JSON deserialization create such a serious risk in gateway and connector architectures?
- How should engineering teams prevent unsafe deserialization when parsing untrusted YAML in Java applications?
- How do organisations stop a model’s safe response from becoming unsafe execution?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 31, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org