Skip to content
SQL injection Write-up Intermediate

I Broke Into a Database With (1=1).

An unauthenticated API endpoint accepted a raw string as an ID and concatenated it into a SQL query, allowing boolean-based blind SQL injection. An attacker could extract the entire database character by character, bypassing a WAF using PostgreSQL type casting.

srck_ Follow

Published on medium.com

The client operates in the industrial automation and energy infrastructure sector — the kind of company whose technology keeps factories and power systems running. Their engineering teams are building a modern, API-first asset management platform for their customers.

SRCK, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the application concatenated user input directly into a SQL query without parameterisation or type validation, and the endpoint lacked authentication.

Impact

An unauthenticated attacker could extract the entire database, including internal operational data, despite the presence of a WAF that was bypassed.

What the attacker needed

No authentication required; Network access to the API endpoint; WAF bypass technique known

The fix

The endpoint should use parameterised queries, enforce strict integer validation, require authentication, and apply least privilege to database accounts.

How it was found

  1. Send a request to the endpoint with a JSON body containing an id field set to a raw string.
  2. Observe that the endpoint returns data without requiring any authentication.
  3. Send a payload that evaluates to true, such as a boolean expression cast to integer, and observe full results.
  4. Send a payload that evaluates to false and observe an empty result, confirming a boolean oracle.
  5. Use PostgreSQL functions to extract the database name character by character via true/false responses.
  6. Automate the extraction with a script that performs binary search for length and linear scan for characters.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The API took an ID from the user and put it directly into a database command without checking it. By sending a special value that evaluates to true or false, the attacker could ask the database yes/no questions and slowly read out all its data. A firewall tried to block common attack words, but the attacker used a different way to write the same logic that the firewall did not recognise.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

More by srck_

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.