<?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 Asyary Raihan on Medium]]></title>
        <description><![CDATA[Stories by Asyary Raihan on Medium]]></description>
        <link>https://medium.com/@asyary?source=rss-dd72918c76d1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ClO6nD7wiyrPljwPVXjmFA.jpeg</url>
            <title>Stories by Asyary Raihan on Medium</title>
            <link>https://medium.com/@asyary?source=rss-dd72918c76d1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 21:53:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@asyary/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[How I Hacked One of the Largest Ministries in Indonesia]]></title>
            <link>https://asyary.medium.com/how-i-hacked-one-of-the-largest-ministries-in-indonesia-1fba947893e1?source=rss-dd72918c76d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fba947893e1</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[indonesia]]></category>
            <category><![CDATA[bug-bounty-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Asyary Raihan]]></dc:creator>
            <pubDate>Fri, 02 Jan 2026 04:05:14 GMT</pubDate>
            <atom:updated>2026-01-02T04:05:14.404Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*TbZH3Syp0yG9MvfzZQW_Tg.png" /></figure><p>I interned at the Ministry of Public Works (<em>Kementerian PU</em>) for about four months as a penetration tester. During that time, I discovered more than two dozen vulnerable web apps, with severities ranging from informational to critical. This is the story of how I hacked the root domain server of Indonesia’s Ministry of Public Works, <a href="https://pu.go.id/">pu.go.id</a>.</p><p>All parties involved have given me permission to share this story with you all. Note that images containing sensitive information will either be partially displayed or mostly redacted.</p><p><em>Source: trust me bro.</em></p><h4>Prerequisites:</h4><p>Given the complexity of the attack, we first need to establish some common ground regarding a few cybersecurity and web application concepts. In this article, you’ll learn about:</p><ul><li>Basics of IP addresses and IPv4 address space;</li><li>Attack vectors and attack surfaces;</li><li>Information disclosure and how it can be exploited;</li><li>How to pivot and move laterally from one machine to another.</li></ul><p>These first four parts provide the necessary background to understand how I devised the attack on pu.go.id. If you’re uninterested in some of those boring details, you can immediately go to <a href="#:~:text=Part%205%3A%20pu.go.id%20PWNED!"><strong>Part 5</strong></a> to understand how I was able to hack the Ministry of Public Works.</p><h4>Part 1: IPv4</h4><p>It might seem a bit strange to open this article by discussing IPv4 instead of, y’know, just immediately going over “How I hacked pu.go.id”, but it’ll make sense in a moment.</p><p>Most of you have likely heard the term “IP Address”, but what is it, exactly? An IP address (Internet Protocol address) is a numerical label that is assigned to each device connected to a network that uses Internet Protocol for communication. As the name suggests, it’s an address; it allows you to identify and reach to and from a device across a network using protocols that is supported by the Internet Protocol, such as HTTP, TCP, TLS, or even <a href="https://dev.mysql.com/doc/dev/mysql-server/latest/PAGE_PROTOCOL.html">MySQL Protocol</a> (<em>foreshadowing</em>).</p><p>There are two primary versions of IP addresses in use today: IPv4 and IPv6. One of the main difference is the address space:</p><ul><li>IPv4 uses 32 bits, which limits it to roughly 4.2 billion addresses.</li><li>IPv6 uses 128 bits, allowing for around 340 undecillion addresses, that is a 3 followed by 38 zeros (3.4×10³⁸).</li></ul><p>Most of the web still relies on IPv4 mainly because IPv6 is not backward compatible. You can’t simply “upgrade” from IPv4 to IPv6, as it is an entirely different protocol despite sharing the “Internet Protocol” name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*CIbDeCiY_IJCvPdIoC7GVA.png" /><figcaption>IPv4 Address Structure</figcaption></figure><p>Certain ranges within the IPv4 address space are reserved for private networks. These addresses are intended for use within local networks and are not routable on the public internet. This allows millions of private networks to reuse the same address ranges without conflict. It would be nonsensical for all devices to have their own public IP addresses, as this would quickly exhaust the IPv4 address space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aNOzWu6QVdDqv6ZB2s9DZQ.png" /><figcaption>Private IP Address Range &amp; Class</figcaption></figure><p>To enable communication between these private networks and the public internet, Network Address Translation (NAT) is used to translate private IP addresses into public ones. Take your day-to-day Wi-Fi router for example, from the outside world, all outgoing traffic looks like it is coming from a single public IPv4 address, even though all of the devices connected to this Wi-Fi router, be that a PC, laptop, smartphone and what not, have their own private IP address that is assigned to them via NAT by the router.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jLzlwlDwOGE1u0zGBCf9fg.png" /><figcaption>NAT Topology Example</figcaption></figure><p>In the example above, outgoing traffics from a PC at 192.168.1.2 and a mobile phone at 192.168.1.4 to Web Server, when inspected as if it were all originating from 36.12.34.56. The same goes for Web Server, whether a response originates from 10.20.30.40, 10.100.200.1, or 10.90.80.70, it is translated to the public IP 103.98.76.54. This example’s Home Wi-Fi uses 192.168.0.0/16 private IP range, while the Web Server uses 10.0.0.0/8 private IP range, though both are not limited to only those ranges.</p><blockquote>“Bang, my target is at 10.90.80.70, but I can’t interact with that IP, only with 10.20.30.40, what can I do leh?”</blockquote><p><em>Patience, thou fretful soul! For the answer shall be revealed unto thee anon.</em></p><h4>Part 2: Attack Vectors and Attack Surfaces</h4><p>Let’s start by asking ourselves a question: “How can you attack a website?” That question in and of itself can be answered in a lot of ways depending on how you look at it. For instance, you could interpret it as “How do you find vulnerabilities on a website?” or “In how many ways can you test a website for weaknesses?” These are all valid questions that I could spend hours elaborating and explaining the depth and details of (but I won’t).</p><p>If you have spent any time in the cybersecurity field, you are likely familiar with names like SQL Injection (SQLi), IDOR, SSRF, XSS, and so on. These are what we call <strong>vulnerabilities</strong>: flaws, weaknesses, or misconfigurations that can be exploited. The method or path by which these vulnerabilities are exploited is what we call an <strong>attack vector</strong>. The total collection of those vulnerabilities that could possibly be exploited, along with all the possible entry points and paths, is what we call an <strong>attack surface</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*S6MICdq3RW5Eq9SYWpK0iA.png" /><figcaption>Attack Vectors and Attack Surfaces via cloudflare.com</figcaption></figure><p>Some examples:</p><ul><li><strong>Attack Vectors</strong> → Your web app uses a SQL database, and an unsanitized query might lead to SQLi. Or, perhaps an admin is targeted by a phishing attack to gain access.</li><li><strong>Attack Surfaces</strong> → A login page that can be brute-forced; API endpoints that can be fuzzed; or even an IoT device, like an NFC card, that could be cloned.</li></ul><p>Identifying realistic attack vectors and attack surfaces on any given web application requires experience and understanding of an application’s technology stack. For example, trying an SQLi attack on a web application that clearly uses a NoSQL database (like MongoDB) is highly inefficient. While not impossible to find a related flaw, traditional SQLi technically wouldn’t be considered a viable attack vector there.</p><p>Knowing how systems work also helps you spot these vectors much faster. In a high-level pentest, if you know the application is written in C or C++, you should look for memory corruption vulnerabilities like buffer overflows, use-after-free, or OOB read/write. You likely wouldn’t focus on those same issues if the application were built with a <a href="https://en.wikipedia.org/wiki/Memory_safety">memory-safe language</a> such as Rust.</p><p>It’s not just about languages and tech stacks either, it’s also the concepts. Understanding how HTTP works, knowing how to alter a request and inspect a full response, and knowing which tool to use in a given situation will immensely help you towards the right direction and find vulnerabilities quicker. These are just small examples of the foundational knowledge required before going further. Again, experience speaks a lot on this matter.</p><h4>Part 3: Information Disclosure</h4><p>Most of you who’ve tinkered around some web application should be well-acquainted with the concept of information disclosure. Well, what exactly is an “information disclosure”? Simply put, when a website accidentally or unintentionally reveals sensitive information to its users, we call it information disclosure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XY_FJlSJmNaQIXj5Atn-cQ.png" /><figcaption>Laravel Error Stack Trace via freek.dev</figcaption></figure><p>There’s a difference between information disclosure as a vulnerability, and information disclosure as an impact of another vulnerability. For example, if a website API asks for a user ID to retrieve profile data, and you can change that ID to access someone else’s private Personally Identifiable Information (PII), the vulnerability is IDOR (Insecure Direct Object Reference). The impact, however, is information disclosure. It’s a generic term that covers lots of specific scenarios.</p><p>We typically define a flaw as an information disclosure vulnerability when a system exposes internal data without requiring an attacker to exploit other bugs to gain privileges. A classic example is when a website displays a stack trace after an error occurs. These traces often include sensitive details like: absolute file paths to the web root, internal IP addresses, and sometimes environment variables that includes credentials for other service.</p><p>The interesting part is how you “leak” this data. There are lots of methods depending on what kind of information you’re trying to get. Usually, it doesn’t take much effort to exploit these flaws, though the severity is often lower than something like a remote code execution. Simple recon such as fuzzing and enumerating is often enough to get some information disclosure vulnerability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7QbjovHiC55PFX5Vl-hLQ.png" /><figcaption>Fuzzing using <a href="https://github.com/ffuf/ffuf">FFUF</a></figcaption></figure><p>A common example is a web app with an exposed .git directory. This indicates that a Git repository was used for version control during the DevOps process. Why does this matter? Inside .git, you might find files such as:</p><ul><li>.git/config → Reveal the repository URL;</li><li>.git/index → Lists files stored on the server;</li><li>.git/objects/ → (directory) Can be used to literally dump the entire source code of the application.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*G-buCOy4hTyKcQHwsPrX7Q.jpeg" /><figcaption>Dumping Source Code using <a href="https://github.com/arthaud/git-dumper">Git-Dumper</a></figcaption></figure><p>In PHP frameworks like Laravel and CodeIgniter, developers often use a tool to help debug their applications: the ENV (Environment) variables. As the name suggest, the environment variable tells the current app where it’s currently running (e.g., development, local, staging, or production).</p><p>You will notice a server is not using “production” as the environment variable when you get an error, and it dumps a bunch of data. An example for CodeIgniter would look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MpRwSM1accQf1HLlEK4czg.png" /><figcaption>CI Error Stack Trace</figcaption></figure><p>However, not every information disclosure vulnerability is immediately exploitable. For instance, you might find database credentials in a leaked file, but most enterprise websites use reverse proxies and load balancers. These tools allow multiple services to hide behind a single public IP. Because the database, or rather the IP and port to connect to the database, is likely hidden away in an isolated internal network, the credentials you found might be useless from the outside.</p><p>In that case, what you need is <strong>leverage</strong>. One where the method requires you to stop trying to go upward, and instead go <strong>sideways</strong>.</p><h4>Part 4: Pivoting and Lateral Movement</h4><blockquote>“Pivot? Lateral? What do you mean leh, Bang?”</blockquote><p>Most vulnerabilities share a common goal: upward escalation. By “escalating upward,” I mean gaining more privilege than you’re supposed to, or getting higher authorization and/or permission than you originally had or was intended to have.</p><p>Pivoting and lateral movement, however, move you “sideways” instead of “upward.” In these scenarios, your primary goal isn’t necessarily to gain more privilege (even though that is something consequentially might happen), instead, you are trying to jump between different machines or hosts within a network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IownJT0LSG3UX-8bji_rTw.png" /><figcaption>Lateral Movement via blog.spittaler.com</figcaption></figure><p>In the topology example above, the attacker has compromised a host that isn’t directly connected to where the sensitive data is stored (2 hops away). The compromised host then can be used to probe and scan the “Enterprise network”, that is the internal network of the organization. This in turn allows an attacker to find vulnerabilities or privileged accounts on other parts of the system that aren’t exposed to the public internet.</p><p>While the term “Pivoting” and “Lateral Movement” are often used interchangeably, there is a slight nuance between them:</p><ul><li><strong>Lateral Movement</strong> is the act of moving from one compromised host to another within the same network.</li><li><strong>Pivoting</strong> is the technical method that is used to facilitate that movement. You use a compromised system as a “pivot point” to bypass firewalls or access network segments that were previously unreachable.</li></ul><p>To put it simply: you <strong>pivot</strong> through a machine to <strong>move laterally</strong> across the network.</p><p>So…, some information disclosure, and a compromised host. You can see where this is going, right?</p><h4>Part 5: pu.go.id PWNED!</h4><p>Timeline: <strong>August 2025</strong><br>During my third week as an intern at the Ministry of Public Works, I was writing a bug report when I realized my laptop was just idling in the background. With permission from my mentor, I decided to perform a simple recon and scan on the root domain <a href="https://pu.go.id/">https://pu.go.id/</a> .</p><p>The recon and scan itself was simple, I enumerated and fuzzed endpoints on the domain to identify any unusual responses. I used a short wordlist that I took from <a href="https://github.com/danielmiessler/SecLists">SecLists</a> to minimize the risk of service disruption. Upon reviewing the results, I noticed there was definitely something fishy going on with the whole web application.</p><p>While most of the results were standard, I found several “500 Internal Server Error” responses that were almost 1 MB in size each.</p><blockquote>“Huh? Watdehel, why are these 500 hits so large leh? Doesn’t make any sense, let me open thi-”<br>-Me 2025</blockquote><p>This led to my discovery of an <strong>information disclosure vulnerability</strong> via an <strong>error stack trace</strong>. For (obvious) security reasons, I cannot disclose the specific data or technical details regarding this incident. I followed up with an Nmap scan to determine if I could use the leaked credentials in an exploitative way. However, the infrastructure utilized a load balancer that consolidated traffic through a single public IP address, which prevented me from connecting to internal services via the internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JIA3FLxYM7FxSnlUceHUpw.png" /><figcaption>D:</figcaption></figure><p>There was a lot of data being spewed out. While much of it was mundane debug information, some entries were highly sensitive, including a database host, username, password, and an app key used to encrypt session data. Crucially, the DB_HOST was an internal address starting with “10.x.x.x”. This detail would become important later.</p><p>I swiftly reported this carried on with my other tasks.</p><p>Timeline: <strong>October 2025</strong><br>I discovered a Remote Code Execution (RCE) vulnerability. Although I cannot disclose the specific “how” or “where,” this was achieved by chaining an <a href="https://owasp.org/www-community/vulnerabilities/Unrestricted_File_Upload">Unrestricted File Upload vulnerability</a> vulnerability with other flaws to obtain a (web) shell. This gave me access to the server’s files and processes, specifically everything my user (www-data, sadly no root, or at least I didn’t try privesc) had permission to access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qXkaKekxlPBF8wagbhtgyA.png" /><figcaption>“Bang, can you hack my Instagram account?”</figcaption></figure><p>Architecturally, I have a problem with the lack of containerization. Without a sandboxed environment, access to the shell meant access to the entire server. It’s not as damning as the actual vulnerabilities though, but it sure does show the lack of care from the developers regarding the security of their application.</p><p>I made a bug report explaining the vulnerabilities in detail, added some remediations to fix their issues, and moved on.</p><p>Timeline: <strong>December 2025<br></strong>While retesting the vulnerabilities I had discovered during my four month internship, I found that the issue from October had not been fully patched. The developer had implemented a “fix” that could be easily circumvented by changing the file extension. Read <a href="https://swisskyrepo.github.io/PayloadsAllTheThings/Upload%20Insecure%20Files/">here</a> for more information.</p><p>At this point, I realized I needed to test a specific theory. This is when I realize I need to quickly test something. Using <a href="https://github.com/flozz/p0wny-shell">p0wny@shell</a> as my web shell, I ran the “ifconfig” command to check the current host’s internal IP address. Surely enough, the internal IP was in the 10.x.x.x range.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*v5DMLuDCZM2Ep1rrOMpdYQ.png" /><figcaption>Pro Hengker :0</figcaption></figure><p>To move laterally, I attempted to access the DB_HOST from this compromised machine using the credentials from the initial information disclosure in August. I checked for the existence of the MySQL CLI using mysql --help and confirmed it was present. Even if this doesn’t exist, I could have used a PHP script like <a href="https://www.adminer.org/en/">Adminer</a> to establish the connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*7IHBBQJeFkRQ_Hs6YFZEkQ.png" /><figcaption>Totally Real Website leh, Bang, trust</figcaption></figure><p>MySQL allows users to interact with the database directly from the command line using the -e flag, which executes a query without requiring an interactive session. This is ideal for a web shell environment where interactive sessions are often unstable/unreliable. While this method requires entering statements one by one, it is sufficient for a proof of concept.</p><p>For the final PoC, I executed the following command to prove I had query execution privileges: “SELECT VERSION();”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IllbNhfzbH3fBPmBiHD6fw.png" /><figcaption>pu.go.id PWNED! :D</figcaption></figure><h4>Part 6: Conclusion and Remediation</h4><p>Following the discovery of these vulnerabilities, I worked closely with the security team and developers at the Ministry of Public Works to ensure a comprehensive and conclusive resolution. The information disclosure issue was resolved by disabling debug modes, hardening error-handling configurations, and rotating credentials to ensure stack traces are no longer exposed to the public and won’t be able to get exploited.</p><p>For the RCE, the developers replaced the flawed extension check with a strict whitelist and content-based validation, while also configuring the server to prevent script execution within upload directories. Furthermore, the root cause of the initial patch bypass was rectified by ensuring the application validates the actual file content rather than relying on easily manipulated metadata.</p><p>Beyond these specific fixes, they has discussed implementing broader architectural changes for the future, such as containerization and improved network segmentation. These proposed defense measures would isolate applications and prevent an attacker from using a single compromised service as a foothold for lateral movement. By securing both the entry points and the internal network paths, the intention is to significantly reduce the overall attack surface.</p><p>If you found any bug or vulnerabilities under the domain pu.go.id and its subdomains, please report them to <a href="https://csirt.pu.go.id/">https://csirt.pu.go.id/</a> by their proper bug submission standard. Lastly, do remember that you should never perform penetration testing or vulnerability research on pu.go.id without explicit permission from Ministry of Public Works.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fba947893e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[$600 Vulnerability: My First Bug Hunting Journey]]></title>
            <link>https://asyary.medium.com/600-vulnerability-my-first-bug-hunting-journey-98b961a62f4b?source=rss-dd72918c76d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/98b961a62f4b</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[bug-hunting]]></category>
            <category><![CDATA[bug-bounty-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Asyary Raihan]]></dc:creator>
            <pubDate>Thu, 23 Jan 2025 11:42:13 GMT</pubDate>
            <atom:updated>2025-12-15T07:02:21.934Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*O-XfoP14Rnpj3kGbMylfGA.png" /></figure><p>This happened about <em>(more than)</em> a year ago, so I don’t really have all the documentations of what happened. All parties involved have given me permission to share this story with you all.</p><p><em>Source: trust me bro.</em></p><h3>How It Happened</h3><p>I was just browsing around the internet, looking for some online *REDACTED* tools/utility site, until I stumbled upon this website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H3AbMux-IPfynN-V_DLbAQ.png" /></figure><p>At first glance, there doesn’t seem to be anything wrong with it. That is, until you actually convert a file. Something immediately sets off an alarm in my mind, all because of this one tiny insignificant thing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DI9cYVd07-6z58g6TLWP0w.png" /><figcaption>Did you see it?</figcaption></figure><p>You don’t see it yet? It’s the <strong>parameter</strong>. Why’s the <em>file</em> parameter in <em>force_download.php</em> pointing to something that looks like a directory? Well, I tested that theory and tried accessing the <em>upload/</em> directory, to my surprise, the file was there.</p><blockquote>“Well, there’s no way this parameter is <strong>unfiltered</strong>, right? Just out of curiosity, what would happen if I, say, changed the parameter to index.php instead?”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*Cq4D2VdPUeOFWSDr4dnO9g.png" /><figcaption>…</figcaption></figure><p>…, wha-</p><h4>Part 1: Path Traversal</h4><p>What is a Path/Directory Traversal vulnerability? Well, as the name suggests, it’s a vulnerability in web applications that allows an attacker to be able to arbitrarily read files on the web server.</p><p>When this happens, sensitive information (like server config files) is located on the outside of the web directory. That’s why this attack is also called “dot-dot-slash” (../), or backtracking.</p><p>The code that was used in <em>force_download.php</em> must’ve been something like this:</p><pre>&lt;?php<br>$file = $_GET[&#39;file&#39;];<br><br>header(&#39;Content-Type: application/force-download&#39;);<br>header(&#39;Content-Disposition: attachment; filename=&quot;&#39;.basename($file).&#39;&quot;&#39;);<br>readfile($file);</pre><p>I immediately contacted the website’s owner to inform them about the vulnerability I had randomly stumbled upon. I later realized the website was owned by a larger company.</p><p>Thankfully, they responded within an hour, thanking me and asked if I could do a thorough penetration test (pentest), as their website had been hacked several times before.</p><h4>Part 2: Boring Stuff (Reflected XSS, SQL Injection)</h4><p>This is probably the simplest part of all, because all I did was run a broad vulnerability scan on all the listed in-scope sites that the company gave me. I usually use Burp Suite and Nuclei to handle all the automation and go from there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*9u3jNlBNzU0y9VfMmVdC7g.png" /><figcaption>That’s a lot</figcaption></figure><p>Even though a high number of them are false positives, a lot of them are still true positive. This is mostly because the company is using an old CMS framework, the only solution is just to upgrade the CMS to a newer version.</p><h4>Part 3: Arbitrary File Read (<a href="https://nvd.nist.gov/vuln/detail/cve-2022-44268">CVE-2022–44268</a>)</h4><p>Now this is where it starts to get interesting. CVE-2022–44268 is a vulnerability caused by ImageMagick. There’s actually another part of it, CVE-2022–44267, a vulnerability also caused by ImageMagick’s PNG parsing, but it’s a Denial of Service attack, not so interesting.</p><p>This arbitrary file read vulnerability is caused by ImageMagick trying to read a “Profile” tEXt (Textual data) chunk (read <a href="https://www.w3.org/TR/PNG-Chunks.html#:~:text=4.2.7.%20tEXt%20Textual%20data">here</a> for PNG specs, it’s a lot to take in), and tries to insert the chosen image profile into the PNG. The only problem is that, well, an attacker can control the Profile tEXt, hence, arbitrary file read (read <a href="https://www.metabaseq.com/threat/imagemagick-zero-days/">here</a> for further vulnerability breakdown).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*lpfSDw-J91X0iTEG9IFmNA.png" /><figcaption>The problematic function, the problematic line is actually way below</figcaption></figure><p>I just inserted a Profile tEXt chunk using python with the help of png library, and set the payload for which file I want to read, in this example I used <em>/etc/passwd</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*PairLqU2SqL-uAPrn7eFsg.png" /><figcaption>It’s just some small PNG</figcaption></figure><p>And after sending it to the website for converting, resizing, or basically anything that requires ImageMagick to parse this PNG, I got an innocent image back. But, if you look deeper into the image (funnily enough using <a href="https://linux.die.net/man/1/identify">identify</a>, part of ImageMagick itself):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*mzJykkzEyoeoTlRcAfNr1g.png" /><figcaption>Hex :D</figcaption></figure><p>I got a load of hex characters on “Raw profile type” key, and if you try to decode it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XGpBLWDs1R7yZf-8HFYyVQ.png" /><figcaption>:0</figcaption></figure><p>Voila! You got the content of <em>/etc/passwd</em> just by uploading an image. This method could read any file as long as ImageMagick has the required permission to read it.</p><h4>Part 4: LaTeX Injection</h4><p>At this point, I haven’t actually found any critical vulnerability the company wants me to find, an RCE vulnerability that is (I couldn’t get an OS shell from the SQL injection). So I stopped mindlessly poking around and tried to approach it more methodically.</p><p>Kindly enough, they gave me a list on which endpoint was accessed the most on the day they got hacked. One of them stood out amongst the others.</p><blockquote>“What’s LaTeX?”</blockquote><p>Apparently, LaTeX is a programming language for document typesetting, weird, I know. They used it as a service for online LaTeX editor on their website. This, on a glance, didn’t look like much, but the keyword “programming language” is so interesting not to check out.</p><blockquote>“Who, in their right mind, would expose an old programming language, that is running on their server?”</blockquote><p>And I finally looked it up, “LaTeX Injection”, it actually exists, the man, the myth, the legend itself.</p><blockquote>“Well, let’s just copy this weird-looking command and see what happens.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*eX6y6mftWwJD7GgAjjTVSQ.png" /></figure><blockquote>“Ah, phew, it’s filtered. Time to look for the other endpoints, I guess.”<br>“…”<br>“What’s this? Replace a character with it’s Unicode hex value? Surely that won’t work, righ-”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*jLDH2X2AabVCoa8Qsh5zzA.png" /><figcaption>So called “won’t work” actually working</figcaption></figure><p>Yeah, so…, that works. After a bit more digging, I also found out that almost every single parameter in the request to convert LaTeX to image is susceptible to LaTeX Injection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*DKY501igX9VnaQnHOQvNDw.png" /><figcaption>All except the file format for who knows why</figcaption></figure><p>And for the finale, I just crafted a malicious PHP payload to be written wherever this LaTeX is called from. At first I thought it might be a challenge to find where this TEX file is located, but apparently it’s just somewhere on the <em>upload/</em> folder where the file is going to be downloaded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*P6VEv7nqUULd9d0X8qwD2A.png" /><figcaption>Malicious payload</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*8ot6_uoRf03PsijB3EKOag.png" /><figcaption>RCE!</figcaption></figure><h4>Part 5: Resolution</h4><p>In total, for all critical, medium, and low severity vulnerabilities I’ve found, I cashed out around $600. That is considered low for a cyber security job, but considering how new I was and this is not some major corporation, I’d say all parties are happy with what they get.</p><p>With all that being said, I hope this story could inspire people to get into tech, especially cyber security and bug hunting. Remember kids to always hack ethically. So, get out there, stay curious, and make the internet a safer place, one bug at a time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98b961a62f4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>