DedSec Security Research ·
Here is a hypothetical. A dynamic scan of three applications returns four results about deserialization.
The first is "Insecure deserialization (Python pickle), time-based", rated critical, on a Python service whose session cookie is base64. The scanner replaced the cookie with a pickle that calls time.sleep(3), and the response took three seconds. The team escalates it as remote code execution. The second, on another Python service, is informational: "Serialized object in cookie". The cookie decodes to bytes that begin 80 04 95, the start of a pickle, but the scanner notes that every active payload got the same 400 bad session as its random-bytes control, and the team closes it as noise. The third is "PHP object injection", rated high, because a malformed serialized string in a cookie produced unserialize(): Error at offset 29 of 39 bytes in a 200 response. The team searches its controllers for __wakeup, finds none, and closes it as "no gadget, not exploitable". The fourth is an old one. A scanner once flagged a pickle in a cookie, the team added an HMAC signature, every retest payload got 403 bad signature, and the finding was closed.
As in the earlier posts in this series, each decision rests on the finding's title and a belief about the application, not on what was observed and what that observation can prove. We rebuilt each situation in a lab. The three seconds in the first finding came from a handler that sleeps three seconds on any session it cannot parse, and that handler never unpickled anything: a harmless pickle and 48 random bytes took the same three seconds, and a real JSON session got a 200 in under five milliseconds. The second was the most serious of the four. Behind that identical 400 bad session, every code-running payload we sent did run: one made an HTTP request to our listener, one made two DNS queries, one wrote a file. The third was real too: a class the controllers never mention, loaded by the autoloader, ran its __wakeup and made an outbound request, and a class with a __destruct method deleted a file even though the handler rejected the object with a 400. And the fourth depends on one line of ordering. Where the signature was checked before unpickling, the bad-signature payload did nothing. Where it was checked after, the response was the same 403 bad signature and our listener had already received the callback.
This post is for whoever is holding an insecure deserialization finding from a dynamic scan, or a clean result they are about to rely on. It covers:
allowed_classes, PyYAML's loaders and data-only formats stopped in the lab, and where each stops workingIt is the twenty-first post in a series about confirming DAST findings. The earlier ones cover reflected XSS, SQL injection, OS command injection, Nuclei template matches, ffuf content discovery, path traversal, open redirect, SSRF through URL-fetch parameters, XXE, CRLF header injection, Host header injection, HTTP request smuggling, CORS misconfiguration, JWT validation, Arjun parameter discovery, server-side template injection, CSRF, GraphQL, NoSQL injection and file upload. Deserialization leans on three of them. Its strongest evidence is the callback from the out-of-band testing post. Its time-based evidence has the same weaknesses as in the SQL injection post. And a signed blob with a leaked key is the problem from the JWT post, with a more dangerous payload.
Sources, and how each was checked. We made the measurements below on our test machine on 12 November 2026, between 07:24 and 07:37 UTC. It runs Ubuntu 24.04.4 with two vCPUs of an AMD EPYC 9354P. Every server, listener and client ran as a non-root user inside a Linux network namespace whose only interface was loopback, with a private mount namespace in which /etc/resolv.conf pointed at a DNS listener on 127.0.0.1. Before each run that sent network traffic we saved an isolation check: the name example.com did not resolve and a TCP connection to 1.1.1.1 failed. The software was:
pickle module (default protocol 4), and PyYAML 6.0.1, all as already installed on the machine.Java was not on the machine, and we did not install it or fetch any exploit tool or gadget-chain generator. Everything about Java below is mechanism, from general knowledge, and is labelled as such.
The vulnerable handlers are deliberate lab constructs. The Python application has one route per behaviour: one that stores the request body without parsing it; and, reading the cookie, one that parses it as JSON; one that parses it as JSON and sleeps three seconds on failure, the way a login throttle does; one that unpickles it and returns the error text on failure; one that unpickles it and returns a fixed 400 bad session on any failure; two that unpickle through a restricted Unpickler, one allowlisting modules and one allowlisting exact names; two that verify an HMAC-SHA256 signature, one before unpickling and one after; and four that parse a POST body with PyYAML's unsafe_load, full_load, safe_load and load with no loader. The PHP application unserializes a cookie with no options, with allowed_classes set to one class, and with allowed_classes set to false, or parses it as JSON. It runs three times: with a lab gadget class defined, with it absent, and with it loadable only through an autoloader. No real application should ship any of these handlers. The scenario is hypothetical, the requests in the lab came from our own lab client, not from any scanner, and none of the numbers measures AppSecD or how any product tests for deserialization.
The primary sources named below are Python's documentation for the pickle module, PHP's manual page for unserialize(), the OWASP Deserialization Cheat Sheet, and MITRE's CWE-502, Deserialization of Untrusted Data. We did not re-fetch them for this post, so we paraphrase them rather than quote them. The one quotation in this post is the docstring of pickle.Unpickler.find_class, printed from Python 3.12.3 on the lab machine.
Serialization turns an object graph into bytes, and deserialization turns bytes back into objects. A data-only format such as JSON can only describe strings, numbers, booleans, null, lists and maps, so apart from parser resource exhaustion, the worst a hostile JSON document can do on its own is be a value the application did not expect. A native object format is different. Python's pickle, PHP's serialize(), Java's object serialization and .NET's binary formatters can name a class and ask for an instance of it. Pickle can also name any callable and ask for it to be called with arguments, which is how a pickle reconstructs objects that define __reduce__.
So the question a deserializer answers is not "what data is this?" but "what should I construct, and what code runs while I construct it?" In Python the answer can be any importable function. In PHP and Java it is any class the runtime can load, plus whatever that class does in its magic methods: __wakeup, __unserialize and __destruct in PHP, and readObject, readResolve and friends in Java. A gadget is a class whose existing code does something useful to an attacker when the deserializer or the garbage collector calls it. A gadget chain links several of them so that data in one object's fields flows into a dangerous call in another. CWE-502 describes the weakness. The OWASP cheat sheet's first recommendation is the one that removes it: do not deserialize untrusted data with a native object format at all.
That is why this finding is unusual among DAST findings. The vulnerability is the call to the deserializer with attacker bytes, but the impact depends entirely on what is loadable in that process. Two applications with the identical vulnerable line can be a remote code execution and a curiosity.
Before a scanner can test deserialization it has to notice a serialized value: in a cookie, a hidden form field, a header, a JSON string inside a JSON body, or a parameter. Most formats announce themselves in their first bytes, and because cookies and fields are usually base64, those bytes have a stable base64 form too. We serialized {"theme": "dark"} and some other values and recorded the prefixes:
| Format | First bytes | Base64 begins |
|---|---|---|
| Pickle protocol 0, no header (a dict begins) | (dp0 | KGRw |
| Pickle protocol 2 | 80 02 | gAJ |
| Pickle protocol 3 | 80 03 | gAN |
| Pickle protocol 4 (Python 3.12's default) | 80 04 95 | gASV |
| Pickle protocol 5 | 80 05 95 | gAWV |
PHP serialize() of an object | O:5:"Prefs" | Tzo |
PHP serialize() of an array | a:1:{ | YTo |
Java object stream, magic AC ED, version 00 05 | AC ED 00 05 | rO0AB |
| gzip, often wrapping any of the above | 1F 8B 08 | H4sI |
| JSON object, for contrast | {" | eyJ |
The Java row was computed from the four header bytes alone, not from a Java runtime. As general knowledge, not tested: a value beginning /wE is the usual sign of ASP.NET view state, and the /wEP we decoded is the bytes FF 01 0F; and the node-serialize package for Node.js marks functions with _$ND_FUNC$_ inside otherwise ordinary JSON, which is why that one does not look like a binary format at all.
Protocols 0 and 1 have no magic bytes at all: their first bytes depend on the object, so the absence of 80 0x does not rule out a pickle.
A pickle also tells you what it will do, in plain text. A pickle of os.system('id') at protocol 0 is cposix\nsystem\np0\n(Vid..., and at protocol 4 the bytes posix and system sit in the stream as length-prefixed strings. On Linux, Python records os.system under its real home, the posix module, which matters later because that is the name an allowlist sees.
How reliable is a prefix? We generated one million random 32-byte tokens, encoded each in standard base64, and counted how many began with each prefix. gA matched 241 and ey 269, close to the one in 4,096 that two base64 characters predict. The three-character prefixes matched a handful each: Tzo 5, gAS 3, rO0 2 and YTo 1. gASV, rO0AB and H4sI matched none. (This count ran on the host, not in the namespace, because it makes no network calls. An earlier run that encoded each token two ways double-counted, and we replaced it.) A busy application issues more than four thousand random tokens. A detector that wants to flag a pickle should decode the value and check the bytes, or at least use four or more base64 characters. Decoding is also how a triager should check the claim: decode it and look.
Recognition is passive and, on its own, proves only that the application hands a serialized value to the client. That is worth a finding on its own, because a value the client holds is a value the client can replace. But it says nothing yet about what happens when the server receives a different one.
An insecure deserialization finding is a claim about a chain, and each link has its own evidence.
We sent nine payloads to each of six routes of the Python application, 54 requests, each carrying a unique token:
{"theme": "dark"}.Prefs class, whose __setstate__ writes a line to the server's log.__reduce__ calls time.sleep(3).urllib.request.urlopen on our HTTP listener.socket.getaddrinfo on a unique name, so the only network traffic is a DNS lookup.os.system to write DESER-$((1336+1)) to a file. The file can only say DESER-1337 if a shell ran the arithmetic.eval on a short expression that fetches our listener.| Route | P0 | P1 | P2 sleep | P3 HTTP | P4 DNS | P5 shell | P6 eval | P7 truncated | P8 random |
|---|---|---|---|---|---|---|---|---|---|
| Store only | 200 | 200 | 200 | 200 | 200 | 200 | 200 | 200 | 200 |
| JSON | 500 | 500 | 500 | 500 | 500 | 500 | 500 | 500 | 500 |
| Pickle, verbose errors | 200 | 200, setstate | 500, 3.0 s, ran | 500, callback | 500, 2 DNS queries | 500, marker | 500, callback | 500 | 500 |
| Pickle, fixed 400 | 200 | 200, setstate | 400, 3.0 s, ran | 400, callback | 400, 2 DNS queries | 400, marker | 400, callback | 400 | 400 |
| Module allowlist | 200 | 200, setstate | 500, blocked | 500, blocked | 500, blocked | 500, blocked | 500, callback | 500 | 500 |
| Name allowlist | 200 | 200, setstate | 500, blocked | 500, blocked | 500, blocked | 500, blocked | 500, blocked | 500 | 500 |
What each row proves:
A 200 proves acceptance and nothing else. The store-only route answered {"ok": true} to all nine payloads, including the shell and callback payloads, and nothing ran. A scanner that reports deserialization because an endpoint accepted a pickle without complaint is reporting the first fact.
An error proves parsing only if it is the deserializer's error. The JSON route answered all nine with a 500. The body was Python's UnicodeDecodeError, because the bytes were not text. That is an error on serialized input, and it proves nothing about pickle: nothing on that route can run a pickle. The verbose pickle route was different. P7 produced UnpicklingError: pickle data was truncated, and P8 produced UnpicklingError: unpickling stack underflow. Those messages come from the unpickler, so they prove the second fact. In the restricted routes, the random-bytes message was invalid load key followed by the first byte, so the exact text varies with the input. A scanner matching one error string will miss the others.
The type name in an error shows what the unpickler produced. Four of the five code payloads on the verbose route got a 500 that named the type the unpickler had produced: TypeError: session is not a dict or Prefs: HTTPResponse for P3 and P6, int for P5 (the exit status of os.system) and NoneType for P2. The callable had already run by the time the application looked at the result. The fifth, P4, surfaced the callable's own exception, gaierror: [Errno -2] Name or service not known, which shows the call was made. On the allowlist routes the errors named the blocked global: global time.sleep is forbidden, global urllib.request.urlopen is forbidden, global posix.system is forbidden. That message proves the unpickler parsed the stream and reached the lookup, and also tells an attacker that a filter exists and how it names things.
The application's own class was instantiated on every pickle route it was sent to. P1 caused exactly one Prefs.__setstate__ log line on each of the four unpickling routes, including both allowlists, because Prefs was allowed on both. That evidence lives in the server's log, not in the response. A scanner cannot see it unless the class's side effect is something it can observe.
And the fixed-400 route hid all of it. On the route that answers every failure with 400 bad session, P2 to P8 got the identical response body, and the eleven bytes bad session are all the scanner received. Yet P2 took three seconds, P3 and P6 each called our HTTP listener, P4 made two DNS queries, and P5's file contained DESER-1337. That is the second finding in the opening scenario. A scanner that compares responses against a random-bytes control sees no difference, because the code ran and then the application rejected the result with the same message it uses for garbage. Response comparison cannot confirm deserialization on a handler like this. Only an effect outside the response can.
The strongest evidence is a request the payload makes to infrastructure the tester controls, carrying a token unique to that attempt. In the lab the HTTP callbacks arrived at the listener with the token in the path, about as fast as the request that triggered them: P3's whole round trip on the verbose route took 0.036 seconds, callback included.
DNS is the narrower channel and often the more useful one. P4 made no HTTP request at all. It asked the system resolver for dns-<token>.oob.lab.test, and our DNS listener logged two queries for that name, an A record and an AAAA record, on both pickle routes. So one payload produced two hits, and a scanner that counts hits rather than distinct tokens will double-count. The DNS answer was NXDOMAIN, the payload raised gaierror, and the evidence had already been delivered. In a real network, as general mechanism, that lookup travels through whatever resolvers the target uses, so egress filtering that blocks outbound HTTP does not necessarily stop it. That is why an out-of-band listener should accept DNS as well as HTTP.
Two limits, the same as in the out-of-band post. A callback proves that something on the target ran code that contacted you, and it identifies which request did so only if the token is unique per attempt. It also proves nothing about privilege: P5's file was owned by the unprivileged lab user the server ran as. And absence of a callback is weak evidence. The payload might have run in a process with no network, or under a filter, or not at all, and those three look the same from outside.
P2 calls time.sleep(3). On the fixed-400 route, five runs took between 3.0012 and 3.0020 seconds, against a median of 0.0010 seconds for the harmless pickle and 0.0016 seconds for random bytes. On the name-allowlist route, where time.sleep is blocked, five runs of P2 had a median of 0.0009 seconds. In a quiet lab the signal is clean.
The first finding in the opening scenario is why a delay alone is not enough. The lab's /json-backoff route parses JSON and sleeps three seconds whenever parsing fails, the way an application might slow down repeated bad sessions or failed logins. It never unpickles anything. Over five runs each:
{"theme": "dark"}: 200 hello dark in 0.0011 to 0.0043 secondsA scanner that sends the sleep payload and a valid baseline sees a three-second difference. A scanner that also sends a control payload the application cannot parse sees no difference, because the delay belongs to the parse failure, not to the payload. The control that exposes the false positive is a payload of the same kind that does not sleep. P0 and P8 both serve. A delay that scales with the requested sleep, for example two seconds when asked for two and five when asked for five, is a stronger test still. We did not run that variation.
Time-based evidence has the other usual weaknesses as well: network jitter, queues, rate limiting and load all add delay. And on a handler where the payload runs in a background job, the response may return before the sleep starts. We did not measure either effect here.
Errors are the weakest of the three, for reasons the lab showed in both languages.
Python's verbose route proved parsing with unpickler-specific messages, and the fixed-400 route proved nothing because every failure looked the same. Between those two is the common case, a generic 500 page, where the status alone says only that something failed.
PHP produced a stranger result. The third finding's payload, O:5:"Prefs":1:{s:5:"theme";s:9:"dark";}, declares a nine-character string with four characters in it. With display_errors on, PHP 8.3.6 printed Warning: unserialize(): Error at offset 29 of 39 bytes. That message proves unserialize() read the cookie, which is the second fact. But the response status was 200, not the 400 the handler sets on a bad session. The body continued with a second warning: http_response_code(): Cannot set response code - headers already sent. The first warning had already been written as output, so the headers had gone and the status could not change. A scanner that keys on status codes would have classified this response as success. A scanner that keys on the warning text would have found it only because display_errors was on, which it should not be in production. With it off, as general PHP behaviour not tested here, unserialize() returns false and the application decides what the client sees.
The PHP JSON route answered all six of our PHP payloads with 400 bad session: NULL, because json_decode returned null. Same status, same body, no deserializer involved.
In Python, pickle needs no gadget hunt. find_class is the method that turns a module and name in the stream into a Python object, and its docstring in Python 3.12.3 says: "Return an object from a specified module. If necessary, the module will be imported." Any importable callable is reachable, and the standard library is importable in practically every Python process, which is why P3 to P6 used nothing but the standard library. Python's own documentation warns that pickle is not secure and that only trusted data should be unpickled.
PHP and Java are different, because unserialize() and readObject() construct objects and call their magic methods but do not call arbitrary functions. The attacker needs a class that is loadable in the target process and whose magic methods do something useful with fields the attacker controls. We built two minimal lab gadgets in PHP:
CacheWarmer: its __wakeup fetches the URL in its url property.TempFile: its __destruct deletes the file named in its path property.Six payloads went to four routes on three copies of the application, 72 requests in all. On the route with no options:
| Payload | Gadget defined | Gadget absent | Gadget via autoloader |
|---|---|---|---|
CacheWarmer alone | 400 bad session: CacheWarmer, callback | 400 bad session: __PHP_Incomplete_Class, no callback | 400 bad session: CacheWarmer, autoloader called, callback |
CacheWarmer inside an array next to a valid theme | 200 hello dark, callback | 200 hello dark, no callback | 200 hello dark, autoloader called, callback |
TempFile pointing at a lab file | 400 bad session: TempFile, file deleted | 400, file deleted (TempFile is defined in every copy) | 400, file deleted |
Four things follow from that table.
The same payload was a hit on one deployment and nothing on another. With CacheWarmer absent, PHP built a __PHP_Incomplete_Class and ran nothing, and the response told us so. That is not evidence that the application is safe. It is evidence that this one gadget is not loadable, and the TempFile row in the same column deleted a file. A scanner's deserialization payloads are a fixed list of guesses about which classes the target has, and a clean result from them is a statement about that list.
A class the controllers never mention can still be a gadget. In the autoload copy, CacheWarmer was defined in a file that only an autoloader registered with spl_autoload_register would load. unserialize() asked the autoloader for it, the autoloader loaded it, and its __wakeup ran. That is the third finding in the opening scenario: searching your own controllers for __wakeup searches the wrong place. In a real PHP application, as general mechanism, the autoloader can load every class in every installed dependency, and that is where published gadget chains are found. PHP's manual for unserialize() warns against passing it untrusted input for exactly this reason, because object instantiation and autoloading can execute code.
Rejecting the object afterwards does not undo it. The handler checked the result's type and answered bad session: TempFile with a 400, and TempFile's destructor deleted our lab file anyway. __wakeup runs during deserialization, before the application's type check, and __destruct runs when the object is freed, at the latest when the request ends, so rejecting the object prevents neither.
The response can look perfectly normal. The nested payload put CacheWarmer beside a valid theme field. The application read theme, answered 200 hello dark, and the callback arrived. Nothing in the response distinguishes it from a legitimate session.
Java follows the same logic with a larger cast, and we describe it as mechanism only, from general knowledge, because there was no JDK in the lab. ObjectInputStream.readObject() reads the class name from the stream, loads it from the classpath and calls its readObject method if it has one. Published chains link readObject, hashCode, compareTo or toString calls through collection and utility classes in common libraries until one of them invokes something dangerous. Whether a given chain works depends on which library versions are on that application's classpath. So the Java form of the PHP table above is a matrix of chains against classpaths, and a clean scan means that no chain in the scanner's list matched this classpath. Java's answer to that, ObjectInputFilter (JEP 290), is covered with the defences below.
A common response to a serialized value in a cookie is to sign it, so that the client cannot change it. The lab's two signed routes verify an HMAC-SHA256 over the pickle bytes:
| Route | Payload | Response | Callback |
|---|---|---|---|
| Verify, then unpickle | harmless pickle, valid signature | 200 hello dark | - |
| Verify, then unpickle | callback pickle, wrong signature | 403 bad signature | none |
| Unpickle, then verify | callback pickle, wrong signature | 403 bad signature | received |
| Verify, then unpickle | callback pickle, signed with the leaked key | 500 TypeError ... HTTPResponse | received |
Order is everything, and the response does not show it. Both routes answered the forged cookie with an identical 403 bad signature. On one of them the payload had already run. That is the fourth finding in the opening scenario, and a retest that reads the 403 and closes the finding is reading the wrong evidence. The only lab evidence that told the two apart was the callback.
A signature moves the problem to the key. When the payload was signed with the application's key, verification passed and the callback arrived. A key in source control, an environment file, a CI log or a container image turns the signed cookie back into an unsigned one, with every deserialization consequence intact. That is why a leaked signing key is more serious in an application that signs serialized objects than in one that signs plain data. The secrets in git history post covers why deleting such a key in a later commit does not remove it. As general knowledge, not tested here: ASP.NET's view state MAC and machine key follow the same pattern, so a leaked machine key is a deserialization finding as well as a disclosure.
A signature is integrity, not safety. It limits who can hand the deserializer bytes. It does nothing about what the deserializer does with them.
A data-only format. The Python JSON route received all nine pickle payloads and the PHP JSON route all six PHP payloads, on all three copies of the application, and they ran none of them. That is the OWASP cheat sheet's first recommendation, and in the lab it was the only defence under which no class was looked up or constructed at all. The name allowlist and allowed_classes also stopped every gadget we sent, but they still constructed the classes they allowed. The caveat, as general mechanism: a JSON library that lets the document name a type to construct, sometimes called polymorphic typing, turns JSON back into an object format, with the same gadget problem. Data-only means the parser cannot construct anything you did not ask for.
A restricted Unpickler that allowlists exact names. Python's pickle documentation describes overriding find_class to restrict which globals a pickle may load. Our name allowlist allowed labapp.Prefs, builtins.set, builtins.frozenset and collections.OrderedDict. It blocked all five code-running payloads, including builtins.eval.
A restricted Unpickler that allowlists modules. Our module allowlist allowed anything from builtins, collections and the application's module. It blocked time.sleep, urllib.request.urlopen, socket.getaddrinfo and posix.system, and let P6 through, because eval lives in builtins. P6 called our listener. Allowlisting a module is not allowlisting what is in it.
Both allowlists ran the allowed class's code. Prefs.__setstate__ ran on both. An allowlist is only as safe as the magic methods of the classes on it. Ours only logs, but a __setstate__ or __reduce__ that opens a path or a URL from its state would be a gadget that the allowlist explicitly permits.
PHP's allowed_classes. With ['allowed_classes' => ['Prefs']], CacheWarmer and TempFile both became __PHP_Incomplete_Class on all three copies of the application, no callback arrived, and no file was deleted. In the autoload copy the autoloader was not called at all, which matters, because autoloading a class can itself run code. The nested CacheWarmer was neutralised as well, while the array around it still produced 200 hello dark. With allowed_classes set to false, the application's own Prefs also became an incomplete class and that session was refused with a 400. So false is the setting for code that only ever stores arrays and scalars. The limits are the same as for the Python allowlist: allowed classes still run their magic methods. As general knowledge, PHP's manual recommends against passing untrusted input to unserialize() whatever allowed_classes says, and recommends JSON instead.
PyYAML's loaders. A YAML document can carry a !!python/object/apply tag that calls a function. In PyYAML 6.0.1, unsafe_load called urllib.request.urlopen on our listener and returned parsed HTTPResponse with a 200. full_load and safe_load both refused the tag with ConstructorError: could not determine a constructor for the tag, and plain YAML still parsed. yaml.load with no Loader argument raised TypeError: load() missing 1 required positional argument: 'Loader', so in this version the unsafe choice has to be written out by name. We did not test older PyYAML versions.
Java's ObjectInputFilter, mechanism only. As general knowledge, not tested: JEP 290 added a filter interface that ObjectInputStream consults for each class, along with array sizes, graph depth and reference counts, before it constructs the object. It can be set per stream in code or for the whole process with the jdk.serialFilter system property. An allowlist filter that names the expected classes and rejects everything else (!*) is the Java counterpart of our name allowlist. It has the same limit: allowed classes still run their readObject.
Signatures. Covered above. They held when checked first and the key was secret, and failed when either of those was false.
pickle data was truncated or unserialize(): Error at offset, which a generic error does not prove.bad session: CacheWarmer versus __PHP_Incomplete_Class, shows whether a named class was loadable. The impact is whatever that class's magic methods do, so the finding should name the gadget it used.And the false positives:
UnicodeDecodeError or PHP's json_decode null. Exposed by reading which component produced the error.This is general practice. It needs authorisation for the target, payloads whose effects are harmless and attributable, and cleanup afterwards. Do not use destructive gadgets against a target you do not own. Our TempFile test deleted a lab file created for the purpose.
All of this is general practice, except where it says it was measured.
find_class and allow (module, name) pairs. Our name allowlist blocked every code payload, while our module allowlist let eval through. In PHP, pass allowed_classes with the classes you expect, or false for arrays and scalars. In the lab it stopped both gadgets and the autoloader call. In Java, configure an ObjectInputFilter that names the expected classes and rejects the rest.Prefs.__setstate__ ran under both allowlists.safe_load. unsafe_load ran our payload, and safe_load and full_load refused it in PyYAML 6.0.1.display_errors also changed the status code here.Deserialization is unusually visible in source. The sink is a named call: pickle.loads, pickle.load, yaml.unsafe_load or yaml.load with an unsafe loader, PHP's unserialize without allowed_classes, Java's ObjectInputStream.readObject, or a binary formatter's Deserialize. A static rule can find all of those. Taint analysis can then ask whether the argument comes from a request. In the lab every cookie route reached the sink through a base64 decode, so a rule that loses taint through base64.urlsafe_b64decode or base64_decode would miss them all. That is the problem from the SAST false-positive post in reverse: a sanitiser credited where there is none, or a transformation that drops the taint.
What a static rule sees less well is the impact. Whether a readObject or an unserialize is a remote code execution depends on what is on the classpath or reachable by the autoloader in the deployed build, which is a property of the dependency tree, not of the line of code. Whether a restricted find_class is safe depends on what it allows, and the module allowlist in this lab looks like a defence until you notice builtins.eval. And a static view cannot tell whether a signature check happens before the parse unless it models the order of the two calls on every path. We did not run a static rule against the lab.
ObjectInputStream, gadget chains and ObjectInputFilter is mechanism from general knowledge.Marshal, YAML), or Node.js serializer. The view-state prefix and the node-serialize marker are general knowledge.unserialize(). Not PHP's phar:// deserialization through file functions, __unserialize, or published gadget chains in real frameworks.display_errors off, and not memory or CPU exhaustion through deeply nested or very large serialized graphs.Back to the four findings.
Time-based pickle deserialization, escalated as remote code execution. False positive. In the lab's version of this endpoint the delay came from a three-second throttle on any session that failed to parse as JSON. The harmless pickle and random bytes took the same three seconds, and a real JSON session got a 200 in milliseconds. It was closed, with a note that a time-based finding needs a non-sleeping control.
Serialized object in cookie, closed as noise. True positive, and the most serious of the four. Behind an identical 400 bad session, the callback, DNS, shell-marker and eval payloads all ran. It was reopened as code execution. The fix is to stop unpickling the cookie, and the retest has to listen out of band, because the response will look the same before and after.
PHP object injection, closed as "no gadget". True positive. The warning proved unserialize() read the cookie, and the 200 was an artefact of display_errors. A class loaded only by the autoloader ran its __wakeup and called out, and a class with a __destruct deleted a file behind a 400. It was reopened, with allowed_classes as the immediate change and JSON as the fix. In the lab, allowed_classes stopped both gadgets and the autoload.
The signed cookie. Depends on one line. If the code verifies before it unpickles, the 403 means what it says, and the remaining question is where the key has been. If it unpickles first, the finding was never fixed, and the 403 is the same one the lab returned while our listener logged the callback. It was reopened until a bad-signature out-of-band payload produces no callback.
AppSecD's dynamic and API testing runs Nuclei, Dalfox, SQLMap, Commix, Katana, Arjun, FFuf and Interactsh for out-of-band detection, plus 150+ native checks and API discovery across 50+ web frameworks. Its static analysis runs Semgrep as the primary engine alongside Bandit, gosec, ESLint security, Brakeman, PHPStan/Psalm and SpotBugs with FindSecBugs across 20+ languages. Those lines, and the shorter mentions of the same capabilities elsewhere in data/products.ts, are what that file says about them. None of them mentions deserialization, pickle, unserialize, gadget chains or ObjectInputFilter, so this post does not claim AppSecD tests for any of it. The measurements, the confirmation procedure, the fixes and the checklist above are general practice that applies to any scanner's output, ours included.
The scenario in this post is hypothetical and does not describe any deployment, user or finding.