Home / Knowledge hub / Object injection
Knowledge hub
Object injection
Supplying crafted serialised data so your app builds objects the attacker designed.
What it means
Serialisation turns an object in memory into text or bytes so it can be stored or sent, and deserialisation turns it back into an object. Object injection is what happens when an attacker controls that data, so your app rebuilds objects they designed, with values they chose.
The danger is that rebuilding an object can run code. Some classes do work automatically when they are created, changed or destroyed. By picking which classes appear and what they hold, an attacker can steer that work toward something your developers never intended.
Why it matters
The worst outcome is remote code execution, where the attacker runs commands on your server. Lesser outcomes include deleting files, reading data, bypassing a sign-in check or crashing the service. Because the payload looks like ordinary data, it can pass checks that look only for obvious attack strings.
It is one of the main ways the broader weakness of insecure deserialisation turns into a real break-in. It matters most in older code, plugins and anything that accepts a serialised value from a cookie, form field or API. Updating libraries is part of the defence, since attacks reuse classes they already contain.
How it shows up
You meet it where an app reads a serialised object from a place the user controls: a cookie that stores a session object, a hidden field, a message queue, a cache entry or an uploaded file. PHP, Java, .NET and Python all have native formats that can be abused when they accept untrusted data.
The safest fix is not to deserialise untrusted data in those native formats at all. Use plain data formats such as JSON with a fixed schema, sign and verify any value you must round-trip through the client, and keep libraries patched, since attacks often chain classes already present in them.
Questions people ask
Object injection, answered
Is object injection the same as insecure deserialisation?
Very close. Insecure deserialisation is the broader weakness of trusting serialised data. Object injection is the specific attack of feeding in crafted objects to exploit it.
Many sources use the two names for the same problem.
What is a gadget chain?
It is a sequence of existing classes in your application or its libraries that, when linked by crafted data, ends in something harmful such as running a command. The attacker writes no code of their own; they reuse yours.
Updating libraries removes known chains.
Does using JSON make us safe?
Plain JSON parsed into simple data is far safer, since it does not rebuild arbitrary classes. Some JSON libraries can be set to create objects of a named type, and that setting reintroduces the risk.
Check your parser configuration.
Does signing the data help?
Yes, if the signing key is secret and you verify the signature before deserialising. Then the client cannot change the data. It does not help if the key leaks or if verification happens after rebuilding.
Verify first.
How do we test for it?
Look for serialised values in cookies, fields and API bodies, change them in harmless ways and see how the app responds. Review code for calls that deserialise input from outside.
A proof is a safe, visible effect, not damage.
Sources
Where this comes from
Related
Terms that sit next to this one
Insecure deserialisation
Turning data from outside back into live objects without checking it.
Remote code execution
Getting a server to run commands of an attacker's choosing.
Untrusted input
Anything that arrived from outside your own code, and is therefore suspect.
Known-vulnerable component
A library or runtime with a published flaw that you are still shipping.
Injection
Input that ends up running as a command instead of being read as text.
What does your app rebuild from input?
In white-box mode we read the code that deserialises data, then prove or rule out a path to it in the running app, with the file and line. Ask us to run it on one of your applications.
Or start with a $199 pilot on one application: thirty days, success criteria agreed before day one, credited against the annual if you convert.