Skip to content
SQL injection Write-up Intermediate

A 500$ SQL Injection Bug in .IKEA.es — My First Finding on Hackerone!

A subdomain of IKEA's Spanish site was vulnerable to SQL injection, letting an attacker interfere with the database queries the application made. The author used an open-source tool to enumerate multiple databases, and the report was marked critical and rewarded.

medium.com

Published on medium.com

Sql Injection

Touseef Gul, 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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

IKEA runs a vulnerability disclosure programme on HackerOne, and this write-up covers the first bug I reported through that platform: an SQL injection on a .ikea.es subdomain that was paid a $500 bounty. The report itself does not name the subdomain, the parameter, or the exact request that was vulnerable, so what follows sticks to what I can show: the tooling, the output, and the timeline.

I found the target by chance. I was not actively hunting on HackerOne at the time; I was looking for vulnerability disclosure programmes at various companies using Google dorks. I noticed a subdomain mentioned on the IKEA site itself, started exploring it, and within a couple of hours had a critical bug.

SQL injection, for the record, is a web security vulnerability that lets an attacker interfere with the queries an application makes to its database. It generally allows an attacker to view data they are not normally able to retrieve, including data belonging to other users or any other data the application itself can access. In many cases an attacker can modify or delete that data, causing persistent changes to the application's content or behaviour. In some situations the attack can be escalated to compromise the underlying server or other back-end infrastructure, or to perform a denial-of-service attack.

Setup

There were no accounts, roles or special preconditions described. The work was done against a live subdomain of .ikea.es that was publicly referenced from the IKEA site. The tools involved were:

  • SQLmap, the well-known open-source SQL injection tool.
  • Ghauri, an open-source SQL injection tool by r0oth3x49, which at the time of the finding was private and only I had access to it (thanks to Nasir Khan for that).

No versions are given for either tool.

Finding it

I picked the target at random and began exploring the subdomain after seeing it mentioned on the IKEA site. Within a couple of hours I had identified an SQL injection. The report does not describe the request that triggered it, the parameter involved, or the response that first suggested the injection, so I cannot reconstruct that part of the hunt here.

When I reported it I was unsure whether it would be duplicated or rejected. My advice from that experience: if you have found a valid bug, report it anyway, because it also increases your knowledge. Think out of the box, since hundreds of people may be searching the same target, and do not rely on a single tool for reconnaissance or even for exploitation.

Exploitation

Step 1: Confirm and enumerate with SQLmap

The first tool used was SQLmap. Through its --sql-shell option I was able to fetch tables in the current database, but SQLmap was unable to fetch the databases themselves and the bug was not being exploited fully through it. However, SQLmap was unable to fetch the databases themselves, and the bug was not being exploited fully through it. This limitation is what the triage team later referred to when they asked me to verify the finding.

From the original on medium.com

The screenshot shows the proof-of-concept stage of the report.

Step 2: Switch to Ghauri for database enumeration

Because SQLmap could not fetch the databases, I switched to Ghauri. With Ghauri it was pretty easy to fetch multiple databases. The report does not include the exact Ghauri command line or its raw output, only the result that multiple databases were retrieved.

From the original on medium.com

The screenshot shows the database enumeration output produced with Ghauri.

Step 3: Report and verify

I reported the bug to IKEA through their vulnerability disclosure programme on HackerOne. The triage team came back asking for verification because, via SQLmap, the bug was not being exploited fully. I supplied the proof, and the HackerOne team marked the report as critical.

Root cause

The report does not analyse the application code, so the specific mistake is not documented. The only statement about the cause is the fix advice: never trust user input, filter it properly. In other words, user-supplied input reached an SQL query without adequate filtering or parameterisation. Why the existing defences did not stop it is not described.

Impact

The HackerOne team marked the bug as critical. With Ghauri I was able to fetch multiple databases, beyond the current database whose tables SQLmap's --sql-shell could list. The general consequences of SQL injection, as summarised in the report's background section, are viewing data the attacker is not normally able to retrieve, including other users' data; modifying or deleting data; and, in some situations, escalating to compromise of the underlying server or other back-end infrastructure, or a denial-of-service attack. The report does not state which data was actually exposed or how many users were affected.

