SQL Injection in hidden Contact Form Parameter
A hidden parameter in a contact form was vulnerable to SQL injection, allowing an attacker to manipulate database queries. This could lead to data leakage or full table access.
medium.com
Published on medium.com
During a private bug bounty program, I came across an issue that reinforced one of the most important lessons in web security: never ignore the obvious. The vulnerability wasn’t in a complex API or behind a login panel.
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 backend inserted the submitted form data directly into a SQL query using string concatenation without using prepared statements.
Impact
An attacker could manipulate database queries, potentially leading to data leakage, full table access, or even remote code execution depending on database permissions.
What the attacker needed
Access to the contact form; ability to intercept HTTP requests
The fix
The issue should be fixed by using parameterized queries for all database operations and never concatenating user input into SQL queries.
How it was found
- Fill in the contact form fields and submit.
- Inspect the request in Burp to find a hidden parameter.
- Enter a single quote in the hidden parameter and observe a MySQL error.
- Test with a condition that is always true and one that is always false to see different responses.
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 contact form had a hidden field that the website used to build a database query. By typing special characters, the tester made the database show an error, proving that the input was not properly handled. This means an attacker could trick the database into revealing or changing 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.