Time-Based SQL Injection in Account Activation $X,XXX
An account activation endpoint accepted a token parameter that was placed into a SQL query without sanitisation, so a crafted value could make the database pause for several seconds. The author used that timing signal to confirm the injection and to read the database version.
While hunting on one of HackerOne programs, I managed to discover a SQL Injection vulnerability, for which the company rewarded me $X,XXX.
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.
Context
The target was a website belonging to one of the HackerOne programs the researcher was hunting on. The program's rules forbid disclosing the program name or the website, so the article uses example.com as the target domain throughout.
The feature at the centre of the finding is account activation. When someone creates an account, the website requires an administrator to manually activate that account. The activation flow is driven by a token, and the application sends that token to the database as part of a query. The researcher found the relevant code by reading a JavaScript file served by the site, then continued reconnaissance against one of the APIs behind the feature.

Setup
The researcher created an account on the target. The account could not be activated, because activation required an administrator to approve it.
No tooling, versions or specific roles beyond the administrator approval requirement are described in the report.
Finding it
During reconnaissance of the website, the researcher came across a JavaScript file. Analysing its contents revealed an important section related to account activation. That section pointed at the activation endpoint, which the researcher then probed further through the API.

The reasoning that made the endpoint look wrong is the standard one for this class of bug. SQL, Structured Query Language, is how an application talks to its database. When a user submits an activation code (the token), the application sends a query to the database similar to the one illustrated in the report.

SQL Injection happens when a programmer lets user-supplied input be incorporated directly into server-side SQL queries without properly validating the request or sanitising the input. In that situation an attacker can use characters such as ' (single quote) or ; (semicolon) to interfere with the application's SQL query and potentially retrieve information stored in the database.

Exploitation
Step 1: request the endpoint without a token
The researcher crafted a request and sent it to the activation endpoint. Submitting the request without a token produced:
404 Not Found

