Skip to content
RCE Write-up Advanced

The Unsigned Form Field That Ran Code on PayPal

A PayPal business site accepted an unsigned, base64-encoded Java serialized object from the browser and deserialized it, allowing an attacker to supply a malicious object graph. The researcher confirmed command execution with an out-of-band callback and read a system file, with potential access to production databases.

medium.com

Published on medium.com

Bug Bounty

Muhammad Asim Shahzad, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

manager.paypal.com is a PayPal business-facing web application. In December 2015, Michael Stepankin found that one of its forms carried server-side state to the browser in a hidden field and accepted it back on submission. The field held a base64-encoded Java serialised object, and the server deserialised it without any signature or integrity check. That turned a form field into a code input path, and Stepankin demonstrated remote code execution on the web servers, with, as he notes, access toward production databases behind the application.

AI-generated illustration From the original on medium.com

AI-generated illustration

The write-up is an analytical case study of that public disclosure, drafted with AI assistance. It deliberately omits reproduction details and payloads.

Setup

No accounts, roles, tools or versions are described. The precondition for the attack is the one that matters: the server must deserialise a client-supplied Java object, and the application's classpath must contain at least one class whose deserialisation hooks can be chained into dangerous behaviour.

That last condition was already public knowledge at the time. Chris Frohoff and Gabriel Lawrence had shown gadget chains in Apache Commons Collections, and a then-recent FoxGlove Security article had popularised the risk.

Finding it

While testing the application, Stepankin noticed a POST parameter that decoded into a complex binary structure. Decoding it showed a Java serialised object. Nothing in the request signed it: the browser held the object, and the server would rebuild whatever object graph a client sent.

That is the wrong shape for form state. A serialised Java object is not passive data. Deserialisation runs class-specific logic while reconstructing the object, so the bytes the client sends decide which classes get instantiated and which of their hooks run. If any library on the classpath contains a class whose hooks can be chained, the attacker supplies the graph and gets code execution.

Exploitation

Step 1: identify the parameter

A POST parameter in the form decoded from base64 into a Java serialised object. The report does not give the parameter name, the endpoint path or the request itself.

Step 2: confirm execution out of band

Stepankin confirmed command execution with a harmless out-of-band callback. The report does not include the payload or the callback mechanism.

Step 3: prove file access

He read a single system file as proof and stopped there. The report does not name the file or show the command.

Step 4: find the same pattern elsewhere

He later found other endpoints in the same application using serialised objects too. The report does not list them.

Root cause

The application used the client as a storage layer for server state and trusted it on the way back. The hidden field was unsigned, so the server had no way to tell its own object from one an attacker built. Because deserialisation executes class logic during reconstruction, the trust decision was effectively made on code, not data.

There was no signature over the field.

Impact

Code execution on payment-adjacent web servers is about as severe as web bugs get. Per the researcher, the foothold could reach production databases behind the application, risking merchant data, lateral movement and persistent backdoors inside a regulated environment.

Stepankin's report was marked duplicate: Mark Litchfield had reported a similar issue two days earlier. The researcher says PayPal paid a bounty despite the duplicate; no amount is given. PayPal fixed the issue promptly.

Fix

The remediation below is the author's own analysis.

  1. Keep state on the server. Send an opaque random ID to the client and look the state up server-side.
  2. If state must travel, use data formats, not object formats. JSON with a strict schema, signed with an HMAC, verified before any parsing.
  3. Where Java deserialisation is unavoidable, allowlist classes. Use a JEP 290 ObjectInputFilter that rejects everything not explicitly expected.
  4. Shrink the gadget surface. Inventory and upgrade libraries; alert on deserialisation exceptions.

The signed-state pattern, as sketched in the article:

Python
SERVER_KEY = load_secret("form_state_hmac_key")
Python
def issue_form_state(data: dict) -> str:    body = b64url(json_dumps(data, sort_keys=True))    mac = hmac_sha256(SERVER_KEY, body)    return body + "." + b64url(mac)def read_form_state(token: str) -> dict:    try:        body, mac = token.rsplit(".", 1)    except ValueError:        raise Rejected("malformed state")    if not constant_time_equal(b64url_decode(mac), hmac_sha256(SERVER_KEY, body)):        raise Rejected("tampered state")          # check before parsing    data = json_loads(b64url_decode(body))        # plain data, no classes    return validate_schema(data, FORM_STATE_SCHEMA)

The important ordering is that the MAC is checked before the body is parsed, and the body is plain JSON validated against a schema, so no classes are instantiated from client input.

