Allowed classes restriction is a deserialisation control that limits which object classes a parser may instantiate from input. It works by using an allowlist of approved classes and rejecting everything else, reducing the risk of unsafe object creation, gadget-chain abuse, and remote code execution during deserialisation.
How allowed classes restriction works
Allowed classes restriction narrows deserialisation to a defined set of object types, so the parser can only instantiate classes that have already been approved. That shifts deserialisation from a permissive object-construction step to a controlled validation step, which is especially important in languages and frameworks that support polymorphic or native object serialisation.
Conceptually, it is an allowlist around object creation. Instead of trusting whatever class name arrives in the payload, the parser compares it against permitted classes and rejects anything outside that boundary. That simple control is often the difference between harmless data handling and arbitrary object instantiation.
When teams implement this well, they are not just filtering names, they are constraining the object graph the application is willing to reconstruct. That matters because deserialisation bugs often emerge from “surprising” classes that carry behaviour, side effects, or implicit hooks that the application never intended to expose.
Why it reduces unsafe object creation
Unsafe deserialisation becomes dangerous when input can drive the runtime into creating objects with attacker-influenced behaviour. An allowlist blocks unknown classes before they can participate in that process, which reduces the chance of gadget-chain abuse, type confusion, or unexpected code paths being triggered during object materialisation.
This is most valuable in ecosystems with a rich classpath or broad runtime libraries, because a large available class set increases the odds that an attacker can find a useful gadget sequence. Allowed classes restriction does not make deserialisation “safe” by itself, but it removes one of the most powerful primitives: the ability to instantiate arbitrary types from untrusted input.
It also helps separate data from executable structure. The more a format allows the sender to decide which classes exist in the reconstructed object graph, the more the application exposes itself to logic buried inside constructors, setters, custom read methods, or framework-specific type handlers.
Where this control fits in a secure deserialisation design
Allowed classes restriction is a defensive boundary, not a substitute for safer formats. It works best when paired with minimal type exposure, versioned schemas, and parser settings that fail closed by default. A narrow allowlist is stronger than a long blacklist, because new gadget classes and framework updates can quickly make deny-based controls obsolete.
The control should be applied close to the parsing boundary, where untrusted input first becomes an object. If validation happens too late, the runtime may already have created dangerous intermediary objects or executed conversion logic that cannot be undone.
For teams modernising legacy systems, this control is often a pragmatic bridge. It can reduce exposure while longer-term changes, such as moving away from insecure native serialisation patterns, are being completed.
Operational consequences when the allowlist is too broad
A permissive allowlist weakens the whole control. If it includes classes with dangerous deserialisation hooks, broad framework base types, or objects that can reach sensitive functionality, the parser may still accept payloads that reintroduce the original attack surface. In practice, the risk is not just “too many classes”, but “the wrong classes”.
That is why class approval should be tied to actual application requirements, not convenience. Every extra class expands the reachable object graph and increases review burden, especially when libraries change over time and previously benign types gain new behaviour.
In mature environments, this control is usually treated as part of secure input handling and application hardening, rather than as a niche serialisation setting. If the parser can construct the wrong object, the rest of the application may inherit that mistake immediately.
Risk and Threat Considerations
Allowed classes restriction is designed to stop deserialisation abuse before the parser can build attacker-controlled objects. If the allowlist is missing, overly broad, or bypassed through a permissive parser path, an attacker may be able to reach gadget chains that convert a data-handling flaw into remote code execution or other high-impact compromise.
Failure mechanism: The attacker supplies a payload that names or references a class the application should never instantiate, then relies on library behaviour, nested objects, or deserialisation hooks to trigger unsafe code paths during reconstruction.
Impact: Successful abuse can lead to arbitrary object creation, server-side execution of unintended logic, privilege abuse inside the application process, and in some cases full remote code execution, depending on the runtime and available gadgets.
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 NIST SP 800-53 Rev 5, OWASP ASVS and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | SI-10 — Information Input Validation | Deserialisation controls validate untrusted input before object creation. |
| Recommendation — Validate serialized input against an allowlist before objects are instantiated. | ||
| OWASP ASVS | V1 — Encoding and Sanitization | Allowed classes restriction constrains unsafe input handling at the parser boundary. |
| Recommendation — Sanitize and constrain inbound serialized data before parsing it into objects. | ||
| CIS Controls v8 | CIS-16 — Application Software Security | Safe deserialisation is an application hardening concern that reduces exploitability. |
| Recommendation — Harden application parsers so untrusted input cannot create unsafe objects. | ||
| MITRE ATT&CK | T1068 — Exploitation for Privilege Escalation | Unsafe deserialisation can be used to obtain higher execution authority on the host. |
| Recommendation — Map deserialisation exploitation to privilege-escalation detections and containment. | ||
Practitioner Guidance
Why practitioners should care: This control is only effective when the approved class set is deliberately small, explicitly owned, and reviewed as the application changes. Treat it as a living policy boundary, not a one-time configuration choice.
What to watch for: Review parser defaults, framework upgrades, and any fallback code paths that may re-enable polymorphic type resolution or bypass the allowlist. If a deserialisation library can still instantiate classes outside the intended contract, the control is not really in force.
Use Secure Deserialisation Guide for the wider hardening pattern, including fail-closed loader settings, language-specific filters, and metrics for spotting unsafe object loading.
Related resources from NHI Mgmt Group
- Should organisations prioritise discovery or access restriction first for shadow AI?
- What breaks when autonomous shopping agents are allowed to act without strong governance?
- What breaks when support workflows are allowed to influence production access?
- What breaks when agents are allowed to keep retrying until they succeed?
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 16, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org