JSON deserialisation is the conversion of JSON text into native objects or data structures in a programme. It is commonly used in web APIs and application code, and unsafe deserialisation can let untrusted input create unexpected object states, trigger logic flaws or, in some runtimes, enable code execution.
What JSON Deserialization Does
JSON deserialization turns JSON text into live objects or data structures that application code can use. That makes it a basic integration step in APIs, message handling, configuration loading and client-server communication. The security boundary matters because the parser is not just reading data, it is creating structured program state from input that may be untrusted.
In safe designs, the target type is predictable and the incoming JSON is treated as data only. In unsafe designs, the deserializer is allowed to influence object construction, type selection or post-processing behaviour, which can create unexpected object states and open the door to logic abuse.
Why Unsafe Deserialisation Becomes Dangerous
The main hazard is not JSON itself, but the way a parser or framework interprets it. If deserialization accepts attacker-controlled structure, polymorphism, dynamic binding or gadget-like behaviours, the input may do more than populate fields. It may trigger code paths the developer never intended, especially in runtimes that support rich object models.
That is why insecure deserialisation is often grouped with object injection and related parser abuse patterns. A small input change can alter trust assumptions inside the application, bypass validation logic, or produce state that later components treat as already trusted.
For a practical overview of the wider unsafe deserialisation problem, see the Insecure Deserialisation Guide, which covers object injection, gadget chains and common language-specific failure modes.
Common Exposure Patterns in Applications
JSON deserialization becomes risky when applications deserialize untrusted input without constraining the target type, allowed fields or object graph shape. Web APIs are a frequent exposure point because they receive external requests at scale, but the same issue also appears in internal service calls, queued jobs and configuration files that developers assume are safe.
Exposure is usually highest when a framework supports automatic binding, reflection-driven type resolution, nested object construction or liberal handling of unknown properties. In those cases, the security question is not just whether the JSON parses, but whether the parser can be steered into creating something the application did not expect.
Safe engineering usually depends on narrowing the contract, not on trusting the input source. That means fixed schemas, explicit model classes, strict field handling and rejection of unexpected polymorphic behaviour.
For engineering patterns that reduce this risk, the Secure Deserialisation Guide explains how to use fixed-type contracts, fail-closed loader settings and language-specific safeguards.
How Teams Reduce the Risk
Reducing deserialization risk starts with controlling what the parser is allowed to construct. The safest approach is to bind JSON to a narrowly defined schema or DTO, reject unexpected properties, avoid dynamic type resolution and remove features that let input influence class selection or object instantiation.
Where the language or framework offers unsafe defaults, teams should prefer explicit allowlists, safe constructors and hardened parser settings. In practice, remediation often means changing the object model as much as changing the code, because the vulnerable behaviour sits at the boundary between data and execution.
Teams should also review whether the application truly needs rich object deserialization at all. In many cases, simpler data-only structures reduce attack surface and make validation much easier to reason about.
Detection and Post-Exploitation Review
Because deserialization failures often surface as strange application behaviour, defenders should treat unexplained exceptions, parser errors, unexpected object states and unusual downstream logic as useful signals. Security review should also look for evidence that attacker-controlled input reached deserialization paths that were never intended for external use.
If exploitation is suspected, review whether the affected runtime could have created objects, loaded unexpected classes or executed gadget-like code paths before the patch or configuration change took effect. Post-patch review should confirm not only that the vulnerable code path is fixed, but that no follow-on compromise occurred through the same trust boundary.
Where credentials, session material or service-integrated secrets were reachable from the affected flow, rotate them if compromise is plausible. In practice, deserialization bugs are often investigated as application issues first, but they can become broader compromise events when the parsing path sits close to privileged state or trusted automation.
Risk and Threat Considerations
Unsafe JSON deserialization can turn a routine data-handling step into an execution boundary. The risk is greatest when untrusted input can influence object type, construction logic or downstream code paths, because that can lead to logic abuse, privilege-related side effects or, in some runtimes, code execution.
Failure mechanism: The parser accepts attacker-controlled JSON and converts it into objects whose type, shape or behaviour changes the application’s trusted state or invokes unintended logic.
Impact: The result can be application compromise, data tampering, session abuse, denial of service or a broader foothold if the deserialization path is tied to privileged internal components.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP ASVS, NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V1 — Encoding and Sanitization | JSON deserialization must validate and constrain attacker-controlled input structure. |
| V8 — Authorization | Unsafe deserialization can create object states that bypass application authorization logic. | |
| Recommendation — Enforce strict input validation and reject unexpected JSON fields or types. Verify that deserialized objects cannot alter authorization decisions or privileged state. | ||
| NIST SP 800-53 Rev 5 | SI-10 — Information Input Validation | Deserialization is a classic input-handling boundary that needs validation of structure and content. |
| SI-7 — Software, Firmware, and Information Integrity | Unsafe deserialization can undermine application integrity by allowing unintended object creation. | |
| Recommendation — Validate JSON inputs before object creation and reject malformed or unexpected data. Use integrity checks and fail closed when deserialization behavior is uncertain. | ||
| CIS Controls v8 | CIS-16 — Application Software Security | Application-layer parsing weaknesses belong in secure design and testing of software controls. |
| Recommendation — Test and harden deserialization code paths as part of secure application development. | ||
Practitioner Guidance
Why practitioners should care: JSON deserialization is often treated as plumbing, but it is a security-sensitive boundary when the input comes from users, partners or other services. The safest design is usually the one that least resembles general-purpose object reconstruction.
Common misunderstanding: Many teams assume that JSON is inherently safe because it is text, when the real risk comes from what the runtime does with that text after parsing. A parser that creates rich objects from untrusted input can be far more dangerous than a simple data decoder.
Practitioner takeaway: Treat every deserialization path as a trust decision, and prefer explicit, constrained data models over automatic object materialisation.
Related resources from NHI Mgmt Group
- How should organisations compare raw JSON handling and eager object deserialization in workflow systems?
- Why does JSON serialization create deserialization risk when data moves between services?
- What is the difference between safe JSON parsing and unsafe deserialization?
- Why does unsafe JSON deserialization create such a serious risk in gateway and connector architectures?
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 November 3, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org