Javascript Analysis to SQL injection
The purchase basket endpoint accepted an 'act' parameter that was not visible in the normal interface, and inserting a single quote into it caused a SQL error in the response. An attacker could use this to inject SQL and potentially read or modify database contents.
Published on melguerdawi.medium.com
It’s have been long time from my last write up, in this write up I will explain how I found SQL injection by analyzing the JavaScript codes.
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application concatenated the 'act' parameter directly into a SQL query without proper sanitisation or parameterisation.
What the attacker needed
Access to the online store; ability to add items to a basket
How it was found
- Add products to the shopping bag and visit the purchase bag page.
- Notice a GET parameter called 'id' in the URL.
- Send the request to Burp Suite and try SQL injection on the 'id' parameter without success.
- Analyse the JavaScript code of the endpoint and discover a new parameter called 'act'.
- Add a single quote to the 'act' parameter value and observe that the response size changes.
- Inspect the response and find a SQL error at the bottom.
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 write-up has not been written yet. The Original tab links to the source.
A web page sometimes sends extra hidden values to the server that you do not see on screen. This report found one such hidden value in a shopping basket page. By putting a special character into it, the server showed a database error, which is a sign that the input is being used directly in a database query and could be abused.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.