Skip to content
SQL injection Write-up Intermediate

Step by Step Exploiting SQLI in Oculus

The report describes a SQL injection vulnerability in the 'Domain' parameter of Oculus' website, demonstrated through boolean-based blind SQL injection payloads. An attacker could use this to extract arbitrary data from the database, such as column names from information_schema.

Josip Franjkovic Follow

Published on josipfranjkovic.blogspot.com

The original lives on josipfranjkovic.blogspot.com

We do not hold its text, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 5 min read.

What the report shows

The report is a short, step-by-step note on SQL injection in Oculus' website, published by Josip Franjković on his blog. It does not describe how the vulnerable feature was found, which endpoint or parameter was involved, what the application returned, or what the outcome was: no bounty, severity, fix or disclosure date is given. What it does contain is a sequence of payloads that show how the researcher moved from a boolean test to extracting data from the database.

The first payload is a boolean expression placed in a value that looks like an email address:

Text
Domain='and (select 1 union select case when (1)=1 then 1 else 2 end) and '@test.com

The second is the same idea with the whitespace removed and comments inserted:

Text
Domain='and(select(1)union(select(case/**/when(1)=1/**/then/**/1/**/else/**/2/**/end)))and'@test.com

Both use a CASE expression that returns 1 when the condition is true and 2 when it is false, combined with UNION SELECT and wrapped in a subquery. The condition (1)=1 is trivially true, so these are proof-of-concept tests: if the page behaves differently for a true condition than for a false one, the input reaches the SQL query unsanitised.

The report then lists two syntax notes that matter for building the extraction payload:

Text
LIMIT 0,1 is same as LIMIT 1 OFFSET 0
substr('Hello',1,1) can be used as
substr('Hello' from 1 for 1).

These are the alternative forms the researcher used to read a single character at a time. The final payload puts it all together and reads the first character of a column name from the information schema:

Text
'and(select(1)union(select(case/**/when((select/**/ascii(substr(column_name/**/from/**/1/**/for/**/1))/**/from/**/information_schema.columns/**/where/**/table_name/**/like/**/'xxxxxxxxxxxxxxx'/**/limit/**/1/**/offset/**/0))=97/**/then(1)else(2)end)))and'@test.com

Read from the inside out: substr(column_name from 1 for 1) takes the first character of a column name, ascii(...) turns it into a number, and the CASE compares that number to 97, the ASCII code for a lowercase a. The WHERE table_name LIKE 'xxxxxxxxxxxxxxx' clause restricts the search to one table, and LIMIT 1 OFFSET 0 picks the first matching row. A true result returns 1, a false result returns 2, and the difference in the response tells the attacker whether the guessed character is correct. Repeating this over positions and characters reconstructs column names, and the same pattern would work against table names or row data.

Root cause

The report implies, rather than states, that user-controlled input was concatenated into a SQL query without parameterisation. The payloads are written to fit inside a quoted string followed by an email domain, which suggests the value was interpolated directly into a query rather than bound as a parameter. The payloads use /**/ comments in place of spaces, but the report does not say why.

Impact

The payloads are built to ask the database true/false questions and read data one character at a time, including schema metadata from information_schema. In principle that extends to any data the database user can read. The report itself stops at the extraction technique and does not show what data was retrieved or how far the access went, so the practical impact on Oculus' systems is not documented here.

How this kind of bug works

SQL injection happens when an application builds a query by joining strings, and part of that string comes from the user. The database cannot tell the developer's SQL from the attacker's SQL, so anything the attacker types becomes part of the query's structure. In the payloads above a single quote is used to break out of the surrounding SQL, and the rest of the payload becomes SQL syntax.

Blind variants do not return query output directly. Instead the attacker turns the query into a yes/no question and observes a side channel: a different page, a different status code, a timing delay, or a different error. Boolean-based blind injection relies on the application rendering differently for a true and a false condition. Time-based blind injection uses functions that pause the database. Error-based injection forces the database to leak data inside an error message. Union-based injection appends a second result set to the original query.

The standard defence is parameterised queries (prepared statements), where the query structure is fixed before user data is attached, so data can never become syntax. Stored procedures used correctly, strict allow-lists for values that cannot be parameterised (such as column or table names), least-privilege database accounts, and disabling detailed error messages all reduce exposure. Input filtering and escaping are weaker: they are easy to get wrong.

How to test for it

  1. Map every place user input reaches the application: query strings, form fields, JSON bodies, cookies, headers, and values that look like identifiers such as email addresses or sort keys.
  2. Send a value containing a single quote and compare the response with the original. Look for a database error, a changed status code, a truncated page, or a different redirect.
  3. If errors are suppressed, send a pair of requests that should produce a true and a false condition, for example a comparison that is always true versus one that is always false, and compare the two responses byte for byte.
  4. If the responses differ, confirm with a third request that should behave like the true case, to rule out caching or randomness.
  5. Move to extraction: ask questions about information_schema or about known values, one character at a time, and check that the answers are consistent across repeated requests.