Fix

IKEA's team replied on the day the issue was assigned to a developer that the bug was fixed, and I confirmed back that the issue had been resolved. The stated principle is to never trust user input and to filter it properly.

Variants to test

These are general directions suggested by the workflow above, not things the report tested:

  1. Parameters that SQLmap confirms but cannot fully exploit. When SQLmap reports an injection but fails to enumerate databases, try a second tool against the same parameter. A positive result is the second tool returning a list of database names where the first returned nothing.
  2. Subdomains referenced from the main marketing site. The target here was found because the subdomain was mentioned on the IKEA site itself. A positive result is a subdomain that accepts input reaching a database and behaves differently for a boolean-true versus boolean-false condition.
  3. --sql-shell as a fallback enumeration path. If full database enumeration fails, check whether the current database's tables can still be listed through an interactive SQL shell. A positive result is table names returned from the current schema.
  4. Tool diversity during exploitation, not just recon. The report's own lesson is not to rely on one tool. A positive result is a finding that one tool misses and another confirms, as happened here between SQLmap and Ghauri.

Timeline

Date Event
09-16-22 Bug discovered and reported to IKEA via their vulnerability disclosure programme on HackerOne.
09-19-22 Response asking for verification, because via SQLmap the bug was not being exploited fully.
09-21-22 HackerOne team marked it as critical after the proof was given.
09-21-22 Issue assigned to the respective developer for fixing.
09-21-22 Reply from the team that the bug is fixed.
09-21-22 Confirmed back that the issue had been resolved.
09-21-22 Report closed by IKEA.
09-22-22 IKEA updated that after 30 days their internal monthly committee would analyse the report and decide on reward eligibility.
10-24-22 Requested an update from IKEA.
10-25-22 IKEA awarded $500 and said really nice findings.
10-25-22 Sent the article draft for approval to make sure it complies with their policy.
11-14-22 Reply that all is OK with a minor correction, which was made in the article.
From the original on medium.com

The closing image accompanies the reward section of the post.

Reward

IKEA paid $500 for finding this bug.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

This is the story of my first bug reported through HackerOne, a website where companies invite security researchers to report problems in their systems. The bug was an SQL injection on a subdomain of .ikea.es, and IKEA paid me $500 for it.

If you are new to all of this, here is the short version. A website is usually a set of pages that talk to a database, which is an organised store of information kept on a server. When you type something into a search box or click a link with an ID in it, the website often builds a question (a query) and sends it to that database. SQL injection means slipping extra instructions into your input so that the database answers a different question than the one the website intended. If it works, you can read data you were never meant to see.

The report does not name the subdomain, the parameter or the exact request that was vulnerable. What I can show is the tooling, the output and the timeline, and that is what follows.

How I found the target

I was not actively hunting on HackerOne at the time. I was looking for vulnerability disclosure programmes (VDPs) at various companies using Google dorks. A Google dork is simply a carefully crafted search query that turns up pages you would not find with ordinary keywords, for example pages that list a company's systems or expose a particular kind of file. A VDP is a company's promise that if you report a security problem responsibly, they will not take legal action against you, and sometimes they pay a reward, called a bounty.

I noticed a subdomain mentioned on the IKEA site itself, started exploring it, and within a couple of hours had a critical bug. A subdomain is the part in front of the main domain name: in shop.example.com, shop is the subdomain. Companies often run many of them, and they are easy to forget about, which makes them interesting places to look.

From the original on medium.com

The image at the top of the post introduces the article and its author.

What SQL injection is

SQL injection is a web security vulnerability that lets an attacker interfere with the queries an application makes to its database. It generally allows an attacker to view data they are not normally able to retrieve, including data belonging to other users or any other data the application itself can access. In many cases an attacker can modify or delete that data, causing persistent changes to the application's content or behaviour. In some situations the attack can be escalated to compromise the underlying server or other back-end infrastructure, or to perform a denial-of-service attack.

A denial-of-service attack is one that makes a service unavailable to its normal users, for example by overwhelming it.

A useful everyday comparison: imagine a librarian who takes a written slip from you and fetches the book named on it. Normally you write one title. SQL injection is writing a second instruction on the same slip, such as "and also hand over the list of every borrower", and having the librarian follow it because they never checked that the slip contained only a title.