Variants to test

  • Hidden fields that decode to binary. Base64-decode every hidden form value and look for the Java serialisation magic bytes (AC ED) or other object-format markers. A positive result is a value that decodes to a serialised object the server accepts back.
  • Cookies and view state. The same pattern often appears in cookies, javax.faces.ViewState and similar state blobs. A positive result is a state value you can modify and have the server deserialise.
  • Other endpoints in the same application. Stepankin found more than one. Enumerate forms and APIs that round-trip state and test each, since a fix applied to one endpoint may not cover the rest.
  • Signature checks. Flip a byte in a signed-looking state value and see whether the server rejects it before parsing. A positive result is a server that parses first and fails later, or accepts the tampered value.
  • Classpath inventory. Where you have source or dependency access, look for libraries with known deserialisation gadgets, such as Apache Commons Collections. A positive result is a gadget library reachable from the deserialisation path.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 13 min read.

What happened, in plain words

In December 2015, a security researcher named Michael Stepankin found a serious flaw in manager.paypal.com, a PayPal website used by businesses. One of the forms on that site kept some information in a hidden field, a part of the page you cannot see but your browser still sends back when you submit the form. That hidden field contained a chunk of data that the server turned back into a live program object, and it did so without checking whether the data really came from PayPal or from someone else. Because of that, an attacker could put their own data in the field and make the server run commands. Stepankin showed he could run commands on PayPal's web servers, and he notes that this gave a path toward the production databases behind the application.

AI-generated illustration From the original on medium.com

AI-generated illustration

This article is an analytical case study of that public disclosure, drafted with AI assistance. It deliberately leaves out the details you would need to repeat the attack, and it contains no payloads.

Before going further, a few everyday comparisons will help.

  • A web server is the computer that holds a website and answers your browser's requests. Think of a restaurant kitchen: you order from the menu, the kitchen prepares the dish and sends it out.
  • A form is the part of a page where you type things and press a button to send them. The browser packages what you typed and sends it to the server.
  • A hidden field is a form field the page fills in for you and you never see. It is like a waiter writing your table number on the order slip: you do not write it, but it travels with your order.
  • An API is the set of addresses and rules a program uses to talk to a server, the way a menu tells you what you can order and how. When your browser submits a form, it is making a request to one of those addresses.
  • A cookie or token is a small piece of information the server gives your browser to hold on to, so the server can recognise you on the next request. It is like a coat-check ticket: you show it later and get your coat back.
  • Serialisation is turning a live object in a program's memory into a stream of bytes that can be stored or sent. Deserialisation is the reverse: turning those bytes back into a live object. Think of packing a piece of furniture into a flat box and then rebuilding it at the other end.
  • Remote code execution (RCE) means an attacker can make someone else's server run commands of the attacker's choosing. It is the difference between ordering from the menu and getting into the kitchen and cooking whatever you like.
  • Insecure deserialisation is the vulnerability class here: the server rebuilds an object from bytes supplied by the client without checking that the bytes are safe. The technical name for this class is CWE-502.

The setup

The report does not describe any accounts, roles, tools or software versions.

Two conditions had to be true for the attack to work, and the second one matters most:

  1. The server had to deserialise a Java object supplied by the client. Java is a programming language, and a Java object is a bundle of data plus the code that knows how to work with it.
  2. The application had to have, among all the code libraries it loads (its classpath, the list of places the program looks for code), at least one class whose deserialisation hooks can be chained into something dangerous. A class is a blueprint for objects in Java, and a hook is a piece of code the program runs automatically at a certain moment, here while an object is being rebuilt.

That second condition was already public knowledge at the time. Chris Frohoff and Gabriel Lawrence had shown gadget chains in a widely used library called Apache Commons Collections. A gadget chain is a sequence of otherwise ordinary pieces of code that, joined together, do something harmful, like a set of household objects that can be combined into a tool. A then-recent article by FoxGlove Security had popularised the risk.

Finding it

While testing the application, Stepankin noticed a POST parameter that decoded into a complex binary structure. A POST parameter is one of the named values your browser sends when you submit a form; POST is simply the type of request used for sending data rather than just asking for a page. Base64 is a way of writing arbitrary bytes using only ordinary text characters, so binary data can travel inside a form. When he decoded the value, it turned out to be a Java serialised object.

Nothing in the request signed it. A signature here means a cryptographic stamp that lets the server tell whether a value is exactly the one it issued and has not been changed. Without one, the browser held the object, and the server would rebuild whatever object graph a client sent. An object graph is the whole set of objects linked together inside one serialised blob.

That is the wrong shape for form state. Form state is the information a form needs to remember between steps, such as which page of a wizard you are on. A serialised Java object is not passive data. Deserialisation runs class-specific logic while reconstructing the object, so the bytes the client sends decide which classes get created and which of their hooks run. If any library on the classpath contains a class whose hooks can be chained, the attacker supplies the graph and gets code execution.