A positive result is a reproducible, deterministic difference between a true and a false condition, or a database error that reveals query structure. Common false positives include pages that vary for unrelated reasons (ads, timestamps, A/B tests, rate limiting), values that are validated but produce a generic error page, and differences caused by caching. Always repeat requests and compare like with like.

How it is fixed

Use parameterised queries everywhere, including in ORMs and query builders where raw fragments are easy to introduce. Where a value cannot be a parameter, such as a sort column, map it against a fixed allow-list. Give the application's database account only the permissions it needs, so a successful injection cannot read or write beyond its own schema. Turn off verbose database errors in production and log them server-side instead. Add a web application firewall as a layer, not as the fix.

Hunting notes

Injection tends to hide in less obvious inputs: email and domain fields, sort and filter parameters, JSON keys, headers used for logging or analytics, and older or internal-facing endpoints that skip the framework's query builder. Recon signals include parameters that accept structured values, endpoints that echo input back, error pages that mention SQL, and applications that mix raw SQL with an ORM. Stop at the minimum needed to prove access, and never touch other users' data.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 8 min read.

What happened, in plain words

This is a short, step-by-step note by Josip Franjković about SQL injection in Oculus' website. It does not say how the vulnerable feature was found, which page or parameter was involved, what the site returned, or what came of it. No bounty, severity, fix or disclosure date is given. What it does contain is a chain of payloads showing how the researcher moved from a simple true/false test to reading data out of the database.

A few ideas first, because the whole report depends on them.

A database is the program a website uses to store and look up its data: user accounts, settings, records. It is asked questions in a language called SQL, for example "give me the row whose email is this one".

SQL injection is what happens when a website builds such a question by gluing text together, and part of that text comes from the visitor. The database cannot tell the developer's SQL from the visitor's SQL, so anything typed in becomes part of the question's structure. A single quote is the character that ends a piece of text in SQL, so typing one can close the developer's text early and let the rest of the input act as SQL.

Blind injection means the site never shows the query's output. Instead the attacker turns the query into a yes/no question and watches for a difference in the page: a different message, a different status, a different error. If true and false look different, the attacker can ask questions and learn answers one bit at a time.

With that in mind, here is the sequence.

Step 1: a true/false test

The first payload is placed in a value that looks like an email address:

Text
Domain='and (select 1 union select case when (1)=1 then 1 else 2 end) and '@test.com

Line by line:

  • Domain=' closes the text the site was building and starts the attacker's SQL.
  • and (select ...) attaches a subquery, a query inside a query.
  • select 1 union select ... combines two result sets. UNION means "also return these rows".
  • case when (1)=1 then 1 else 2 end is a conditional: if the condition is true return 1, otherwise return 2. Here (1)=1 is always true, so this is a proof of concept.
  • and '@test.com closes the payload so the rest of the original email value still fits the query's syntax.

The point of this step is confirmation. If the page behaves one way for a true condition and another way for a false one, the input is reaching the SQL query without being neutralised.

Step 2: the same test, hardened

The second payload is the same idea with the spaces removed and comments inserted:

Text
Domain='and(select(1)union(select(case/**/when(1)=1/**/then/**/1/**/else/**/2/**/end)))and'@test.com

In SQL, /**/ is a comment, and a comment can stand in for a space. Writing case/**/when instead of case when keeps the statement valid while avoiding literal spaces. The researcher used this form, but the report does not say why.

Step 3: two syntax notes

Before extracting data, the report records two equivalences it relies on:

Text
LIMIT 0,1 is same as LIMIT 1 OFFSET 0
substr('Hello',1,1) can be used as
substr('Hello' from 1 for 1).

LIMIT controls how many rows come back, and OFFSET says how many to skip, so LIMIT 1 OFFSET 0 means "one row, starting from the first". substr takes a piece of a piece of text: substr('Hello',1,1) is the first character, H. The from ... for ... spelling does the same thing. These are the alternative forms used to read a single character at a time.

Step 4: reading a character

The final payload puts everything together and reads the first character of a column name from the database's own catalogue of its structure:

Text
'and(select(1)union(select(case/**/when((select/**/ascii(substr(column_name/**/from/**/1/**/for/**/1))/**/from/**/information_schema.columns/**/where/**/table_name/**/like/**/'xxxxxxxxxxxxxxx'/**/limit/**/1/**/offset/**/0))=97/**/then(1)else(2)end)))and'@test.com

Read from the inside out:

  • information_schema.columns is a built-in table that lists every column of every table, with its name and the table it belongs to.
  • where table_name like 'xxxxxxxxxxxxxxx' restricts the search to one table. The x string is a placeholder for a table name.
  • limit 1 offset 0 picks the first matching row.
  • substr(column_name from 1 for 1) takes the first character of that column's name.
  • ascii(...) turns that character into a number, because numbers are easier to compare.
  • case when (...) = 97 then 1 else 2 end asks: is that number 97? 97 is the ASCII code for a lowercase a.

