Beyond the Wall: Bypassing OTP, WAF, and 403 for exploiting a SQL Injection
A legacy panel had a 403 on the main domain but not on other paths, and after registering the OTP was returned in the response, allowing login. The dashboard search box was vulnerable to SQL injection, and the author bypassed a WAF using URL-encoded newlines and a closing parenthesis to execute a time-based sleep.
In this blog post, I’m going to share my experience exploiting a SQL Injection after bypassing WAF, the 403 Status Code, and OTP on a VDP program. I won’t go through my recon process here, as I’ve covered it in a previous XSS writeup, which you can read: 403 Forbidden?
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 returned the OTP in the HTTP response and concatenated user input into SQL queries without proper parameterisation.
Impact
An attacker could bypass the OTP and log in, then exploit SQL injection to make the database delay responses, confirming the vulnerability; the WAF initially blocked some payloads but was eventually bypassed.
What the attacker needed
Access to the legacy panel; a registered account; ability to read HTTP responses
How it was found
- Access a dummy path on the legacy panel to see if the 403 applies to all paths.
- Brute force directories to find the /dashboard path.
- Register on the dashboard and observe that the OTP is returned in the response.
- Enter the OTP from the response to log in.
- Inject a single quote into the search box and notice a change in behaviour.
- Use a time-based SQL injection payload with URL-encoded newline and closing parenthesis to bypass the WAF.
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 application had a login step that asked for a one-time code sent by email, but the code was actually included in the server's reply, so anyone could read it and log in. Once inside, a search box let users look up orders, and the site put the search text directly into a database command, so a crafted search could make the database wait and reveal that it was vulnerable. The attacker also had to get around a web application firewall, a filter that blocks suspicious requests, by encoding parts of the request.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.