Reference: https://portswigger.net/web-security/sql-injection

Setup

There were no accounts, roles or special preconditions described. The work was done against a live subdomain of .ikea.es that was publicly referenced from the IKEA site. The tools involved were:

  • SQLmap, the well-known open-source SQL injection tool. Open source means its code is public and anyone can download and use it.
  • Ghauri, an open-source SQL injection tool by r0oth3x49, which at the time of the finding was private and only I had access to it (thanks to Nasir Khan for that).

No versions are given for either tool.

Both tools do broadly the same job: you point them at a web address, they try a series of inputs designed to reveal whether the site is building database queries from your input unsafely, and if so they try to extract information. Think of them as automated assistants that repeat hundreds of small experiments for you.

Finding it

I picked the target at random and began exploring the subdomain after seeing it mentioned on the IKEA site. Within a couple of hours I had identified an SQL injection. The report does not describe the request that triggered it, the parameter involved, or the response that first suggested the injection, so I cannot reconstruct that part of the hunt here.

When I reported it I was unsure whether it would be duplicated or rejected. A duplicate is when someone else reported the same bug first, and a rejection is when the company decides the report is not a real problem. My advice from that experience: if you have found a valid bug, report it anyway, because it also increases your knowledge. Think out of the box, since hundreds of people may be searching the same target, and do not rely on a single tool for reconnaissance or even for exploitation. Reconnaissance means the information-gathering phase before you attack anything: finding out what exists, what it runs, and where the doors are.

Exploitation

Step 1: Confirm and enumerate with SQLmap

The first tool used was SQLmap. Through its --sql-shell option I was able to fetch tables in the current database, but SQLmap was unable to fetch the databases themselves and the bug was not being exploited fully through it. However, SQLmap was unable to fetch the databases themselves, and the bug was not being exploited fully through it. This limitation is what the triage team later referred to when they asked me to verify the finding.

A few terms here. A database server usually holds several databases, each of which contains tables, and each table contains rows of data, a bit like a spreadsheet. The "current database" is the one the vulnerable web page is already connected to. --sql-shell is a SQLmap option that gives you an interactive prompt where you can type SQL statements yourself and see the answers, rather than letting the tool decide what to ask. Triage is the first stage of handling a report, where the company's team checks whether it is real and how serious it is.

From the original on medium.com

The screenshot shows the proof-of-concept stage of the report.

Step 2: Switch to Ghauri for database enumeration

Because SQLmap could not fetch the databases, I switched to Ghauri. With Ghauri it was pretty easy to fetch multiple databases. The report does not include the exact Ghauri command line or its raw output, only the result that multiple databases were retrieved.

Enumeration means listing things one by one: here, asking the database server to name every database it holds. This matters because the current database may be only one small part of what is stored on the server, and the other databases may belong to entirely different applications.

From the original on medium.com

The screenshot shows the database enumeration output produced with Ghauri.

Step 3: Report and verify

I reported the bug to IKEA through their vulnerability disclosure programme on HackerOne. The triage team came back asking for verification because, via SQLmap, the bug was not being exploited fully. I supplied the proof, and the HackerOne team marked the report as critical.

Root cause

The report does not analyse the application code, so the specific mistake is not documented. The only statement about the cause is the fix advice: never trust user input, filter it properly. In other words, user-supplied input reached an SQL query without adequate filtering or parameterisation. Why the existing defences did not stop it is not described.

Parameterisation is the standard defence: instead of gluing your text directly into a query, the website sends your text separately and tells the database "treat this purely as a value, never as instructions". It is the difference between a librarian who reads your slip as a title and one who reads it as a list of commands.

Impact

The HackerOne team marked the bug as critical. With Ghauri I was able to fetch multiple databases, beyond the current database whose tables SQLmap's --sql-shell could list. The general consequences of SQL injection, as summarised in the report's background section, are viewing data the attacker is not normally able to retrieve, including other users' data; modifying or deleting data; and, in some situations, escalating to compromise of the underlying server or other back-end infrastructure, or a denial-of-service attack.

Fix