Submitting the request without a token produced a 404 Not Found response.
Step 2: insert a single quote
To check whether the endpoint might be vulnerable to SQL Injection, the researcher inserted a single quote ('). The server returned:
500 Internal Server Error

A 500 on a quote can sometimes indicate a SQL-related error, although on its own it does not necessarily confirm the presence of SQL Injection. The report is explicit about that limit, and it is the right way to read the signal: it justifies the next test, it does not prove the bug.
Step 3: test for time-based injection
The next step was to test for a Time-Based SQL Injection. This technique relies on observing the response time. When the injected condition evaluates to true, the application may deliberately delay its response for a specified number of seconds.

On some bug bounty programs you may need to stop testing at this stage. Depending on the program's rules, further testing may be permitted to identify additional information such as the database name, the database user or the database version.
Step 4: work around the character limit
During testing, the researcher hit a limitation: the vulnerable parameter accepted only a very small number of characters, which made it difficult to construct a suitable SQL Injection payload. AI tools were tried to help develop a payload that would fit within the restriction, but most of them refused to assist with the request. The researcher then used ObsidianLabs to work through the payload limitation and explore a solution that would fit the character restriction, and was eventually able to develop a Proof of Concept demonstrating the vulnerability.
The payload used to gather the database version as the PoC was:
1'; IF (SUBSTRING(@@VERSION,1,1) = 'M') WAITFOR DELAY '0:0:4' -
The payload closes the token string with ', then runs a conditional statement. SUBSTRING(@@VERSION,1,1) = 'M' tests the first character of the database version string, and WAITFOR DELAY '0:0:4' introduces a four second delay only when that condition holds. The trailing - comments out the remainder of the original query. A response that arrives roughly four seconds later than a baseline request is the confirmation that the injected condition was evaluated by the database.
Root cause
The report states the general cause directly: user-supplied input is incorporated into server-side SQL queries without proper validation of the request or sanitisation of the input. The activation token is placed into the query without proper validation or sanitisation.
Why the existing defences did not stop it is not described in the report. The report does not describe why the existing defences did not stop it.
Impact
According to the report, the vulnerability allowed the researcher to extract all the information stored in the database. The company rewarded the finding with $X,XXX. The report does not name the database, enumerate the tables read, or state how many records were exposed.
Fix
The fix implied by the stated root cause is to stop incorporating the token directly into the query: pass it as a bound parameter so the value can never change the query's structure, and validate the token's format before it reaches the database. Database errors should also be caught and returned as generic responses rather than surfacing as 500s.
Variants to test
- Activation and verification endpoints reached from client-side JavaScript. Send the request with no token, then with a single quote, then with a conditional time delay. A positive result is a change from a clean rejection to a 500 on the quote, followed by a measurable delay only when the condition is true.
- Parameters with tight length limits. When a payload does not fit, shorten the condition (compare a single character, as in the PoC) and use comment syntax to discard the rest of the query. A positive result is the same delay with a much shorter payload.
- Other token-like parameters in the same API (password reset codes, invitation codes, email confirmation links). A positive result is the same 500-then-delay pattern.
Hunting notes
This bug was found by reading a JavaScript file served by the site and following the account activation logic it exposed, then probing the corresponding API. Client-side code that references activation, verification or token handling is a good signal during recon, because those endpoints often sit outside the authenticated surface and are exercised before an account is fully trusted.
The two responses that carried the finding were a 404 Not Found for a missing token and a 500 Internal Server Error for a single quote. Neither proves injection alone, but together they justify a time-based test, which is what turned the suspicion into a PoC. The report's own framing is worth keeping: on some programs you must stop at the detection stage, and further extraction is only appropriate where the program's rules permit it.
The report says the vulnerability allowed extraction of all information stored in the database, with the database version used as the PoC. The character limit on the parameter was the main obstacle, and the lesson the researcher draws is that understanding the vulnerability is only part of the process; the real challenge is often working around unexpected restrictions during testing.
What happened, in plain words
A security researcher was looking for bugs on a website that belongs to one of the programs listed on HackerOne. HackerOne is a platform where companies invite people to test their systems and pay for the problems they find. The rules of this particular program said the researcher must not reveal the program's name or the website's address, so throughout the article the site is called example.com. That is a placeholder name, like writing "John Doe" on a form.
The researcher found a SQL Injection bug. SQL Injection is a way of sneaking database commands into a website through an ordinary input field, and it is explained properly further down. This particular kind was time-based, relying on observing the response time. The company paid $X,XXX for the finding.
The feature involved was account activation. When you sign up on many websites, the site does not switch your account on straight away. Sometimes a human administrator has to look at it and approve it first. The site sends a code, called a token, to check that the activation request is genuine. The report states that user-supplied input was incorporated into server-side SQL queries without proper validation or sanitisation.

The website and the feature
Before the technical part, two ideas need to be clear, because everything else rests on them.
An account is the profile you create on a website with a username and password. Activation is the step that turns a freshly created account into a usable one. On some sites activation happens automatically when you click a link in an email. On this site, activation was manual: an administrator had to approve the account. Until that happened, the account existed but could not be used normally.
A token is a short piece of text that stands in for proof of something. Think of a cloakroom ticket: the number on the ticket is not your coat, but handing it over proves the coat is yours. Websites use tokens for activation codes, password reset links and similar steps. The token is generated by the server, given to the user, and sent back later so the server can check it.
An API is the part of a website that answers requests made by software rather than by a person clicking around. When you fill in a form and press a button, your browser sends a request to the API behind the page, and the API replies with data. Think of a restaurant: the menu and the dining room are the website you see, and the kitchen is the API. You never walk into the kitchen, but your order goes there and your food comes back. The researcher's work happened at the kitchen door, sending requests directly to the API instead of clicking through pages.
A JavaScript file is a text file of code that a website sends to your browser so the page can do things, such as show a pop-up or check a form before sending it. Because the browser has to download these files, anyone can read them. They often mention addresses and parameters that are not visible on the page itself, which makes them useful during reconnaissance.
Reconnaissance means looking around a target before attacking anything: reading pages, watching which requests the browser makes, and reading the files the site hands out. It is the equivalent of walking around a building and noting which doors exist before trying any of them.
Finding the activation code
During reconnaissance of the website, the researcher came across a JavaScript file. After analysing its contents, the researcher noticed an important section related to account activation.

Why does this matter? A JavaScript file is public by design. If the code that handles activation is in a file the browser downloads, then the address of the activation endpoint and the name of the parameter it expects are public too. The JavaScript file contained an important section related to account activation. This is a common starting point in web security: read what the site gives away for free before trying anything clever.
The researcher then continued reconnaissance against one of the APIs. This means sending requests directly to the API address found in the JavaScript, rather than going through the visible web page. Doing so makes it easy to change one detail at a time, such as removing the token or replacing it with odd characters, and to see exactly what comes back.
What SQL is
SQL stands for Structured Query Language. It is the language applications use to talk to databases. A database is an organised store of information, like a very large, very strict spreadsheet: it holds tables, tables hold rows, and rows hold values such as usernames, email addresses and activation tokens.
When a website needs to look something up, it writes a sentence in SQL and sends it to the database. The database reads the sentence, finds the matching rows and sends them back. For example, when you submit an account activation code (Token), the application sends a query to the database similar to the following:

The important thing to notice is the shape of the sentence. Part of it is fixed text written by the programmer, and part of it is the value you typed in. The database does not know which is which. It simply reads the whole sentence from left to right. That single fact is the seed of the entire vulnerability.
What SQL Injection is
SQL Injection occurs when a programmer allows user-supplied input to be directly incorporated into server-side SQL queries without properly validating the request or sanitising the input.
In plain words: the programmer builds the database sentence by gluing your text into it, and never checks whether your text contains characters that mean something to the database. In this situation, an attacker may use characters such as ' (single quote) or ; (semicolon) to interfere with the application's SQL query and potentially retrieve information stored in the database.

A useful comparison is a form letter. Imagine a letter that reads: "Dear ____, your account is approved." If you write your name in the blank, the letter reads normally. If instead you write "Dear ____, your account is approved. Also, please send me the list of all customers," the person reading the letter cannot tell where the template ended and your text began. They just read the whole thing as instructions. SQL works the same way: the quote character is how SQL marks the beginning and end of a piece of text, so a quote typed by a user can end the programmer's text early and let the user start writing SQL of their own.
Step 1: asking without a token
After discovering the endpoint, the researcher attempted to create an account. However, the account could not be activated because it required an administrator to approve it.
This is worth pausing on. The researcher could not use the normal, successful path, because a human had to approve the account first. So the testing had to happen against an endpoint whose happy ending was closed off. That is not a blocker; it just means the interesting information comes from how the endpoint behaves when things are wrong.
The researcher then crafted a request and sent it to the endpoint. When the request was submitted without a token, the server returned the following response:
404 Not Found

Line by line, in plain words:
- The request was sent to the activation endpoint with the token left out entirely.
404 Not Foundis the standard web reply meaning "there is nothing here at this address".
Why does this matter? Because the endpoint answered at all. It did not hang, it did not refuse to talk, and it did not fail somewhere earlier in the system. It noticed that the token was missing and replied in a defined way. That tells the researcher the address is real and reachable, and that the token is a parameter the endpoint actually looks at. A door that reacts to your knock is a door worth studying.
Step 2: sending a single quote
The researcher inserted a single quote (') to check whether the endpoint might be vulnerable to SQL Injection. The server returned:
500 Internal Server Error

Line by line, in plain words:
- The token value was replaced with a single quote character.
500 Internal Server Erroris the standard web reply meaning "something broke on the server while handling this".
Why does this matter? A single quote is an ordinary character to a web page, but it is a special character to SQL: it marks where a piece of text starts and ends. If the server had treated the token as plain text and nothing more, a quote would have been stored or rejected like any other character. Instead the server broke. That suggests the quote travelled all the way into the database sentence and confused it.
The report is careful here, and so should you be: a 500 on a quote can sometimes indicate a SQL-related error, although it doesn't necessarily confirm the presence of SQL Injection on its own. A server can break for many reasons. What the 500 does is justify the next test. It is a strong hint, not a proof.
Step 3: testing with time
Next, the researcher needed to test for a Time-Based SQL Injection vulnerability.
This technique relies on observing the response time. When the injected condition evaluates to true, the application may deliberately delay its response for a specified number of seconds.

Why use time at all? Because the researcher cannot see the database directly. When you inject SQL, the database's answer usually does not appear on the page: the page just says "invalid token" either way. Time gives you a channel that works even when nothing is displayed. Think of a friend behind a closed door who can only knock. You ask a yes-or-no question, and you agree in advance that one knock means yes and silence means no. You cannot see your friend, but you can still get an answer.
In SQL terms, the injected instruction says: if my condition is true, wait a few seconds before replying. If the condition is false, reply immediately. The researcher measures how long the reply takes. A delay that appears only when the condition is true is the proof.
On some bug bounty programs, you may need to stop your testing at this stage. However, depending on the program's rules, further testing may be permitted to identify additional information, such as:
- Database name
- Database user
- Database version
This is an ethical and legal point, not a technical one. A bug bounty program is a permission slip with conditions written on it. Some programs only want to know that a hole exists; digging further into other people's data is out of bounds.
Step 4: getting around the character limit
During testing, the researcher encountered a limitation: the vulnerable parameter accepted only a very small number of characters. This made it difficult to construct a suitable SQL Injection payload.
A payload is the piece of text you send as input to trigger the behaviour you want. Here the payload had to be a complete SQL instruction, but the field would only take a handful of characters. It is like being asked to write a full sentence on a sticky note the size of a postage stamp.
The researcher tried using AI tools to help develop a payload that would fit within this restriction, but most of them refused to assist with the request. The researcher then used ObsidianLabs to work through the payload limitation and explore a solution that would fit the character restriction, and was eventually able to develop a Proof of Concept (PoC) to demonstrate the vulnerability.
A Proof of Concept is a small, safe demonstration that a bug is real. It is the difference between saying "I think this lock is weak" and opening the lock in front of the owner. Bug bounty programs usually want a PoC before they pay.
The payload used to gather the database version as the PoC was:
1'; IF (SUBSTRING(@@VERSION,1,1) = 'M') WAITFOR DELAY '0:0:4' -
Line by line, in plain words:
1'is a harmless-looking value followed by a single quote. The quote closes the text the programmer opened, so everything after it is read as SQL rather than as a token.;ends the programmer's original statement, so a new statement can begin.IF (...)is a conditional: the instruction inside the brackets is checked first, and the rest only happens if it is true.SUBSTRING(@@VERSION,1,1)takes the database version string and cuts out its first character.@@VERSIONis the database's own report of which version it is running.= 'M'asks whether that first character is the letter M. This is a yes-or-no question with a one-character answer, which is exactly what makes the payload short enough to fit.WAITFOR DELAY '0:0:4'tells the database to pause for four seconds. It only runs when the answer above is yes.- The trailing
-turns the rest of the original query into a comment, so the leftover text the programmer wrote is ignored instead of causing an error.
Why does this prove anything? Because the researcher can send the same request twice, once with a condition that is true and once with one that is false, and compare the times. If the true version comes back roughly four seconds later than the false version, then the database really did read and execute the injected instruction. Nothing on the page needs to change for the researcher to learn the answer.
Why the bug existed
The report states the general cause directly: user-supplied input is incorporated into server-side SQL queries without proper validation of the request or sanitisation of the input. The activation token is placed into the query without proper validation or sanitisation.
The report does not describe why the site's existing defences failed to stop it. A bound parameter is a way of sending a value to the database separately from the query text, so the database treats it purely as data and never as instructions. It is the difference between handing a waiter a note that says "extra cheese" and handing the waiter a note that says "extra cheese, and also give me the till". The 500 on a quote also suggests the resulting database error was not caught and turned into a generic reply.
What the impact was
According to the report, the vulnerability allowed the researcher to extract all the information stored in the database. The company rewarded the finding with $X,XXX. The report does not name the database, list the tables that were read, or say how many records were exposed.
How it should be fixed
The fix implied by the stated root cause is to stop incorporating the token directly into the query: pass it as a bound parameter so the value can never change the query's structure, and validate the token's format before it reaches the database. Database errors should also be caught and returned as generic responses rather than surfacing as 500s.
Similar places to look
- Activation and verification endpoints reached from client-side JavaScript. Send the request with no token, then with a single quote, then with a conditional time delay. A positive result is a change from a clean rejection to a 500 on the quote, followed by a measurable delay only when the condition is true.
- Parameters with tight length limits. When a payload does not fit, shorten the condition (compare a single character, as in the PoC) and use comment syntax to discard the rest of the query. A positive result is the same delay with a much shorter payload.
- Other token-like parameters in the same API (password reset codes, invitation codes, email confirmation links). A positive result is the same 500-then-delay pattern.
Notes for your own hunting
This bug was found by reading a JavaScript file served by the site and following the account activation logic it exposed, then probing the corresponding API. Client-side code that references activation, verification or token handling is a good signal during reconnaissance, because those endpoints often sit outside the logged-in area and are used before an account is fully trusted.
The two responses that carried the finding were a 404 Not Found for a missing token and a 500 Internal Server Error for a single quote. Neither proves injection alone, but together they justify a time-based test, which is what turned the suspicion into a PoC. The report's own framing is worth keeping: on some programs you must stop at the detection stage, and further extraction is only appropriate where the program's rules permit it.
The report says the vulnerability allowed extraction of all information stored in the database, with the database version used as the PoC. The character limit on the parameter was the main obstacle, and the lesson the researcher draws is that understanding the vulnerability is only part of the process; the real challenge is often working around unexpected restrictions during testing.
Glossary
- Account activation: the step that turns a newly created account into a usable one, sometimes done by an administrator.
- Administrator: a person with elevated rights on a website who can approve or manage accounts.
- API: the part of a website that answers requests from software, as opposed to pages a person clicks through.
- Bound parameter: a way of sending a value to a database separately from the query text, so the value is always treated as data.
- Bug bounty program: an arrangement where a company invites people to test its systems and pays for confirmed problems.
- Comment (in SQL): text the database ignores, often used to discard the rest of a query.
- Conditional: an instruction that only runs if a stated condition is true.
- Database: an organised store of information, made of tables, rows and values.
- Database version: the identifier of which database software and release is running.
- Endpoint: a specific address on a server that accepts requests, such as the activation address.
- HackerOne: a platform where companies run bug bounty programs.
- JavaScript file: a text file of code a website sends to the browser, readable by anyone.
- Parameter: a named value sent with a request, such as the token.
- Payload: the piece of input crafted to trigger a specific behaviour.
- Proof of Concept (PoC): a small demonstration that a bug is real and exploitable.
- Reconnaissance: looking around a target to learn its structure before testing it.
- Sanitising: cleaning input so that special characters cannot change the meaning of a query.
- SQL (Structured Query Language): the language applications use to talk to databases.
- SQL Injection (SQLi): a bug where user input is glued into a database query and can change what the query does.
- Time-Based SQL Injection: a form of SQL Injection where the result is read from how long the server takes to reply rather than from what it displays.
- Token: a short piece of text used as proof of something, such as an activation code.
- Validating: checking that input has the expected shape before using it.
404 Not Found: the standard web reply meaning there is nothing at the requested address.500 Internal Server Error: the standard web reply meaning the server broke while handling the request.