How the attack unfolded

Step 1: identify the parameter

A POST parameter in the form decoded from base64 into a Java serialised object. The report does not give the parameter name, the endpoint path or the request itself. The reason for this step is simple: before you can abuse a value, you have to notice that it is not ordinary text but a rebuilt program object.

Step 2: confirm execution out of band

Stepankin confirmed command execution with a harmless out-of-band callback. An out-of-band callback is a signal the server sends to a place the attacker controls, such as a request to a server the attacker runs, rather than a visible change on the page. It is a safe way to prove that code ran without damaging anything. The report does not include the payload or the callback mechanism.

Step 3: prove file access

He read a single system file as proof and stopped there. Reading a file the server was never meant to hand out shows that the attacker's code is running with the server's own permissions.

Step 4: find the same pattern elsewhere

He later found other endpoints in the same application using serialised objects too. An endpoint is one specific address the application answers on. The report does not list them. The reason to look further is that a mistake made once in a codebase is usually made in several places.

Why it worked

The application used the client as a storage layer for server state and trusted it on the way back. In other words, the server handed its own notes to the browser, let the browser hold them, and believed whatever came back. The hidden field was unsigned, so the server had no way to tell its own object from one an attacker built. Because deserialisation executes class logic during reconstruction, the trust decision was effectively made on code, not data.

There was no signature over the field. An HMAC is a keyed signature: a value computed with a secret key so that only someone holding the key can produce a valid stamp. An allowlist is a list of things that are permitted, with everything else refused.

Impact

Code execution on payment-adjacent web servers is about as severe as web bugs get. Per the researcher, the foothold could reach production databases behind the application, risking merchant data, lateral movement and persistent backdoors inside a regulated environment. Lateral movement means using one compromised machine to reach others. A backdoor is a way in that the attacker leaves behind so they can return later.

Stepankin's report was marked duplicate: Mark Litchfield had reported a similar issue two days earlier. A duplicate is a report of a bug that has already been reported. The researcher says PayPal paid a bounty despite the duplicate; no amount is given. A bounty is a reward a company pays for a valid security report. PayPal fixed the issue promptly.

The fix

The remediation below is the author's own analysis, not a description of what PayPal did.

  1. Keep state on the server. Send an opaque random ID to the client and look the state up server-side. An opaque ID is a meaningless string, like a claim ticket number, that tells the server which stored record to fetch. The client never sees or edits the record itself.
  2. If state must travel, use data formats, not object formats. JSON with a strict schema, signed with an HMAC, verified before any parsing. JSON is a plain text format for data, with no code attached. A schema is a description of which fields are allowed and what type each one has.
  3. Where Java deserialisation is unavoidable, allowlist classes. Use a JEP 290 ObjectInputFilter that rejects everything not explicitly expected. JEP 290 is a Java feature that lets a program restrict which classes may be deserialised.
  4. Shrink the gadget surface. Inventory and upgrade libraries; alert on deserialisation exceptions. The gadget surface is the set of libraries that could supply a dangerous chain; fewer and newer libraries mean less to exploit.

The signed-state pattern, as sketched in the article:

Python
SERVER_KEY = load_secret("form_state_hmac_key")

This line loads the secret key used to sign form state, from a secret store rather than from the code itself. The key is what makes the signature impossible for an outsider to forge.

Python
def issue_form_state(data: dict) -> str:    body = b64url(json_dumps(data, sort_keys=True))    mac = hmac_sha256(SERVER_KEY, body)    return body + "." + b64url(mac)def read_form_state(token: str) -> dict:    try:        body, mac = token.rsplit(".", 1)    except ValueError:        raise Rejected("malformed state")    if not constant_time_equal(b64url_decode(mac), hmac_sha256(SERVER_KEY, body)):        raise Rejected("tampered state")          # check before parsing    data = json_loads(b64url_decode(body))        # plain data, no classes    return validate_schema(data, FORM_STATE_SCHEMA)

