How I Found an SQL Injection in coupon code
The coupon code field on an e-commerce checkout page was vulnerable to SQL injection, as indicated by an error response when a single quote was added. An attacker could use automated tools to extract database information.
The discovery of this vulnerability began when I visited an e-commerce website. At first I just did normal testing for fun like Idor, XSS, information disclosure etc.
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 user input directly into SQL queries without proper sanitisation or parameterisation.
Impact
An attacker could extract database contents, potentially including sensitive information, as the text shows sqlmap successfully enumerated databases.
What the attacker needed
No account needed; add any product to cart; reach checkout page
How it was found
- Add a product to the cart and proceed to checkout.
- Enter a test coupon code and intercept the request.
- Add a single quote to the coupon code and observe the error response.
- Save the request to a file and run sqlmap with specific options.
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.
SQL injection is a way to trick a website's database into running unintended commands by inserting special characters into input fields. Here, the coupon code box did not properly handle a single quote, causing an error that revealed the weakness. An attacker could then use a tool to steal data from the database.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.