IKEA's team replied on the day the issue was assigned to a developer that the bug was fixed, and I confirmed back that the issue had been resolved. The stated principle is to never trust user input and to filter it properly.

Variants to test

These are general directions suggested by the workflow above, not things the report tested:

  1. Parameters that SQLmap confirms but cannot fully exploit. When SQLmap reports an injection but fails to enumerate databases, try a second tool against the same parameter. A positive result is the second tool returning a list of database names where the first returned nothing.
  2. Subdomains referenced from the main marketing site. The target here was found because the subdomain was mentioned on the IKEA site itself. A positive result is a subdomain that accepts input reaching a database and behaves differently for a boolean-true versus boolean-false condition. A boolean condition is simply a statement that is either true or false, and if the page visibly changes depending on which one you send, that is a strong hint the input is reaching the database.
  3. --sql-shell as a fallback enumeration path. If full database enumeration fails, check whether the current database's tables can still be listed through an interactive SQL shell. A positive result is table names returned from the current schema. A schema is the description of how a database is laid out: its tables and their columns.
  4. Tool diversity during exploitation, not just recon. The report's own lesson is not to rely on one tool. A positive result is a finding that one tool misses and another confirms, as happened here between SQLmap and Ghauri.

Timeline

Date Event
09-16-22 Bug discovered and reported to IKEA via their vulnerability disclosure programme on HackerOne.
09-19-22 Response asking for verification, because via SQLmap the bug was not being exploited fully.
09-21-22 HackerOne team marked it as critical after the proof was given.
09-21-22 Issue assigned to the respective developer for fixing.
09-21-22 Reply from the team that the bug is fixed.
09-21-22 Confirmed back that the issue had been resolved.
09-21-22 Report closed by IKEA.
09-22-22 IKEA updated that after 30 days their internal monthly committee would analyse the report and decide on reward eligibility.
10-24-22 Requested an update from IKEA.
10-25-22 IKEA awarded $500 and said really nice findings.
10-25-22 Sent the article draft for approval to make sure it complies with their policy.
11-14-22 Reply that all is OK with a minor correction, which was made in the article.
From the original on medium.com

The closing image accompanies the reward section of the post.

Reward

IKEA paid $500 for finding this bug.

Glossary

  • Bounty: a cash reward a company pays for a valid security report.
  • Boolean condition: a statement that is either true or false; used in testing to see whether input reaches a database.
  • Critical: the highest severity label used here, meaning the company judged the bug very serious.
  • Current database: the database the vulnerable web page is already connected to.
  • Database: an organised store of information kept on a server, made up of tables.
  • Denial-of-service attack: an attack that makes a service unavailable to its normal users.
  • Duplicate: a report of a bug that someone else already reported first.
  • Enumeration: listing items one by one, such as every database on a server.
  • Exploitation: the phase where you actually use a vulnerability to extract information or otherwise demonstrate impact.
  • Ghauri: an open-source SQL injection tool by r0oth3x49, private at the time of this finding.
  • Google dork: a carefully crafted search query used to find pages ordinary keywords would miss.
  • HackerOne: a platform where companies run bug bounty and disclosure programmes.
  • Open source: software whose code is public and free to download and use.
  • Parameter: a named piece of input a web page accepts, such as a search term or an ID.
  • Parameterisation: sending user input to a database separately from the query, so it is treated only as a value.
  • Query: a question or instruction sent to a database.
  • Reconnaissance: the information-gathering phase before attacking, finding what exists and where.
  • Rejection: a company's decision that a report is not a real problem.
  • Schema: the description of a database's layout, its tables and columns.
  • SQL injection (SQLi): slipping extra database instructions into input so the database answers a different question than intended.
  • SQLmap: a well-known open-source SQL injection tool.
  • --sql-shell: a SQLmap option giving an interactive prompt where you type SQL statements yourself.
  • Subdomain: the part in front of a main domain name, as in shop.example.com.
  • Table: a set of rows of data inside a database, like a spreadsheet.
  • Triage: the first stage of handling a report, checking whether it is real and how serious it is.
  • Vulnerability disclosure programme (VDP): a company's scheme for receiving security reports safely, sometimes with rewards.

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.