Line by line, in plain words:

  • def issue_form_state(data: dict) -> str: starts a function that takes a dictionary of data and returns a string. A function is a named block of code you can call.
  • body = b64url(json_dumps(data, sort_keys=True)) turns the data into JSON text, sorts the keys so the result is always identical for identical data, and encodes it in a URL-safe base64 form. This is the part the client will carry.
  • mac = hmac_sha256(SERVER_KEY, body) computes the signature over that body using the secret key.
  • return body + "." + b64url(mac) glues the body and the signature together with a dot, so the client receives one string.
  • def read_form_state(token: str) -> dict: starts the function that reads the value back.
  • try: begins a block that may fail.
  • body, mac = token.rsplit(".", 1) splits the string at the last dot into body and signature.
  • except ValueError: catches the case where there is no dot at all.
  • raise Rejected("malformed state") refuses the value outright.
  • if not constant_time_equal(b64url_decode(mac), hmac_sha256(SERVER_KEY, body)): recomputes the signature and compares it with the one received. Constant-time comparison takes the same amount of time whether the values match or not, so an attacker cannot learn the answer by timing it.
  • raise Rejected("tampered state") refuses the value if the signature does not match.
  • # check before parsing is a comment marking the key ordering: the signature is verified before the body is looked at.
  • data = json_loads(b64url_decode(body)) decodes the body as plain JSON.
  • # plain data, no classes is a comment noting that nothing here rebuilds a program object.
  • return validate_schema(data, FORM_STATE_SCHEMA) checks the data against the expected schema and returns it.

The important ordering is that the MAC is checked before the body is parsed, and the body is plain JSON validated against a schema, so no classes are instantiated from client input.

Things to test if you look for this pattern

  • Hidden fields that decode to binary. Base64-decode every hidden form value and look for the Java serialisation magic bytes (AC ED) or other object-format markers. A positive result is a value that decodes to a serialised object the server accepts back. Magic bytes are a short fixed sequence at the start of a file or value that identifies its format.
  • Cookies and view state. The same pattern often appears in cookies, javax.faces.ViewState and similar state blobs. A positive result is a state value you can modify and have the server deserialise.
  • Other endpoints in the same application. Stepankin found more than one. Enumerate forms and APIs that round-trip state and test each, since a fix applied to one endpoint may not cover the rest.
  • Signature checks. Flip a byte in a signed-looking state value and see whether the server rejects it before parsing. A positive result is a server that parses first and fails later, or accepts the tampered value.
  • Classpath inventory. Where you have source or dependency access, look for libraries with known deserialisation gadgets, such as Apache Commons Collections. A positive result is a gadget library reachable from the deserialisation path.

Glossary

  • API: the set of addresses and rules a program uses to talk to a server.
  • Allowlist: a list of things that are permitted, with everything else refused.
  • Backdoor: a way into a system that an attacker leaves behind for later access.
  • Base64: a way of writing arbitrary bytes using ordinary text characters.
  • Bounty: a reward a company pays for a valid security report.
  • Class: a blueprint for objects in Java.
  • Classpath: the list of places a Java program looks for code.
  • Constant-time comparison: comparing two values in the same amount of time whether they match or not, so timing reveals nothing.
  • Cookie: a small piece of information the server gives the browser to hold and send back later.
  • CWE-502: the standard identifier for insecure deserialisation of untrusted data.
  • Deserialisation: turning a stream of bytes back into a live program object.
  • Duplicate: a report of a bug that has already been reported.
  • Endpoint: one specific address the application answers on.
  • Form: the part of a page where you type things and send them to the server.
  • Form state: information a form needs to remember between steps.
  • Function: a named block of code you can call.
  • Gadget chain: a sequence of ordinary pieces of code that, joined together, does something harmful.
  • Gadget surface: the set of libraries that could supply a dangerous chain.
  • Hidden field: a form field the page fills in for you and you never see.
  • HMAC: a keyed signature computed with a secret key, so only the key holder can produce a valid stamp.
  • Hook: code the program runs automatically at a certain moment, such as while rebuilding an object.
  • Insecure deserialisation: rebuilding an object from client-supplied bytes without checking that they are safe.
  • JEP 290: a Java feature that lets a program restrict which classes may be deserialised.
  • JSON: a plain text format for data, with no code attached.
  • Lateral movement: using one compromised machine to reach others.
  • Magic bytes: a short fixed sequence at the start of a value that identifies its format.
  • Object: a bundle of data plus the code that works with it.
  • Object graph: the whole set of objects linked together inside one serialised blob.
  • Opaque ID: a meaningless string, like a claim ticket number, that points to a stored record.
  • Out-of-band callback: a signal the server sends to a place the attacker controls, used to prove code ran.
  • POST parameter: a named value sent with a form submission.
  • Remote code execution (RCE): making someone else's server run commands of the attacker's choosing.
  • Schema: a description of which fields are allowed and what type each one has.
  • Serialisation: turning a live program object into a stream of bytes.
  • Signature: a cryptographic stamp that shows a value is the one issued and has not been changed.
  • Token: a small piece of information the browser holds and sends back so the server can recognise it.
  • Web server: the computer that holds a website and answers browser requests.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.