<?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 C4PTR4 on Medium]]></title>
        <description><![CDATA[Stories by C4PTR4 on Medium]]></description>
        <link>https://medium.com/@roshan.reju?source=rss-e661ac2a0084------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JZ9Ah8tDSPiDXsjHSIwT1w.png</url>
            <title>Stories by C4PTR4 on Medium</title>
            <link>https://medium.com/@roshan.reju?source=rss-e661ac2a0084------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 21:08:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@roshan.reju/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[Rowhammer Attacks: Exploiting DRAM Vulnerabilities in Modern Systems ^_^]]></title>
            <link>https://medium.com/@roshan.reju/rowhammer-attacks-exploiting-dram-vulnerabilities-in-modern-systems-3160f01c6995?source=rss-e661ac2a0084------2</link>
            <guid isPermaLink="false">https://medium.com/p/3160f01c6995</guid>
            <category><![CDATA[hardware]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[exploit]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[computers]]></category>
            <dc:creator><![CDATA[C4PTR4]]></dc:creator>
            <pubDate>Thu, 12 Dec 2024 20:37:26 GMT</pubDate>
            <atom:updated>2024-12-12T20:37:26.488Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern computing relies heavily on <strong>Dynamic Random-Access emory(DRAM)</strong> which is used for high-performance and high-density form of volatile storage. However, as DRAM technology advances, it also becomes increasingly susceptible to hardware-level vulnerabilities. Among these, the <strong>Rowhammer attack</strong> stands out as a fascinating yet alarming exploit that manipulates DRAM&#39;s physical properties to alter data, bypass security mechanisms, and compromise systems.</p><p>In this article, we’ll explore the <strong>background of Rowhammer attacks,</strong> <strong>how they work, and the defense mechanisms designed to mitigate them</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/0*IilAr0VTI_FQBNQm.jpg" /></figure><h3><strong>Understanding DRAM Architecture :</strong></h3><p>DRAM stores data in a <strong>matrix of cells</strong>, where each cell consists of:</p><ul><li>A <strong>capacitor</strong> (to hold electrical charge representing binary data).</li><li>A <strong>transistor</strong> (to control access to the capacitor).</li></ul><p>These cells are organized into <strong>rows</strong> (word lines) and <strong>columns</strong> (bit lines). Accessing data involves opening a specific row and column to read or write the desired value.</p><p>However, the high-density arrangement of DRAM cells introduces a phenomenon called <strong>electrical interference</strong>, which is the key to understanding Rowhammer attacks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*KkroJURhPDdCO_whkpvnHg.png" /><figcaption>DRAM Architecture from <a href="https://csg.csail.mit.edu/6.888Yan/slides/9-Rowhammer.pdf">Rowhammer</a> Paper from MIT</figcaption></figure><blockquote><strong>What is a Rowhammer Attack?</strong></blockquote><p>A Rowhammer attack exploits the physical properties of DRAM by repeatedly accessing (or “hammering”) a specific row of memory cells. This causes <strong>charge leakage</strong> in neighboring rows, potentially flipping bits in the adjacent rows.</p><p><strong>Bit Flips:</strong> A “bit flip” is when a memory cell’s state changes unintentionally (e.g., from 0 to 1 or vice versa). This seemingly small change can have severe consequences, such as:</p><ul><li>Corrupting sensitive data.</li><li>Bypassing security mechanisms.</li><li>Injecting malicious code.</li></ul><blockquote><strong>How a Rowhammer Attack Works </strong>°−°</blockquote><ol><li><strong>Identifying Target Rows:</strong> Map the physical layout of DRAM to locate rows adjacent to sensitive data.</li><li><strong>Hammering the Target Row:</strong> Use specific instructions to repeatedly access (hammer) the target row, inducing charge leakage.</li><li><strong>Monitoring for Bit Flips:</strong> Check for unintended data changes in neighboring rows.</li></ol><blockquote><strong>Real-World Examples</strong></blockquote><p>Rowhammer attacks have been used in:</p><ul><li><strong>Flip Feng Shui - Hammering a Needle in the Software Stack:</strong> A technique to corrupt data in co-hosted virtual machines. So it basically exploits the Rowhammer bug and memory deduplication to induce controlled bit flips, enabling malicious VMs to compromise co-hosted VMs by corrupting targeted data in the software stack. (<a href="https://www.usenix.org/conference/usenixsecurity16">Read more about this here!</a>):)</li><li><strong>DRAMMER -Deterministic Rowhammer Attacks:</strong> A Rowhammer-based attack targeting Android devices. The DRAMMER attack exploits predictable memory reuse patterns to perform deterministic Rowhammer-based privilege escalation on ARM-based mobile platforms without relying on software vulnerabilities or user permissions. (<a href="https://dl.acm.org/doi/10.1145/2976749.2978406">Read more about this here!</a>):)</li></ul><p>Now comes the exciting part: let’s explore how this attack can be executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cQv-aw6_pQbO35uY.jpg" /></figure><blockquote><strong>Performing a Rowhammer Attack:</strong></blockquote><h4>Step 1: Identifying Target Rows</h4><ul><li><strong>Reverse-Engineering Memory Layout</strong>: Use timing analysis and side-channel attacks to map the physical arrangement of rows in DRAM.</li><li><strong>Focus on Adjacent Rows</strong>: Target rows adjacent to sensitive data, as they are most susceptible to bit flips.</li></ul><h4>Step 2: Hammering the Target Row</h4><ul><li><strong>Rapid Memory Access</strong>: Use instructions like clflush or non-temporal memory operations to bypass the CPU cache and directly access DRAM.</li><li><strong>Double Hammering</strong>: Simultaneously hammer two rows to maximize the chance of flipping bits in the row sandwiched between them, bypassing defenses like Target Row Refresh (TRR).</li></ul><h4>Step 3: Monitoring for Bit Flips</h4><ul><li><strong>Validation</strong>: Continuously monitor neighboring rows for bit flips and log their locations.</li><li><strong>Exploitation</strong>: Use flipped bits to compromise critical data, such as authentication tokens, encryption keys, or system privileges.</li></ul><p>The below stage diagram from <a href="https://www.mdpi.com/1424-8220/24/2/592">Rowhammer Attacks in Dynamic Random-Access Memory</a> can be helpful to get more idea on these attacks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XvCRRncWL9q5WwM_.png" /></figure><blockquote><strong>Defending Against Rowhammer Attacks</strong></blockquote><p>To combat Rowhammer, various hardware and software defenses have been developed:</p><h4>1. Error-Correcting Code (ECC) Memory</h4><p><strong>How It Works</strong>: Adds redundant bits to detect and correct single-bit errors, reducing the impact of bit flips.</p><p><strong>Limitations</strong>:</p><ul><li>May fail to handle multi-bit errors.</li><li>Increases memory cost and latency.</li></ul><h4>2. Target Row Refresh (TRR)</h4><p><strong>How It Works</strong>: Tracks memory access patterns and refreshes neighboring rows if excessive activations are detected.</p><p><strong>Challenges</strong>: Advanced attacks can bypass TRR by hammering multiple rows or using randomized access patterns.</p><h4>3. Increased Refresh Rates</h4><p><strong>How It Works</strong>: Increases the frequency of DRAM refresh cycles to replenish charge and mitigate bit flips.</p><p><strong>Trade-Off</strong>: Higher refresh rates lead to increased power consumption and latency, affecting performance.</p><p>If you found this article useful, please share it with your network to raise awareness about hardware vulnerabilities.🦀 #DefendTogether💪</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3160f01c6995" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[❌Attacking JSON Web Tokens❌]]></title>
            <link>https://medium.com/@roshan.reju/attacking-json-web-tokens-892fc76b7fcf?source=rss-e661ac2a0084------2</link>
            <guid isPermaLink="false">https://medium.com/p/892fc76b7fcf</guid>
            <category><![CDATA[json-web-token]]></category>
            <category><![CDATA[attack]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[jwt]]></category>
            <dc:creator><![CDATA[C4PTR4]]></dc:creator>
            <pubDate>Fri, 17 Nov 2023 06:11:58 GMT</pubDate>
            <atom:updated>2023-11-17T07:11:07.208Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to JWT:</h3><p>JWT, which stands for JSON Web Token, is a compact, self-contained means of representing information between two parties in a way that can be verified and trusted. JWTs are commonly used for authentication and authorization purposes in web development and distributed systems.</p><h3>JWT Structure:</h3><p>It consists of header, payload and signature and is represented by putting a “.” in between each parameter.</p><p>Structure &gt;&gt; “header.payload.signature”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1LXLsgMFcJ_GcNxlfLVMfg.png" /></figure><p>Header: The header typically consists of two parts: the type of the token, which is JWT, and the signing algorithm being used, such as HMAC SHA256 or RSA.</p><p>Payload: The payload contains the claims. Claims are statements about an entity (typically, the user) and additional data. There are three types of claims: registered, public, and private claims. Eg: “iss” (issuer), “sub” (subject), “exp” (expiration time), and “roles” (user roles).</p><p>Signature: To create the signature part, the encoded header and payload are combined with a secret key. The signature is used to verify that the sender of the JWT is who it says it is and to ensure that the message wasn’t changed along the way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IwhsqlE0Lqk_usmLE8RpMA.png" /></figure><h4>How the entire concept of JWT works?</h4><p>It is pretty simple. After a user logs in, a server generates a JWT and sends it to the client. The client includes this token in the headers of subsequent requests to prove its identity.</p><p>Also, JWT is used with Single Sign On(SSO) as well where a user logs in once to access multiple applications without needing to log in again for each one.</p><p>It also helps with stateless authentication as the token contains all the necessary info already, so servers can verify a user’s identity without the need for additional database queries.</p><p>Enough of the boring stuff, coming to the interesting part of this writeup, the ATTACKS:</p><p>There are quite a few attacks which can be used against JWT tokens:</p><p>Before Starting off with the attacks in deep, I would like to mention a tool that I started using recently which helps with anything related to JWT tokens be it Recon, Scanning, exploits and so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*k4bgjsrha55Z34vDro-hVQ.png" /></figure><p><a href="https://github.com/ticarpi/jwt_tool#the-json-web-token-toolkit-v2">GitHub - ticarpi/jwt_tool: :snake: A toolkit for testing, tweaking and cracking JSON Web Tokens</a></p><p>There are a few good tools out there. Among those, the one I liked was The JSON Web Token Toolkit by Ticarpi which does the following:</p><ul><li>Checking the validity of a token</li><li>Testing for known exploits:</li></ul><p>(CVE-2015–2951) The alg=none signature-bypass vulnerability</p><p>(CVE-2016–10555) The RS/HS256 public key mismatch vulnerability</p><p>(CVE-2018–0114) Key injection vulnerability</p><p>(CVE-2019–20933/CVE-2020–28637) Blank password vulnerability</p><p>(CVE-2020–28042) Null signature vulnerability</p><ul><li>Scanning for misconfigurations or known weaknesses</li><li>Fuzzing claim values to provoke unexpected behaviours</li><li>Testing the validity of a secret/key file/Public Key/JWKS key</li><li>Identifying weak keys via a High-speed Dictionary Attack</li><li>Forging new token header and payload contents and creating a new signature with the key or via another attack method</li><li>Timestamp tampering</li><li>RSA and ECDSA key generation, and reconstruction (from JWKS files).</li></ul><p>We start with understanding the values in the token:</p><pre>{<br> &quot;alg&quot;: &quot;HS256&quot;,<br> &quot;typ&quot;: &quot;JWT&quot;<br>}.<br>{<br> &quot;name&quot;: &quot;Bob Marley&quot;,<br> &quot;user_name&quot;: &quot;bob.marley&quot;,<br> &quot;is_admin&quot;: false<br>}</pre><p>Then we can scan the token for common misconfigurations using the jwt_tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*mXxl48fqQIdc_gL0AVSWyg.png" /></figure><p>We have intentionally taken a vulnerable JWT token. Every green line above indicates a positive finding in the scan.</p><p>Testing of these misconfigurations and manual testing on these tokens can be done using the JSON Web Tokens extension in <strong>Burp Suite</strong>.</p><ol><li><strong>Signature Verification failure:</strong></li></ol><ul><li>The ideal way to implement JWT is by setting one method to decode the token and another to verify it. But in some cases there might be developer logic error in decode() method or verify() method. That’s where this vulnerability rises.</li><li>Consider the token where we did the recon on.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*7OGEk-W0EAY96kpJrgosqA.png" /></figure><ul><li>Here, we can see the id_admin : false field. We can try and modify it to true.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*inNhw9iB8fY0l9dOnPTJYg.png" /></figure><ul><li>In this case, the verification of the token signature does not happen so this modification goes through and the user get admin privileges.</li></ul><p>2.<strong> None Algorithm Acceptance:</strong></p><p>When algorithm parameter is given as “none” and we get a OK response, then the token is vulnerable to None Algorithm vulnerability.</p><p>We can simply strip the signature off of a token like the one shown below</p><pre>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.<br>eyJuYW1lIjoiSm9obiBEb2UiLCJ1c2VyX25hbWUiOiJqb2huLmRvZSIsImlzX2FkbWluIjpmYWxzZX0..<br>(sig)fSppjHFaqlNcpK1Q8VudRD84YIuhqFfA67XkLam0_aY(sig)</pre><pre>eyJhbGciOiJOb25lIiwidHlwIjoiSldUIn0.<br>eyJuYW1lIjoiSm9obiBEb2UiLCJ1c2VyX25hbWUiOiJqb2huLmRvZSIsImlzX2FkbWluIjp0cnVlfQ.</pre><p>The stripped off token goes through and the attacker can simply use it to replace the valid algorithm and then get rid of the signature.</p><p>Therefore algo types like None, none, NONE, nOnE, or any other case variations should never be accepted in the “alg” header.</p><p>3. <strong>Algorithm Confusion:</strong></p><p>Both symmetric and asymmetric encryption algorithms are used with JWT tokens.</p><p>Eg: Symmetric algo like HMAC uses the same secret key is used both to sign and verify the JWT.</p><p>And Asymmetric algos like RSA uses private key for signing, and a corresponding public key is used for verification.</p><p>The algorithm confusion vulnerability arises when an application does not check whether the algorithm of the received token matches the expected algorithm.</p><ul><li>In some libraries, the verification method might be verify(token, secret) for HMAC or verify(token, publicKey) for RSA.</li><li>However, in certain cases, this method alone might not ensure that the algorithm used in the token aligns with what the application expects.</li></ul><p>Let’s say an attacker can access the public key used by the application. They can exploit this by:</p><p># Changing the algorithm in the token to HMAC.</p><p># Modifying the payload to suit their goals.</p><p># Using the public key to sign the malicious token.</p><p>To prevent this vulnerability, applications must be thorough. Before blindly passing a token to the verify() method, they should explicitly check if the algorithm used in the token aligns with what the application expects.</p><p>4. <strong>Kid Parameter Injection:</strong></p><p>The JWT token can contain a parameter known as Kid. It is often used to retrieve the key from a database or filesystem. The application verifies the signature using the key obtained through the Kid parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*LHQFTs7nDOkqme1k" /></figure><p>So this can create a lot of vulnerabilities if the Kid parameter is injectable.</p><p>And that’s exactly what we are going to focus on here.</p><p>We’ll be using the valid token shown below as an example:</p><pre>{<br>  &quot;alg&quot;: &quot;HS256&quot;,<br>  &quot;typ&quot;: &quot;JWT&quot;,<br>  &quot;kid&quot;: &quot;key1&quot;<br>}.<br>{<br>  &quot;name&quot;: &quot;Bob Marley&quot;,<br>  &quot;user_name&quot;: &quot;bob.marley&quot;,<br>  &quot;is_admin&quot;: false<br>}</pre><p><strong>Attack1:</strong> Getting an RCE if the Kid parameter is injectable.</p><pre>{<br>  &quot;alg&quot;: &quot;HS256&quot;,<br>  &quot;typ&quot;: &quot;JWT&quot;,<br>  &quot;kid&quot;: &quot;key1|/usr/bin/uname&quot;<br>}.<br>{<br>  &quot;name&quot;: &quot;Bob Marley&quot;,<br>  &quot;user_name&quot;: &quot;bob.marley&quot;,<br>  &quot;is_admin&quot;: false<br>}</pre><p><strong>Attack2:</strong> Considering the Kid parameter is vulnerable, we can couple it with directory traversal vulnerability which can lead into signature bypass.</p><p>As we already know by now, the key parameter fetches the key from the system to verify it. So if it is vulnerable to directory traversal attack then attacker can force the application to use a file whose value the attacker can predict as a key for verification.</p><pre>{<br>  &quot;alg&quot;: &quot;HS256&quot;,<br>  &quot;typ&quot;: &quot;JWT&quot;,<br>  &quot;kid&quot;: &quot;../../../../../../dev/null&quot;<br>}.<br>{<br>  &quot;name&quot;: &quot;Bob Marley&quot;,<br>  &quot;user_name&quot;: &quot;bob.marley&quot;,<br>  &quot;is_admin&quot;: false<br>}</pre><p>If the directory traversal to /dev/null succeeds, the attacker will be able to sign a malicious token using an empty string.</p><p>Sounds Scary!</p><p><strong>Attack3:</strong> Considering the Kid parameter is vulnerable, we can couple it with SQL injection vulnerability which can lead into signature bypass.</p><p>If the Kid is vulnerable to SQL Injection attack can control the value returned to the kid parameter from an SQL query and use it to sign a malicious token.</p><p>Consider that the developer uses SELECT key FROM keys WHERE key=’key1&#39; to fetch the key.</p><p>We can use UNION SELECT statement into the Kid as an example:</p><pre>{<br>  &quot;alg&quot;: &quot;HS256&quot;,<br>  &quot;typ&quot;: &quot;JWT&quot;,<br>  &quot;kid&quot;: &quot;xxxx&#39; UNION SELECT &#39;aaa&quot;<br>}.<br>{<br>  &quot;name&quot;: &quot;Bob Marley&quot;,<br>  &quot;user_name&quot;: &quot;bob.marley&quot;,<br>  &quot;is_admin&quot;: false<br>}</pre><p>If the Kid is vulnerable to SQL Injection attack and this payload succeeds, application will use SELECT key FROM keys WHERE key=’xxxx’ UNION SELECT ‘aaa’ to fetch the key from the system.</p><p>This query returns “aaa” into the Kid parameter and the attacker can maliciously sign the token.</p><p>To defend against the Kid parameter injection, sanitation of the Kid field is necessary.</p><p>5. <strong>Attacks on the “JKU” header in the token:</strong></p><p>Developers use the JKU header in the JWT token to specify where the application can find the <a href="https://tools.ietf.org/html/rfc7517">JSON Web Key (JWK)</a> used to verify the signature which is basically the public key in JSON format.</p><pre>{<br>  &quot;alg&quot;: &quot;RS256&quot;,<br>  &quot;typ&quot;: &quot;JWT&quot;,<br>  &quot;kid&quot;: &quot;https://example.com/key.json&quot;<br>}.<br>{<br>  &quot;name&quot;: &quot;Bob Marley&quot;,<br>  &quot;user_name&quot;: &quot;bob.marley&quot;,<br>  &quot;is_admin&quot;: false<br>}</pre><p>The content of key.json files can be as shown below:</p><pre>{<br>  &quot;kty&quot;: &quot;RSA&quot;,<br>  &quot;n&quot;: &quot;zTfU2oIeZDZtNQcBQye6aL9H7l3yYg8n3vXy-.......Hwr5w&quot;,<br>  &quot;e&quot;: &quot;AQAB&quot;<br>}</pre><p>The attacker can try to replace or point the link to the public key to his own public key or a different public key and if the alternate key goes through, then the attacker can maliciously sign the tokens using his private key.</p><p>After the malicious token is sent, the application will fetch the attacker’s JWK and use it to verify the signature.</p><p>One way to prevent such attacks are whitelisting permitted hosts and have correct URL filtering in place.</p><p>We have seen some of the attacks on the JWT tokens. Now we’ll see some of the <strong>defenses</strong> that can be applied for securing the tokens:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*bNCIApZ6nsBAX3Rt" /></figure><ol><li>Strong Secret Keys:</li></ol><ul><li>Use long, random secret keys to sign JWTs securely.</li></ul><p>2. Token Expiration:</p><ul><li>Set reasonable expiration times for JWTs to limit their usability window.</li></ul><p>3. Token Refresh Mechanism:</p><ul><li>Implement token refresh mechanisms to mitigate the impact of compromised tokens.</li></ul><p>4. Validate Token Signatures:</p><ul><li>Always validate JWT signatures to prevent attackers from forging tokens.</li></ul><p>5. Use HTTPS:</p><ul><li>Transmit JWTs over HTTPS for secure data transit.</li></ul><p>6. Avoid Storing Sensitive Information:</p><ul><li>Minimize sensitive data in JWT payloads, keeping it on the server when possible.</li></ul><p>7. Implement Proper Access Controls:</p><ul><li>Enforce access controls on the server side, regardless of token validity.</li></ul><p>8. Token Blacklisting:</p><ul><li>Implement mechanisms to blacklist or revoke compromised tokens.</li></ul><h4>Conclusion:</h4><p>In a nutshell, diving into the world of JWTs is like exploring secret codes for web security. JWTs, or JSON Web Tokens, help parties share info securely online, often used for logins and permissions.</p><p>But here’s the catch — there are potential attacks! From tricking signatures to messing with algorithms, attackers can find weak spots. Tools like the JSON Web Token Toolkit can help spot and fix these issues during security tests.</p><p>To keep things secure, use strong secret keys, set short expiration times, and check signatures. Also, be smart about HTTPS, avoid storing super-secret stuff, and have a plan for compromised tokens.</p><p>Understanding these JWT ins and outs helps everyone — from developers to security buffs — stay on top of web security. Stay sharp, stay safe, and keep those JWTs in check!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=892fc76b7fcf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Penetration Testing Your Web Application Firewall: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@roshan.reju/penetration-testing-your-web-application-firewall-a-step-by-step-guide-325cebb66915?source=rss-e661ac2a0084------2</link>
            <guid isPermaLink="false">https://medium.com/p/325cebb66915</guid>
            <category><![CDATA[waf]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[steps]]></category>
            <category><![CDATA[web-application-firewall]]></category>
            <category><![CDATA[pentest]]></category>
            <dc:creator><![CDATA[C4PTR4]]></dc:creator>
            <pubDate>Tue, 07 Feb 2023 08:32:39 GMT</pubDate>
            <atom:updated>2023-02-07T08:32:39.898Z</atom:updated>
            <content:encoded><![CDATA[<h4>What is a WAF?</h4><p>Web Application Firewall (WAF) is an essential tool for safeguarding modern websites and applications against a range of malicious attacks. In today’s connected world, the internet has become the primary platform for businesses to interact with their customers. As a result, websites and web applications are now more vulnerable to cyber attacks, making WAF a necessary security layer.</p><figure><img alt="WAF placement in a data path&gt;&gt;" src="https://cdn-images-1.medium.com/max/766/1*IGjNdb5xfV5U_yXpIrKB2Q.gif" /><figcaption>WAF Placement in a data path</figcaption></figure><p>The main idea here is to place the WAF as close to the web applications it is protecting as possible, while still ensuring that it can inspect all incoming and outgoing traffic to and from the web applications.</p><h4>Various industry-leading web application firewalls (WAFs) used out there:</h4><ol><li><a href="https://aws.amazon.com/waf/">AWS WAF</a></li><li><a href="https://azure.microsoft.com/en-us/products/web-application-firewall">Azure WAF</a></li><li><a href="https://www.akamai.com/us/en/products/web-application-security/kona-site-defender.jsp">Akamai Kona Site Defender</a></li><li><a href="https://www.barracuda.com/products/webapplicationfirewall">Barracuda WAF</a></li><li><a href="https://www.f5.com/products/big-ip/application-security-manager">F5 BIG-IP Application Security Manager (ASM)</a></li><li><a href="https://www.imperva.com/products/waf/">Imperva Incapsula</a></li><li><a href="https://www.citrix.com/products/netscaler-adc/">Citrix NetScaler ADC</a></li><li><a href="https://www.paloaltonetworks.com/products/traps">Palo Alto Networks Traps</a></li><li><a href="https://www.radware.com/product/defensepro/">Radware DefensePro</a></li><li><a href="https://www.fortinet.com/products/web-application-firewall">Web Application Firewall (WAF) by Fortinet</a></li><li><a href="https://www.checkpoint.com/products/cloudguard-waf/">Check Point CloudGuard WAF</a></li></ol><p>These WAFs are used by organizations to protect against web-based attacks, such as SQL injection, cross-site scripting (XSS), and distributed denial of service (DDoS) attacks. The choice of WAF depends on the specific needs and budget of an organization, as well as its security requirements. Organizations can study and compare these options and choose the one that fits them the most.</p><h4>Why should we do a pentest for a WAF?</h4><p>A pentest (penetration test) of a WAF (Web Application Firewall) is important because it helps identify vulnerabilities and potential weaknesses in the system, which can then be addressed to improve the security of the web application it is protecting. A pentest provides an opportunity for ethical hackers to simulate real-world attacks and test the WAF’s effectiveness in preventing unauthorized access and other security threats. This information can then be used to make informed decisions about future improvements to the WAF’s configuration and deployment, helping to ensure the security and availability of the underlying web application. <br>Therefore it is important to test the effectiveness of a WAF by conducting a penetration test, also known as a pentest. In this article, we will discuss the steps involved in pentesting a web application firewall.</p><h4>Step 1: Information Gathering</h4><p>The first step in pentesting a WAF is to gather information about the target system. This includes finding the IP address of the website, the web server software being used, and the type of WAF in use. This information can be gathered using many tools.<br>I personally use Nmap, Whois, and Wafw00f.</p><figure><img alt="WafW00f Banner" src="https://cdn-images-1.medium.com/max/1024/1*k4Gbp2Z8eFvsMyOMpogFwQ.jpeg" /></figure><h4>Step 2: Identify Threats</h4><p>The next step is to identify potential vulnerabilities reported in the WAF and threats to the website. This will help in identifying the most likely types of attacks and their severity, allowing you to focus your testing efforts on the most critical areas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*gimSTvo2t7hDAQVRmiV7_A.gif" /></figure><p>This is one of the important steps in the whole process. Saves a lot of time :D.</p><p>OWASP Top 10 Project can be used as reference: <a href="https://owasp.org/Top10/">https://owasp.org/Top10/</a></p><h4>Step 3: Attacking / Testing</h4><p>The third step is to try different types of attacks shortlisted against the website and its WAF. This can be done using tools such as OWASP ZAP, Burp Suite, and Nessus. The objective of this step is to see if the WAF is able to detect and prevent the attacks, or if it is possible to bypass the WAF.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*Jq4_KOAb--3beSebg1Jg4w.gif" /></figure><p>There are also some automated tools for WAF testing out there.<br>One of the automated tools which I use is the GotestWaf by <a href="https://medium.com/u/78984bf6a74f">Wallarm</a>.</p><p>The tool is pretty fancy and generates a report too after the automated test.<br>You can clone the repo from this github link : <a href="https://github.com/wallarm/gotestwaf.git">https://github.com/wallarm/gotestwaf.git</a></p><p>Generally, several initial configurations are possible when first deploying your WaF. These configurations can be somewhat tedious as you need to learn/add URLs and parameters to your WaF.</p><h4>So following the below methods can help us understand the WAF at a more deeper level:</h4><ul><li>Check if restrictions are placed for URL access only.</li><li>Check if there are URL restriction and parameter inspection.</li><li>Test parameter checking for basic JSON/SOAP specific traffic if your application uses specific web services.</li><li>Test for file upload vulnerabilities and inspect if malicious content can be uploaded and bypass the restrictions(Only if File Upload Functionality is present).</li></ul><h4>The tests given above will need to be tested with different kinds of payloads and attack signatures:</h4><ul><li>Encoded and non-encoded SQL injection, XSS, OS Injection, LDAP Injection, XML Injection, Path Traversal, Local File Inclusion, Remote File Inclusion etc.</li><li>Header manipulation techniques — Attacking cookie/Referer/Host headers etc.</li><li>Masked data — shikata_ga_nai(Encoding used to obfuscate shell code) and Base64 encoding etc.</li><li>File Scanning manipulation — masked and unmasked malware signatures.</li></ul><h4>Step 4: Evaluation</h4><p>The final step is to evaluate the results of the pentest and make recommendations for improving the security of the website and its WAF. This includes identifying any vulnerabilities that were not detected by the WAF and suggesting changes to the WAF configuration to improve its effectiveness.</p><p>In conclusion, pentesting a web application firewall is an important step in ensuring the security of a website. By simulating different types of attacks, you can assess the effectiveness of the WAF and make changes to improve its security. It is important to conduct regular pentests to stay ahead of evolving cyber threats.</p><p>Fin…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*kxBvmeovdjj6CkmvDcG9nA.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=325cebb66915" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>