<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Malina Stepińska</title>
    <description>The latest articles on DEV Community by Malina Stepińska (@gh0stbloom).</description>
    <link>https://dev.to/gh0stbloom</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4129452%2F925e6989-0485-4b33-b5f5-1354d005b5b9.jpg</url>
      <title>DEV Community: Malina Stepińska</title>
      <link>https://dev.to/gh0stbloom</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gh0stbloom"/>
    <language>en</language>
    <item>
      <title>SQL injection in the WHERE clause: how to reach unreleased products (PortSwigger)</title>
      <dc:creator>Malina Stepińska</dc:creator>
      <pubDate>Thu, 12 Nov 2026 11:49:04 +0000</pubDate>
      <link>https://dev.to/gh0stbloom/sql-injection-in-the-where-clause-how-to-reach-unreleased-products-portswigger-2089</link>
      <guid>https://dev.to/gh0stbloom/sql-injection-in-the-where-clause-how-to-reach-unreleased-products-portswigger-2089</guid>
      <description>&lt;h1&gt;
  
  
  SQL injection in the WHERE clause: how to reach unreleased products (PortSwigger)
&lt;/h1&gt;

&lt;p&gt;Another lab from PortSwigger Academy: &lt;strong&gt;SQL injection vulnerability in WHERE clause allowing retrieval of hidden data&lt;/strong&gt;. The goal is simple: display one or more unreleased products via SQL injection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Starting point
&lt;/h2&gt;

&lt;p&gt;The shop filters products by category. In Burp I intercepted the request for opening a product description. The GET request includes the parameter &lt;code&gt;productID=6&lt;/code&gt;, the product number.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hypothesis
&lt;/h2&gt;

&lt;p&gt;Task tells us that server-side SQL query contains a &lt;code&gt;released = 1&lt;/code&gt; condition. If so, perhaps &lt;code&gt;released = 0&lt;/code&gt; would show products that haven't gone on sale yet. So the trick is to make that condition stop applying.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where I got stuck
&lt;/h2&gt;

&lt;p&gt;I forgot that closing the query takes more than an apostrophe &lt;code&gt;'&lt;/code&gt;. You also need to &lt;strong&gt;comment out the rest of the statement&lt;/strong&gt;, which is what the double dash &lt;code&gt;--&lt;/code&gt; does. Without it, the remainder of the query either breaks the syntax or keeps filtering the results.&lt;/p&gt;

&lt;p&gt;Then came a second problem. In the "Gifts" category one unreleased product showed up, but the lab wasn't marked as solved. I looked at the solution and it turned out you need to display &lt;strong&gt;all&lt;/strong&gt; products using the &lt;code&gt;1=1&lt;/code&gt; method. In my opinion that contradicts the task wording "one or more", since the task suggests that one product or a few is enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exploit
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="s1"&gt;' OR 1=1--
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The condition &lt;code&gt;1=1&lt;/code&gt; is always true, so the query returns every product, including those with &lt;code&gt;released = 0&lt;/code&gt;. Just &lt;code&gt;'--&lt;/code&gt; on its own should work too.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to defend against it
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Parameterized queries.&lt;/strong&gt; User input is passed to the query as a parameter rather than concatenated into the query text, so &lt;code&gt;'&lt;/code&gt; and &lt;code&gt;--&lt;/code&gt; can't change the query's structure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;With SQLi, think about the whole query, not just the injection point: you need to close the string and comment out the rest.&lt;/li&gt;
&lt;li&gt;Solving a lab can depend on a specific condition being checked, not just on the results looking right.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cybersecurity</category>
      <category>security</category>
      <category>sql</category>
    </item>
  </channel>
</rss>
