{"id":23631,"date":"2024-10-30T10:06:38","date_gmt":"2024-10-30T09:06:38","guid":{"rendered":"https:\/\/herolab.usd.de\/security-advisories\/usd-2024-0008\/"},"modified":"2024-11-11T09:31:24","modified_gmt":"2024-11-11T08:31:24","slug":"usd-2024-0008","status":"publish","type":"page","link":"https:\/\/herolab.usd.de\/en\/security-advisories\/usd-2024-0008\/","title":{"rendered":"usd-2024-0008"},"content":{"rendered":"<p>[et_pb_section fb_built=\"1\" _builder_version=\"4.21.0\" _module_preset=\"default\" background_color=\"#2E353D\" custom_padding=\"||0px|||\" global_colors_info=\"{}\"][et_pb_row _builder_version=\"4.25.2\" _module_preset=\"default\" global_colors_info=\"{}\"][et_pb_column type=\"4_4\" _builder_version=\"4.21.0\" _module_preset=\"default\" global_colors_info=\"{}\"][et_pb_text _builder_version=\"4.27.2\" _module_preset=\"default\" custom_padding=\"||13px|||\" hover_enabled=\"0\" global_colors_info=\"{}\" sticky_enabled=\"0\"]<\/p>\n<h1>usd-2024-0008 | Path Traversal in Webswing Upload Functionality<\/h1>\n<p><strong>Advisory ID:<\/strong> usd-2024-0008<br \/><strong>Product:<\/strong> Webswing<br \/><strong>Affected Version:<\/strong> Confirmed on 23.2.2, potentially also on 24.1 (not tested)<br \/><strong>Vulnerability Type:<\/strong> Relative Path Traversal (CWE-23)<br \/><strong>Security Risk:<\/strong> High<br \/><strong>Vendor URL:<\/strong> <a>https:\/\/webswing.org\/<\/a><br \/><strong>Vendor acknowledged vulnerability:<\/strong> Yes<br \/><strong>Vendor Status:<\/strong> Fixed<br \/><strong>CVE Number:<\/strong> CVE-2024-39332<br \/><strong>CVE Link:<\/strong> <a href=\"https:\/\/nvd.nist.gov\/vuln\/detail\/CVE-2024-39332\" target=\"_blank\" rel=\"noopener\">https:\/\/nvd.nist.gov\/vuln\/detail\/CVE-2024-39332<\/a><\/p>\n<h2>Affected Component<\/h2>\n<p>Due to the product being closed-source, it is not possible to pinpoint the exact component.<br \/>As Webswing works by offering a toolkit that aims to be a drop-in replacement for Java Swing's toolkit, it is likely that the vulnerability is contained in the Webswing equivalent of <strong>java.awt.FileDialog<\/strong>.<\/p>\n<h2>Description<\/h2>\n<p>Webswing allows you to run Java Swing applications inside a web browser.<br \/>It consists of (a) the Webswing toolkit, which aims to be a drop-in replacement for Java Swing's toolkit, (b) the Webswing server and (c) the Webswing frontend.<br \/>In order to do so, it has to act as an intermediary between the Java client and the user's browser.<br \/>This requires putting various operations, such as file dialogs, into to context of the user's browser in a way that does not affect the Java client.<br \/>This vulnerability is contained within the logic that maps file imports functionality in Java clients to file upload functionality in browsers.<\/p>\n<p>As far as can be observed from the outside, Webswing does this as follows:<br \/>1. Whenever the Java client wants to import a file, it calls the <strong>createFileDialog<\/strong> function with the necessary settings.<br \/>2. Depending on its configuration the Webswing server creates or chooses an upload folder.<br \/>3. The Webswing server sends a message to the Webswing frontend, which creates a file dialog from within the user's browser.<br \/>4. The Webswing frontend uploads the file contents as well as its filename to the Webswing server.<br \/>5. The Webswing server places the file into the specified upload folder and finally hands it to the Java client.<\/p>\n<p>The vulnerability is contained in step 5 and can be exploited by specifiying a malicious filename in step 4.<\/p>\n<h2>Proof of Concept<\/h2>\n<p>When the user opts to upload a file, Webswing creates a popup which in turn opens file dialog on the user's system.<br \/>The functionality of this popup is contained in <strong>webswing-embed.js<\/strong>, in particular in the <strong>Jr<\/strong> class.<\/p>\n<p>As this JavaScript code is in the user's browser, it can be modified. For example, the filename can be adjusted before the request is handed to the backend.<br \/>In the following the path traversal is added to the filename in the <strong>t<\/strong> variable.<\/p>\n<pre class=\"codehilite\" style=\"line-height: 125%;background: #263238;color: #eff\">sendUploadStart(e, t, r) {    <br \/>    this.manager.send({        <br \/>        directUpload: {            <br \/>            transferId: e,            <br \/>            event: Br.start,            <br \/>            fileName: \".\/..\/..\/..\/..\/home\/webswing\/.ssh\/\" + t,            <br \/>            size: r        <br \/>        }    <br \/>    })<br \/>}<\/pre>\n<p>The Webswing server receives the data sent from the browser via Websocket and passes it on to the Java application without further filtering.<br \/>In other words, the Webswing backend accepts the filename from the Webswing JavaScript frontend without validation and the Java Application trusts the path given by Webswing.<\/p>\n<p>As a result, an attacker can write to arbitrary file locations that are accessible by the webswing user.<\/p>\n<p>In the example payload above, the uploaded file is saved in <strong>\/home\/webswing\/.ssh\/<\/strong>, which will be created, should it not already exist.<\/p>\n<p>In terms of impact, this vulnerability very likely leads to remote code execution for the attacker.<br \/>For example, if the SSH port had been open, the attacker could login using his respective private key.<br \/>Even without SSH, an attacker can modify any of the various shell scripts on the Webswing server to gain an interactive shell through a backdoor.<\/p>\n<h2>Fix<\/h2>\n<p>The backend should not trust the user input from the frontend and should not use the provided filename without filtering.<br \/>It is recommended to filter all input that is used in the context of file operations for path specifications.<\/p>\n<p>Users of the software should upgrade to versions 24.1.1, 23.2.8 LTS, 22.1.23 LTS that fix this security issue.<\/p>\n<h2>References<\/h2>\n<ul>\n<li><a>https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/awt\/Toolkit.html#createFileDialog-java.awt.FileDialog-<\/a><\/li>\n<li><a>https:\/\/owasp.org\/www-community\/attacks\/Path_Traversal<\/a><\/li>\n<\/ul>\n<h2>Timeline<\/h2>\n<ul>\n<li><strong>2024-05-06<\/strong>: First contact request via contact form on <a>https:\/\/www.webswing.org\/en\/contact.<\/a><\/li>\n<li><strong>2024-06-05<\/strong>: Vulnerability confirmed by vendor.<\/li>\n<li><strong>2024-06-17<\/strong>: The Responsible Disclosure Team requested a CVE for the issue in coordination with Webswing.<\/li>\n<li><strong>2024-07-01<\/strong>: Vulnerability fixed in Versions 24.1.1, 23.2.8 LTS, 22.1.23 LTS.<\/li>\n<\/ul>\n<h2>Credits<\/h2>\n<p>This security vulnerability was identified by Ehud Cseresnyes and Yannick Westphal of usd AG.<\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>usd-2024-0008 | Path Traversal in Webswing Upload Functionality Advisory ID: usd-2024-0008Product: WebswingAffected Version: Confirmed on 23.2.2, potentially also on 24.1 (not tested)Vulnerability Type: Relative Path Traversal (CWE-23)Security Risk: HighVendor URL: https:\/\/webswing.org\/Vendor acknowledged vulnerability: YesVendor Status: FixedCVE Number: CVE-2024-39332CVE Link: https:\/\/nvd.nist.gov\/vuln\/detail\/CVE-2024-39332 Affected Component Due to the product being closed-source, it is not possible to pinpoint the [&hellip;]<\/p>\n","protected":false},"author":114,"featured_media":0,"parent":16124,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","inline_featured_image":false,"footnotes":""},"class_list":["post-23631","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/23631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/users\/114"}],"replies":[{"embeddable":true,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/comments?post=23631"}],"version-history":[{"count":4,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/23631\/revisions"}],"predecessor-version":[{"id":23688,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/23631\/revisions\/23688"}],"up":[{"embeddable":true,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/16124"}],"wp:attachment":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/media?parent=23631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}