<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Masoud Abdaal on Medium]]></title>
        <description><![CDATA[Stories by Masoud Abdaal on Medium]]></description>
        <link>https://medium.com/@MasoudAbdaal?source=rss-54b67ee1d23e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WAFWoIkijKepoheJSaOYSw.jpeg</url>
            <title>Stories by Masoud Abdaal on Medium</title>
            <link>https://medium.com/@MasoudAbdaal?source=rss-54b67ee1d23e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:12:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@MasoudAbdaal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Hijacking Trust: The Parallels Between Use-After-Free and Insecure Deserialization]]></title>
            <link>https://medium.com/@MasoudAbdaal/hijacking-trust-the-parallels-between-use-after-free-and-insecure-deserialization-a12c587a2987?source=rss-54b67ee1d23e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a12c587a2987</guid>
            <category><![CDATA[exploit]]></category>
            <category><![CDATA[insecure-deserialization]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[heap-memory]]></category>
            <dc:creator><![CDATA[Masoud Abdaal]]></dc:creator>
            <pubDate>Thu, 24 Apr 2025 04:06:56 GMT</pubDate>
            <atom:updated>2025-04-24T04:48:52.073Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Summary</strong></h3><p>Memory-level Use-After-Free and high-level Insecure Deserialization both arise when a program re-uses data it shouldn’t — whether that’s freed memory or untrusted serialized objects. Attackers exploit these misuses to inject and run arbitrary code. In this article you’ll learn:</p><ul><li><strong>What</strong> each vulnerability is, in plain terms</li><li><strong>Two simple examples</strong> of each, showing how they work</li><li><strong>A side-by-side comparison</strong> of their core similarities</li><li><strong>A real CVE example</strong> of insecure deserialization (CVE-2020–9484 in Apache Tomcat), with vulnerable code and attack flow</li></ul><h3>Side-by-Side: Why They’re Alike</h3><figure><img alt="Use-After-Free vs DeSerialization Comparesion" src="https://cdn-images-1.medium.com/max/973/1*MygD2WQOmK_pYlxmLujUZg.png" /><figcaption>Use-After-Free vs DeSerialization Comparision</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l0PjFFGDNTSBBEpf5X-OfQ.png" /><figcaption>Use-After-Free Vs Insecure De-Serialization</figcaption></figure><h3>What Is Use-After-Free?</h3><p>When a program frees (releases) a memory block but later still uses it, that’s a Use-After-Free (UAF) bug. Because that memory can be reallocated for something else, reading or writing it lets attackers hijack program logic or run their own code.</p><h3>Example: Dangling Pointer in C</h3><pre>#include &lt;stdlib.h&gt;<br>#include &lt;stdio.h&gt;<br><br>int main() {<br>    int *ptr = malloc(sizeof(int));<br>    *ptr = 42;<br>    free(ptr);            // memory is returned to the system<br>    printf(&quot;%d\n&quot;, *ptr); // &lt;-- Use-After-Free: ptr now dangles<br>    return 0;<br>}</pre><p>Here, after free(ptr), the program still reads *ptr—but that memory may now hold attacker-controlled data.</p><h3>What Is Insecure Deserialization?</h3><p>When a program blindly deserializes (reconstructs) objects from untrusted input without validating it, attackers can craft payloads that run arbitrary methods or code during reconstruction.</p><h3>Example 1: Python pickle</h3><pre>import pickle, os, base64<br><br>class Malicious:<br>    def __reduce__(self):<br>        return (os.system, (&quot;echo HACKED&quot;,))<br><br># Attacker serializes Malicious<br>payload = base64.b64encode(pickle.dumps(Malicious()))<br>print(payload.decode())  # Unpickling this executes os.system(&quot;echo HACKED&quot;)</pre><p>If the application does pickle.loads(user_input), that alone runs the attacker’s __reduce__ code.</p><h3>Example 2: PHP unserialize()</h3><pre>&lt;?php<br>class Logger {<br>    public $cmd;<br>    function __destruct() {<br>        system($this-&gt;cmd);<br>    }<br>}<br><br>$data = $_GET[&#39;data&#39;];<br>$logger = unserialize($data); // insecure!</pre><p>An attacker’s GET parameter like</p><pre>data=O:6:&quot;Logger&quot;:1:{s:3:&quot;cmd&quot;;s:7:&quot;id &gt; /tmp/x&quot;;}</pre><p>will execute system(&quot;id &gt; /tmp/x&quot;) when the script ends and __destruct() fires.</p><h3>Real-World CVE: Insecure Deserialization in Apache Tomcat (CVE-2020–9484)</h3><p>In April 2020, Tomcat’s session persistence feature was found to deserialize session data from an untrusted cookie — leading to remote code execution.</p><h3>Vulnerable Code Snippet</h3><pre>protected synchronized void doLoad() throws IOException {<br>    // ...<br>    File file = new File(fileName);<br>    if (file.exists()) {<br>        FileInputStream fis = new FileInputStream(file);<br>        ObjectInputStream ois = new ObjectInputStream(fis);<br>        Object session = ois.readObject(); // &lt;-- Untrusted deserialization<br>        ois.close();<br>        restoreSession(session);<br>    }<br>}</pre><p>Here, ObjectInputStream.readObject() blindly trusts data stored in the .SER file (fed from the JSESSIONID cookie).</p><h3>Attack Flow</h3><ol><li><strong>Craft Payload</strong></li></ol><ul><li>Attacker builds a Java serialized object using a known gadget chain (e.g., Commons-Collections) to execute a shell command.</li></ul><p><strong>2. Encode &amp; Inject</strong></p><ul><li><strong><em>They encode the serialized bytes (Base64), set it as the </em></strong><strong><em>JSESSIONID cookie, and send an HTTP request to any webapp endpoint.</em></strong></li></ul><p><strong>3. Server Loads Session</strong></p><ul><li>On restart or session load, Tomcat reads the session file, calls readObject(), and the gadget chain triggers the attacker’s code.</li></ul><p><strong>4. Code Execution</strong></p><ul><li>Arbitrary commands run with the server’s privileges.</li></ul><p>This CVE underscores how trusting serialized data — even in a “helper” feature — can open the door to full system compromise.</p><h3>Conclusion</h3><p>Both Use-After-Free and Insecure Deserialization stem from re-using data that should be off-limits — freed memory or unvalidated objects. By understanding their parallels, you can apply similar defensive mindsets:</p><ol><li><strong>Never trust untrusted data</strong> — validate, sanitize, or strictly limit what you accept.</li><li><strong>Adopt safe libraries and patterns</strong> — smart pointers in C++, allow-lists in deserialization frameworks.</li><li><strong>Test proactively</strong> — fuzz memory paths and serialization endpoints.</li></ol><p>Mastering these concepts and defense strategies makes your software — and your own security skills — more robust, creative, and future-proof.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a12c587a2987" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microsoft’s Strategic Contribution to the Go Project: Enabling FIPS-140 Compliance]]></title>
            <link>https://medium.com/@MasoudAbdaal/microsofts-strategic-contribution-to-the-go-project-enabling-fips-140-compliance-3be3baf6895c?source=rss-54b67ee1d23e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3be3baf6895c</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[compliance]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Masoud Abdaal]]></dc:creator>
            <pubDate>Thu, 03 Apr 2025 14:19:40 GMT</pubDate>
            <atom:updated>2025-04-03T14:19:40.915Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*_axUn_LwHNcR5GUGxtqexw.png" /><figcaption>GoLang, Cryptography, Microsoft</figcaption></figure><h3>Why Is Microsoft Involved In Go Development?</h3><p>Microsoft has taken an active role in the development of Go, primarily because the language currently lacks native implementations for cryptographic libraries with its runtime. Instead, Go relies on external libraries such as OpenSSL (e.g., <a href="https://github.com/golang-fips/openssl">golang-fips/openssl</a>). In other words, Go does not inherently provide its own cryptographic function implementations.</p><h4>Addressing Cryptographic Limitations</h4><p>Recognizing the gap, Microsoft is gradually working to integrate these missing cryptographic functions into Go. The aim is to enhance the language’s security by aligning it with the <strong><em>F</em></strong>ederal <strong><em>I</em></strong>nformation <strong><em>P</em></strong>rocessing <strong><em>S</em></strong>tandard (<a href="https://csrc.nist.gov/publications/fips"><strong>FIPS</strong>-140</a>). This initiative presents a significant step toward ensuring that Go meets the strict security requirements needed by many organisations.</p><h4>Undrestanding FIPS-140: A Primer</h4><p>FIPS-140 is a set of security standards established by the U.S. government. These standards are designed to develop cryptographic modules that ensure robust security in cryptographic operations. The standards define four levels of security, and it is mandatory for any organization that collaborates with the U.S. government or operates in a sector like healthcare to implement these requirements in their code.</p><h4>The Impact of FIPS-140 Compliance</h4><p>By contributing to the integration of FIPS-140 compliant cryptographic functions, Microsoft is not only helping improve the security posture of Go but also easing the burden for organizations that must adhere to these stringent standards. This effort benefits developers by providing a more secure and auditable codebase and helps organizations streamline their compliance process.</p><h3>Conslusion</h3><p>In summary, Microsoft’s investment in enhancing Go is driven by the need to address its current cryptographic limitations. Through their work to implement FIPS-140 compliant functions, Microsoft is paving the way for a more secure, compliant and future-ready Go ecosystem. This initiative is critical for industries that require stringent security measures and demonstrates a proactive approach toward evolving the language to meet modern security challenges.</p><h3>Further Reading</h3><ol><li><a href="https://github.com/microsoft/go/tree/microsoft/main/eng/doc/fips#microsoft-build-of-go-fips-compliance">Microsoft build of Go FIPS compliance</a></li><li>Github.com <a href="https://github.com/microsoft/go?tab=readme-ov-file#why-does-this-fork-exist">microsoft/go: The Microsoft build of Go</a></li><li><a href="https://go.dev/doc/security/fips140">FIPS 140–3 Compliance — The Go Programming Language</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3be3baf6895c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chaining Multiple Vulnerabilities to Achieve RCE in Kerio Control (CVE-2024–52875)]]></title>
            <link>https://medium.com/@MasoudAbdaal/chaining-multiple-vulnerabilities-to-achieve-rce-in-kerio-control-cve-2024-52875-d15342a7062d?source=rss-54b67ee1d23e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d15342a7062d</guid>
            <category><![CDATA[exploit]]></category>
            <category><![CDATA[cve]]></category>
            <category><![CDATA[rce]]></category>
            <category><![CDATA[csrf]]></category>
            <category><![CDATA[xss-attack]]></category>
            <dc:creator><![CDATA[Masoud Abdaal]]></dc:creator>
            <pubDate>Sat, 11 Jan 2025 08:37:21 GMT</pubDate>
            <atom:updated>2025-01-11T08:37:21.307Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>A critical vulnerability chain was discovered in Kerio Control that allows an attacker to achieve Remote Code Execution (RCE) through a series of chained vulnerabilities. The attack combines HTTP Response Splitting, Cross-Site Scripting (XSS), CSRF token theft, and insecure file upload to gain unauthorized system access.</p><h3>Visual Representation</h3><p>[HTTP Response Splitting] <br> ↓<br>[Reflected XSS Injection]<br> ↓<br>[CSRF Token Theft via iframe]<br> ↓<br>[Malicious File Upload]<br> ↓<br>[RCE via Shell Execution]</p><h3>Technical Details of the Attack Chain</h3><p><strong>Step 1: HTTP Response Splitting</strong></p><ul><li>Vulnerable endpoints: <em>/nonauth/addCertException.cs</em>, <em>/nonauth/guestConfirm.cs</em> , <em>/nonauth/expiration.cs</em></li><li>Attack vector: Manipulation of the “<strong>dest</strong>” GET parameter</li><li>The attacker can inject newline characters <strong>(`\n`)</strong> to split and control HTTP response headers</li></ul><p><strong>Step 2: Reflected XSS Exploitation</strong></p><ul><li>The HTTP Response Splitting vulnerability is leveraged to inject malicious JavaScript</li><li>Payload is encoded using <strong><em>zlib_encode </em></strong>for compatibility with the server’s <strong><em>Content-Encoding: deflate</em></strong></li><li>Custom <em>Content-Length</em> header is injected to prevent response parsing errors</li></ul><p><strong>Step 3: CSRF Token Theft</strong></p><ul><li>Missing <em>X-Frame-Options</em> header allows iframe-based attacks</li><li>An iframe is created to access <em>/admin/</em> directory</li><li>Stolen tokens:<br><em>SESSION_CONTROL_WEBADMIN<br>TOKEN_CONTROL_WEBADMIN</em></li></ul><pre>function createIFrame(file, id)<br>{<br> iframe = document.createElement(&quot;iframe&quot;);<br> iframe.src = url + &quot;/constants.js&quot;;<br> iframe.style.display = &quot;none&quot;;<br> iframe.sandbox = &quot;allow-scripts allow-same-origin&quot;;<br><br> iframe.onload = function() {<br>  cookie = iframe.contentWindow.document.cookie;<br><br>  var re = new RegExp(name + &quot;=([^;]+)&quot;);<br>  var value = re.exec(cookie);<br>  var token = (value != null) ? unescape(value[1]) : null;<br><br>  uploadImage(file, id, token);<br> };<br><br> document.body.appendChild(iframe);<br>}<br>...<br>$body = zlib_encode($body, ZLIB_ENCODING_DEFLATE);</pre><p><strong>Step 4: Malicious File Upload</strong></p><ul><li>Created a malicious shell script <strong>(upgrade.sh)</strong> containing netcat reverse shell</li><li>Packaged as <strong><em>.tar</em></strong><em> </em>file and renamed to <em>.img</em></li><li>Base64 encoded to bypass potential filters</li><li>Uploaded using stolen CSRF tokens</li></ul><p>Step 5: RCE Achievement</p><ul><li>Leveraged existing Kerio vulnerability (<a href="https://www.exploit-db.com/exploits/38450">Exploit-DB 38450</a>)</li><li>The uploaded <em>.img </em>file is executed with root privileges</li><li>Establishes reverse shell connection to attacker’s system</li></ul><p><a href="https://karmainsecurity.com/hacking-kerio-control-via-cve-2024-52875">Main Blog Post</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d15342a7062d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Firefox Debugger Does Not Show Any Source Code]]></title>
            <link>https://medium.com/@MasoudAbdaal/firefox-debugger-does-not-show-any-source-code-8aeb46d3bf43?source=rss-54b67ee1d23e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8aeb46d3bf43</guid>
            <category><![CDATA[devtools]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[firefox-devtools]]></category>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[firefox]]></category>
            <dc:creator><![CDATA[Masoud Abdaal]]></dc:creator>
            <pubDate>Wed, 09 Oct 2024 15:41:12 GMT</pubDate>
            <atom:updated>2024-10-09T15:41:12.993Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="The Empty Debugger Sources In FireFox" src="https://cdn-images-1.medium.com/max/1024/1*Q1H5zIphV1qgleGk31GxVw.png" /><figcaption>Empty Debugger Sources</figcaption></figure><p>If you are faced with this problem and you do not have any idea about its root cause, we are going to solve it together.</p><h3>The Problem</h3><p>Accidentally, when you select “Set directory root” in the sources section, this change could permanently affect your browser and <strong><em>will not reset</em></strong> after you close the browser tab. The directory root will apply to your future browsing and prevent you from debugging loaded source codes. You will not have access to them and cannot do anything.</p><h4>Solve Steps</h4><ol><li>Open<strong><em> about:profiles</em></strong><em> </em>on firefox<br>-Find <em>Default Profile: yes<br>-</em>Select <em>Root Directory (Open Folder )</em></li><li>Open <strong><em>prefs.js</em></strong></li><li>Comment Out These (//):<br><strong><em>devtools.debugger.pending-selected-location<br>devtools.debugger.project-directory-root<br>devtools.debugger.project-directory-root-name</em></strong></li><li>Close your browser and open it again</li><li>Done.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gS7UDb7O8IFRxtXpSh_XPA.png" /><figcaption>Firefox Debugger Configurations</figcaption></figure><p>In my case, google.com has been set as the directory root and I could not see other site&#39;s sources. This method helps you prevent a &quot;Reset Profile&quot; and losing all of your data and credentials.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8aeb46d3bf43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTTP Methods Testing/Fuzzing Using ffuf]]></title>
            <link>https://medium.com/@MasoudAbdaal/http-methods-testing-fuzzing-using-ffuf-fa85317dcd08?source=rss-54b67ee1d23e------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa85317dcd08</guid>
            <dc:creator><![CDATA[Masoud Abdaal]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 15:10:16 GMT</pubDate>
            <atom:updated>2024-04-19T15:10:16.525Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>Copy your request from Burp suite</li><li>Delete it’s method and put §§ instead of it</li><li>Save your request in a file (req.txt)</li><li>Save HTTP methods on a seprated file (methods.txt)</li><li>Try this command:</li></ol><pre>ffuf.exe -req .\req.txt -w .\methods.txt -mode sniper</pre><ol><li>DONE</li><li>You can use HTTP methods I mentioned below in your file:</li></ol><p>GET</p><p>HEAD</p><p>POST</p><p>PUT</p><p>DELETE</p><p>CONNECT</p><p>OPTIONS</p><p>TRACE</p><p>PATCH</p><p>INVENTED</p><p>HACK</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa85317dcd08" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Logical (Process-Oriented) Attacks Series Part #1]]></title>
            <link>https://medium.com/@MasoudAbdaal/logical-process-oriented-attacks-series-part-1-29d02c360b71?source=rss-54b67ee1d23e------2</link>
            <guid isPermaLink="false">https://medium.com/p/29d02c360b71</guid>
            <dc:creator><![CDATA[Masoud Abdaal]]></dc:creator>
            <pubDate>Wed, 17 Apr 2024 08:34:05 GMT</pubDate>
            <atom:updated>2024-04-17T08:34:05.963Z</atom:updated>
            <content:encoded><![CDATA[<h3>Prototype Pollution In NodeJs Application</h3><p><strong>Impact &amp; Flow?</strong></p><p>This vulnerability occurs when your input affects object creation in other parts of your code. Your input can disrupt the construction of variables throughout the rest of the code.<br>When this happens, some or all of your declared variables may unintentionally revert to <strong>polluted values</strong>, <strong>BEFORE</strong> you’ve initialized them! As your program checks these uninitialized variables for default or null states and assigns the correct values, they might <strong>already </strong>become poisoned by the attack!</p><p><strong>Example</strong></p><p>As you can see on below, I create an object with some properties and next just assign a propery for <strong><em>__proto__ </em></strong>object. All of objects I will create after this, going to have this property!</p><figure><img alt="Polluted property" src="https://cdn-images-1.medium.com/max/271/1*vK2ZUfpK0OGtQhy7vk4QTA.png" /><figcaption>Polluted Property</figcaption></figure><p>__proto__ is an object which is include all methods and properties specified for defined variable. An Object type has different __proto__ values compare to an Array.</p><p><strong>Prevent And Mitigate</strong></p><ol><li>Use <strong>Object.freeze(<em>yourObject</em>)</strong> to make your object freeze and unchangeable.</li><li>Check for <em>__proto__ </em>while you are assign or extend an object which values come from user side!</li><li><strong>Object.create(</strong><em>null</em><strong>)</strong> will create an object for you <strong>without ANY</strong> prototype properties! You will not able to write <em>stringVar.length </em>or <em>myArray.keys! </em>Everything already cleaned-up!</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*tF8BhNMrn1grqG6MDULW2Q.png" /><figcaption>Create Object Using Object.Create(null)</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29d02c360b71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OWASP WebGoat Vulnerabilities Code Audit; Part: 1 (Path Traversal)]]></title>
            <link>https://medium.com/@MasoudAbdaal/owasp-webgoat-vulnerabilities-code-audit-part-1-path-traversal-38e0ac3e83ab?source=rss-54b67ee1d23e------2</link>
            <guid isPermaLink="false">https://medium.com/p/38e0ac3e83ab</guid>
            <category><![CDATA[vulnerability-assessment]]></category>
            <category><![CDATA[web-vulnerabilities]]></category>
            <category><![CDATA[secure-coding]]></category>
            <category><![CDATA[path-traversal]]></category>
            <category><![CDATA[owasp-top-10]]></category>
            <dc:creator><![CDATA[Masoud Abdaal]]></dc:creator>
            <pubDate>Sun, 10 Dec 2023 13:15:41 GMT</pubDate>
            <atom:updated>2023-12-10T13:15:41.163Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Cute Goat :DD" src="https://cdn-images-1.medium.com/max/800/1*zQPtxvqk8eANg-F0WU_pGw.jpeg" /><figcaption>Cute Goat!</figcaption></figure><p>Today im gonna do some security code audit on OWASP WebGoat project and see what pattern has been applied to the codes.</p><p>You can easily download and build <a href="https://github.com/WebGoat/WebGoat#4-run-from-the-sources">this project</a> in Windows and Visual Studio Code.</p><h3>Path Traversal</h3><p>It’s better to be familiar with this kind of vulnerability! if not, It’s highly recommend to visit P<a href="https://portswigger.net/web-security/learning-paths/server-side-vulnerabilities-apprentice/path-traversal-apprentice/file-path-traversal/reading-arbitrary-files-via-path-traversal">ortswigger</a> academy and read more about it.</p><p>let’s dive into how our Java Back-End is vulnerable…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SuVQhEv_ziuxAwj1DOjgzw.png" /><figcaption>Path Traversal Vulnerable Page</figcaption></figure><p>As you can see, we have a web form and we should select some file and it will upload on the server, then let be a classic user and do our regular works…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eJvBKs7pDXrglhDVI0WYmg.png" /><figcaption>Regular Form Request</figcaption></figure><p>As you can see, we have some connections between <strong>FullName </strong>form field and THE FILE PATH!</p><p>let’s dive into <strong>HTML!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*WQT2hxGz9KxxJ9FcohMeSw.png" /><figcaption>HTML Form Inspect</figcaption></figure><p>Here we cannot find anything interest, just API/End-Point which our picture fly to it. lets search and find this endpoint on WebGoat Source Codes!</p><pre>public class ProfileUpload extends ProfileUploadBase {<br><br>  public ProfileUpload(<br>      @Value(&quot;${webgoat.server.directory}&quot;) String webGoatHomeDirectory, WebSession webSession) {<br>    super(webGoatHomeDirectory, webSession);<br>  }<br><br>  @PostMapping(<br>      value = &quot;/PathTraversal/profile-upload&quot;,<br>      consumes = ALL_VALUE,<br>      produces = APPLICATION_JSON_VALUE)<br>  @ResponseBody<br>  public AttackResult uploadFileHandler(<br>      @RequestParam(&quot;uploadedFile&quot;) MultipartFile file,<br>      @RequestParam(value = &quot;fullName&quot;, required = false) String fullName) {<br>    return super.execute(file, fullName);<br>  }<br><br>  @GetMapping(&quot;/PathTraversal/profile-picture&quot;)<br>  @ResponseBody<br>  public ResponseEntity&lt;?&gt; getProfilePicture() {<br>    return super.getProfilePicture();<br>  }<br>}</pre><pre>protected AttackResult execute(MultipartFile file, String fullName) {<br>    if (file.isEmpty()) {<br>      return failed(this).feedback(&quot;path-traversal-profile-empty-file&quot;).build();<br>    }<br>    if (fullName.isEmpty()) {<br>      // if (StringUtils.isEmpty(fullName)) {<br>      return failed(this).feedback(&quot;path-traversal-profile-empty-name&quot;).build();<br>    }<br><br>    File uploadDirectory = cleanupAndCreateDirectoryForUser();<br><br>    try {<br>      var uploadedFile = new File(uploadDirectory, fullName);<br>      uploadedFile.createNewFile();<br>      FileCopyUtils.copy(file.getBytes(), uploadedFile);<br>...<br><br>  @SneakyThrows<br>  protected File cleanupAndCreateDirectoryForUser() {<br>    var uploadDirectory =<br>        new File(this.webGoatHomeDirectory, &quot;/PathTraversal/&quot; + webSession.getUserName());<br>    if (uploadDirectory.exists()) {<br>      FileSystemUtils.deleteRecursively(uploadDirectory);<br>    }<br>    Files.createDirectories(uploadDirectory.toPath());<br>    return uploadDirectory;<br>  }</pre><p>Let’s create some break-points on this vulnerable spots and again send our picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ifz7SSblNsbtpLods4AH3w.png" /></figure><p>As you can imagine, an invalid path has been come to File() function and our picture files byte going to be copy on it without any validations!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38e0ac3e83ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>