Object injection occurs when an application accepts input that influences which objects or classes are created or referenced at runtime. In secure code, the caller should control data values, not the shape of server-side objects or the paths used to build them.
Expanded Definition
Object injection is a runtime trust failure: the application lets external input influence which object, class, or constructor path is instantiated, referenced, or rehydrated. In NHI and application security work, it sits at the boundary between data parsing and code execution, where seemingly harmless values can redirect control flow. Definitions vary across vendors and languages, because the same flaw may appear in deserialisation, dependency resolution, reflection, or object mappers, but the core issue is the same: untrusted input affects object shape or identity instead of remaining data. That distinction matters because a safe API call can become dangerous if the caller can select privileged classes, trigger side effects, or reach sensitive methods. Standards guidance is usually expressed through least privilege, input validation, and secure deserialisation controls rather than a single object injection definition, so practitioners often map the issue to broader control frameworks such as the NIST Cybersecurity Framework 2.0 and secure coding guidance.
The most common misapplication is treating object injection as simple input validation alone, which occurs when teams sanitise values but still allow attackers to choose the object type, class name, or deserialisation path.
Examples and Use Cases
Implementing protections against object injection rigorously often adds friction to dynamic frameworks, requiring teams to weigh developer convenience against the safety of explicit type controls and allowlists.
- A web API accepts a class name in JSON and uses reflection to instantiate that class, letting an attacker reach admin-only code paths.
- A queue consumer deserialises messages into server objects without a strict allowlist, so a crafted payload triggers unexpected methods during object creation.
- A configuration service allows clients to influence which dependency object is loaded, and the selected object carries privileged filesystem or network access.
- A legacy session store restores objects directly from untrusted tokens, making state reconstruction vulnerable to attacker-controlled class references.
- An agent workflow plugin system accepts externally supplied tool objects, so an invalidly governed object reference can expand the agent’s execution authority.
These patterns are especially dangerous when object construction is tied to secrets handling, service account use, or backend automation. The Ultimate Guide to NHIs shows how brittle NHI operations become when credentials, rotation, and visibility are weak, and object injection can turn that fragility into direct abuse of privileged runtime paths. In practice, the safest designs make object selection server-controlled, keep external input as plain data, and reject any untrusted class or type references before parsing begins. The same discipline aligns with the NIST Cybersecurity Framework 2.0 emphasis on access control, secure design, and governance of risky inputs.
Why It Matters in NHI Security
Object injection matters in NHI security because the affected object is often not a user record but a service principal, API client, automation worker, or agent component with real execution authority. Once an attacker can influence object selection, they may pivot from data tampering to credential exposure, privilege escalation, or unsafe tool invocation. This is where NHI governance becomes concrete: compromised object graphs can expose tokens, move through internal APIs, and bypass intended trust boundaries. NHIMG research shows that 96% of organisations store secrets outside of secrets managers in vulnerable locations including code, config files, and CI/CD tools, which makes runtime object abuse even more damaging when injected objects can reach those stores. That same research also reports that 97% of NHIs carry excessive privileges, amplifying the blast radius when an injected object inherits broad permissions. Defences must therefore combine secure parsing, strict type allowlists, secret isolation, and least-privilege runtime design.
Organisations typically encounter object injection only after a deserialisation incident, unexpected class loading, or agent tool misuse exposes privileged behaviour, at which point the term becomes operationally unavoidable to address.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 and OWASP Agentic AI Top 10 address the attack and risk surface, while NIST CSF 2.0, NIST Zero Trust (SP 800-207) and NIST AI RMF set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-01 | Object injection can redirect NHI runtime paths into unsafe object creation and privilege misuse. |
| OWASP Agentic AI Top 10 | AGENT-03 | Agentic systems can be subverted when input controls which tool or object an agent loads. |
| NIST CSF 2.0 | PR.AC-4 | Least-privilege access control is undermined when untrusted input selects privileged objects. |
| NIST Zero Trust (SP 800-207) | SC-3 | Zero Trust requires explicit trust decisions, not attacker-chosen object references. |
| NIST AI RMF | AI systems inherit risk when external inputs alter object graphs or execution components. |
Restrict object construction to server-approved types and block attacker influence over class selection.