A true answer returns 1, a false answer returns 2, and the difference in the response tells the attacker whether the guessed character is right. Repeating this over positions and characters rebuilds column names, and the same pattern works for table names or row data.

In general, how this kind of bug works

SQL injection happens when an application builds a query by joining strings and part of that string comes from the user. The database cannot tell the developer's SQL from the attacker's SQL, so anything the attacker types becomes part of the query's structure. In the payloads above a single quote is used to break out of the surrounding SQL, and the rest of the payload becomes SQL syntax.

Blind variants do not return query output directly. Instead the attacker turns the query into a yes/no question and observes a side channel: a different page, a different status code, a timing delay, or a different error. Boolean-based blind injection relies on the application rendering differently for a true and a false condition. Time-based blind injection uses functions that pause the database. Error-based injection forces the database to leak data inside an error message. Union-based injection appends a second result set to the original query.

The standard defence is parameterised queries (prepared statements), where the query structure is fixed before user data is attached, so data can never become syntax. Stored procedures used correctly, strict allow-lists for values that cannot be parameterised (such as column or table names), least-privilege database accounts, and disabling detailed error messages all reduce exposure. Input filtering and escaping are weaker: they are easy to get wrong.

How to test for it

  1. Map every place user input reaches the application: query strings, form fields, JSON bodies, cookies, headers, and values that look like identifiers such as email addresses or sort keys.
  2. Send a value containing a single quote and compare the response with the original. Look for a database error, a changed status code, a truncated page, or a different redirect.
  3. If errors are suppressed, send a pair of requests that should produce a true and a false condition, for example a comparison that is always true versus one that is always false, and compare the two responses byte for byte.
  4. If the responses differ, confirm with a third request that should behave like the true case, to rule out caching or randomness.
  5. Move to extraction: ask questions about information_schema or about known values, one character at a time, and check that the answers are consistent across repeated requests.

A positive result is a reproducible, deterministic difference between a true and a false condition, or a database error that reveals query structure. Common false positives include pages that vary for unrelated reasons (ads, timestamps, A/B tests, rate limiting), values that are validated but produce a generic error page, and differences caused by caching. Always repeat requests and compare like with like.

How it is fixed

Use parameterised queries everywhere, including in ORMs and query builders where raw fragments are easy to introduce. Where a value cannot be a parameter, such as a sort column, map it against a fixed allow-list. Give the application's database account only the permissions it needs, so a successful injection cannot read or write beyond its own schema. Turn off verbose database errors in production and log them server-side instead. Add a web application firewall as a layer, not as the fix.

Hunting notes

Injection tends to hide in less obvious inputs: email and domain fields, sort and filter parameters, JSON keys, headers used for logging or analytics, and older or internal-facing endpoints that skip the framework's query builder. Recon signals include parameters that accept structured values, endpoints that echo input back, error pages that mention SQL, and applications that mix raw SQL with an ORM. Stop at the minimum needed to prove access, and never touch other users' data.

Glossary

  • SQL: the language used to ask a database questions and to change its data.
  • Database: the program a website uses to store and look up its data.
  • SQL injection (SQLI): a bug where user input becomes part of a database query's structure instead of staying data.
  • Payload: the exact text an attacker sends to trigger or exploit a bug.
  • Blind injection: injection where the query's output is never shown, so the attacker learns by watching for side effects.
  • Boolean-based blind injection: blind injection that relies on a true/false difference in the response.
  • Time-based blind injection: blind injection that relies on the database pausing for a measurable time.
  • Error-based injection: injection that makes the database reveal data inside an error message.
  • Union-based injection: injection that appends a second result set to the original query with UNION.
  • Subquery: a query written inside another query.
  • UNION: an SQL keyword that combines the results of two queries.
  • CASE expression: an SQL conditional that returns one value when a condition is true and another when it is false.
  • String literal: a piece of text in SQL, usually wrapped in single quotes.
  • Comment (/**/): text the database ignores; it can stand in for a space.
  • LIMIT / OFFSET: SQL clauses that control how many rows are returned and how many are skipped.
  • substr: an SQL function that takes a piece of a piece of text.
  • ascii: an SQL function that turns a character into its numeric code.
  • information_schema: a built-in catalogue of tables and columns that the database keeps about itself.
  • Parameterised query (prepared statement): a query whose structure is fixed before user data is attached, so data cannot become syntax.
  • Allow-list: a fixed list of permitted values, used where a value cannot be a parameter.
  • Least privilege: giving an account only the permissions it actually needs.
  • ORM: a library that builds database queries for the developer, sometimes with room for raw SQL fragments.
  • Web application firewall (WAF): a filter placed in front of a site that blocks known attack patterns; a layer, not a fix.
  • False positive: a test result that looks like a bug but has an innocent explanation.

More by Josip Franjkovic

View all

6 more disclosed reports, best first.

More from Meta

View all

The newest disclosed reports for this program.

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.