August 14, 2026
๐ฅ THE DOOR Penetration Testing | SQLi โ Authentication Bypass โ Command Injection
Web application vulnerabilities rarely exist in isolation.
By Pentester Club
7 min read
A seemingly simple SQL injection can sometimes lead to authentication bypass. Once authenticated access is obtained, a vulnerable administrative function may expose an entirely different attack surface โ potentially including operating-system command execution.
This CTF-style penetration-testing scenario, THE DOOR, demonstrates an important security concept:
A vulnerability chain can be significantly more dangerous than any individual vulnerability.
The attack path explored in this lab is:
๐ฏ Web Application
โ
โผ
๐ SQL Injection
โ
โผ
๐ Authentication Bypass
โ
โผ
๐ค Privileged Application Access
โ
โผ
โ๏ธ Vulnerable Functionality
โ
โผ
๐ป Command Injection
โ
โผ
๐จ Potential System Compromise๐ฏ Web Application
โ
โผ
๐ SQL Injection
โ
โผ
๐ Authentication Bypass
โ
โผ
๐ค Privileged Application Access
โ
โผ
โ๏ธ Vulnerable Functionality
โ
โผ
๐ป Command Injection
โ
โผ
๐จ Potential System Compromise๐ง Understanding the Attack Chain
The interesting part of THE DOOR isn't simply discovering SQL injection.
It is understanding how vulnerabilities can connect.
Imagine an application with:
Login
โ
Authentication
โ
Dashboard
โ
Administrative Functions
โ
System UtilityLogin
โ
Authentication
โ
Dashboard
โ
Administrative Functions
โ
System UtilityIf authentication relies on an insecure database query, an attacker may potentially bypass the login.
If the authenticated dashboard contains another vulnerable feature, the first vulnerability becomes the doorway to the second.
This is why penetration testers should think in terms of attack paths, not isolated vulnerabilities.
๐ Step 1 โ Reconnaissance
Before testing the application, start with reconnaissance.
Map the available functionality:
THE DOOR
โ
โโโ Login
โโโ Registration
โโโ User Profile
โโโ Dashboard
โโโ Admin Functions
โโโ System Tools
โโโ API EndpointsTHE DOOR
โ
โโโ Login
โโโ Registration
โโโ User Profile
โโโ Dashboard
โโโ Admin Functions
โโโ System Tools
โโโ API EndpointsLook for:
- Login forms
- Search functionality
- URL parameters
- POST parameters
- Cookies
- API endpoints
- Administrative functionality
- Diagnostic features
- File-processing functionality
The objective is to understand how the application works before attempting to exploit it.
๐ต๏ธ Step 2 โ Investigating the Login
Suppose the login page contains:
Username:
[____________]
Password:
[____________]
[ Login ]Username:
[____________]
Password:
[____________]
[ Login ]A security tester should first capture the request and understand how authentication works.
For example:
POST /login HTTP/1.1
Host: the-door.ctf
Content-Type: application/x-www-form-urlencoded
username=test&password=testPOST /login HTTP/1.1
Host: the-door.ctf
Content-Type: application/x-www-form-urlencoded
username=test&password=testThe important question is:
How does the backend validate these credentials?
If the application constructs a database query using user-controlled input without parameterization, SQL injection may be possible.
๐ Step 3 โ Identifying SQL Injection
SQL injection occurs when attacker-controlled input is incorporated into a database query in an unsafe way.
Conceptually, an application might construct:
SELECT ...
FROM users
WHERE username = '<input>'
AND password = '<input>';SELECT ...
FROM users
WHERE username = '<input>'
AND password = '<input>';The vulnerability exists when input can change the intended structure of the query rather than being treated strictly as data.
During a CTF, a tester can use controlled, non-destructive test inputs to determine whether the login parameters behave unexpectedly.
Useful observations include:
Normal credentials
โ
Authentication failure
Modified input
โ
Different response
โ
Potential SQL injectionNormal credentials
โ
Authentication failure
Modified input
โ
Different response
โ
Potential SQL injectionLook for differences in:
- HTTP status codes
- Response length
- Error messages
- Redirects
- Cookies
- Authentication state
๐งช Step 4 โ Confirming the SQLi
A professional penetration test should avoid jumping immediately to destructive database operations.
Instead, establish a minimal proof of concept.
For example, compare:
Normal inputNormal inputagainst:
Controlled SQLi testControlled SQLi testand observe whether the application's authentication logic changes.
In a CTF environment, the goal is to demonstrate:
Can attacker-controlled SQL syntax alter the application's authentication decision?
If yes, document the behavior.
๐ Step 5 โ Authentication Bypass
Once the SQL injection has been confirmed, the next stage of the attack chain may be authentication bypass.
The conceptual flow becomes:
Unauthenticated User
โ
โผ
Login Endpoint
โ
โผ
SQL Injection
โ
โผ
Authentication Logic Manipulated
โ
โผ
Authenticated SessionUnauthenticated User
โ
โผ
Login Endpoint
โ
โผ
SQL Injection
โ
โผ
Authentication Logic Manipulated
โ
โผ
Authenticated SessionAt this point, the attacker has potentially crossed an important security boundary.
This is where vulnerability chaining becomes interesting.
A SQL injection that initially appears to affect only the login page can potentially provide access to functionality that was never intended to be publicly accessible.
๐ช Step 6 โ Examine the Authenticated Session
After successful authentication in the CTF, inspect the resulting session.
Look for:
Cookies
Session IDs
JWTs
Roles
User IDs
Redirect destinationsCookies
Session IDs
JWTs
Roles
User IDs
Redirect destinationsFor example:
HTTP/1.1 302 Found
Location: /dashboard
Set-Cookie: session=...HTTP/1.1 302 Found
Location: /dashboard
Set-Cookie: session=...The session determines what functionality is now accessible.
Don't assume that reaching /dashboard automatically means administrative privileges.
Verify the actual authorization level.
๐งญ Step 7 โ Explore the Dashboard
After authentication, enumerate the newly available functionality.
A dashboard might expose:
Dashboard
โ
โโโ Profile
โโโ Orders
โโโ Users
โโโ Settings
โโโ Diagnostics
โโโ System ToolsDashboard
โ
โโโ Profile
โโโ Orders
โโโ Users
โโโ Settings
โโโ Diagnostics
โโโ System ToolsThe Diagnostics/System Tools area is particularly interesting if it interacts with the operating system.
Examples of functionality that deserves security review include:
- Ping
- DNS lookup
- Traceroute
- File conversion
- Backup operations
- Image processing
- Archive utilities
The key question becomes:
Does this feature pass user-controlled input to an operating-system process?
โ๏ธ Step 8 โ Investigating Command Injection
OS command injection occurs when untrusted input influences the execution of an operating-system command.
Conceptually:
User Input
โ
Web Application
โ
Command Construction
โ
Operating SystemUser Input
โ
Web Application
โ
Command Construction
โ
Operating SystemA vulnerable implementation might conceptually do something like:
command = "utility " + user_inputcommand = "utility " + user_inputand execute that command through a shell.
This creates a dangerous boundary between application data and executable instructions.
๐งช Step 9 โ Safe Proof of Command Execution
In a CTF environment, command injection should be confirmed using a harmless proof of execution.
The objective is not to destroy data or access unrelated systems.
Instead, demonstrate a controlled effect such as creating a marker inside a temporary lab directory or returning a benign system value.
Conceptually:
HTTP Request
โ
Vulnerable Parameter
โ
Application
โ
OS Command
โ
Benign ProofHTTP Request
โ
Vulnerable Parameter
โ
Application
โ
OS Command
โ
Benign ProofOnce reproducibility is established, stop.
A good penetration tester doesn't need to demonstrate maximum damage to prove a vulnerability.
๐ The Complete THE DOOR Attack Chain
Now we can connect the individual vulnerabilities:
๐ฏ THE DOOR
โ
โผ
Login Endpoint
โ
โผ
๐ SQL Injection
โ
โผ
๐ Authentication Bypass
โ
โผ
๐ช Valid Session
โ
โผ
Dashboard Access
โ
โผ
โ๏ธ System Utility
โ
โผ
๐ป Command Injection
โ
โผ
๐จ Code Execution Risk๐ฏ THE DOOR
โ
โผ
Login Endpoint
โ
โผ
๐ SQL Injection
โ
โผ
๐ Authentication Bypass
โ
โผ
๐ช Valid Session
โ
โผ
Dashboard Access
โ
โผ
โ๏ธ System Utility
โ
โผ
๐ป Command Injection
โ
โผ
๐จ Code Execution RiskThis is the central lesson of the CTF.
The impact comes from the chain.
๐ฅ Why Vulnerability Chaining Matters
Consider the individual findings:
SQL Injection
Potentially serious.
Authentication Bypass
Potentially serious.
Command Injection
Potentially critical.
But when combined:
SQLi
โ
Authentication Bypass
โ
Privileged Functionality
โ
Command InjectionSQLi
โ
Authentication Bypass
โ
Privileged Functionality
โ
Command Injectionthe overall attack path becomes much more significant.
An attacker may move from:
Unauthenticated web access
to:
authenticated application access
and potentially to:
operating-system command execution.
This is why penetration testers should always ask:
"What can I reach after exploiting this vulnerability?"
๐ก๏ธ Fixing the SQL Injection
The primary defense against SQL injection is parameterized queries / prepared statements.
Instead of constructing SQL statements by concatenating user input, applications should separate:
SQL structureSQL structurefrom:
User-controlled valuesUser-controlled valuesConceptually:
cursor.execute(
"SELECT id FROM users WHERE username = %s AND password = %s",
(username, password)
)cursor.execute(
"SELECT id FROM users WHERE username = %s AND password = %s",
(username, password)
)The exact syntax depends on the database driver and framework.
The security principle remains the same:
Never treat user input as SQL syntax.
๐ Fixing Authentication Bypass
Applications should also implement strong authentication architecture.
Important controls include:
- Parameterized database queries
- Secure password hashing
- Generic login error messages
- Session regeneration after authentication
- Secure session cookies
- Proper authorization checks
- Rate limiting
- Multi-factor authentication where appropriate
Authentication and authorization should be treated as separate security controls.
โ๏ธ Fixing Command Injection
The safest solution is to avoid shell execution whenever possible.
Instead of constructing a shell command:
"utility " + input"utility " + inputuse a fixed executable and separate arguments.
For example, in Python:
subprocess.run(
["utility", validated_input],
shell=False,
check=True
)subprocess.run(
["utility", validated_input],
shell=False,
check=True
)The exact implementation should depend on the application's requirements.
Additional defenses include:
- Strict input validation
- Allowlisting expected formats
- Running processes with minimal privileges
- Restricting filesystem permissions
- Network segmentation
- Monitoring suspicious child processes
๐ซ Why Blacklists Are Not Enough
A common mistake is trying to solve command injection by blocking a handful of special characters.
For example:
Block:
;
&&
|Block:
;
&&
|This is not a strong security boundary.
Command interpreters have complex parsing behavior, and incomplete filtering can frequently be bypassed.
A stronger architecture is:
No shell
+
Fixed executable
+
Separated arguments
+
Strict validation
+
Least privilegeNo shell
+
Fixed executable
+
Separated arguments
+
Strict validation
+
Least privilege๐ Defense in Depth
Even when an application contains a vulnerability, additional security controls can reduce the potential impact.
A production architecture should consider:
Application
โ
โโโ Least-privilege service account
โ
โโโ Restricted filesystem
โ
โโโ Network segmentation
โ
โโโ Secret management
โ
โโโ Egress controls
โ
โโโ Security monitoringApplication
โ
โโโ Least-privilege service account
โ
โโโ Restricted filesystem
โ
โโโ Network segmentation
โ
โโโ Secret management
โ
โโโ Egress controls
โ
โโโ Security monitoringSecurity should not depend on one layer.
๐ Writing the Penetration Test Report
A strong report should explain the entire attack chain.
Finding 1 โ SQL Injection
Location: Login endpoint
Impact: Attacker-controlled input can influence database query processing.
Risk: Potential authentication bypass and unauthorized database interaction.
Finding 2 โ Authentication Bypass
Location: Authentication workflow
Impact: An unauthenticated attacker may obtain an authenticated application session.
Risk: Access to functionality intended for authenticated users.
Finding 3 โ OS Command Injection
Location: System/diagnostic functionality
Impact: User-controlled input can influence operating-system command execution.
Risk: Potential arbitrary command execution under application privileges.
๐ฏ Attack Chain Severity
When reporting a chained attack, don't simply list three independent vulnerabilities.
Explain the relationship:
SQL Injection
โ
Authentication Bypass
โ
Access to Restricted Function
โ
Command Injection
โ
Potential OS-Level ImpactSQL Injection
โ
Authentication Bypass
โ
Access to Restricted Function
โ
Command Injection
โ
Potential OS-Level ImpactThis helps developers understand why fixing only one component may not completely eliminate the attack path.
๐ง What This CTF Teaches
THE DOOR demonstrates several fundamental penetration-testing principles.
1. Reconnaissance comes first
Understand the application's attack surface.
2. Follow the trust boundaries
Identify where:
User
โ
Application
โ
Database
โ
Authorization
โ
Operating SystemUser
โ
Application
โ
Database
โ
Authorization
โ
Operating Systemchanges from one security boundary to another.
3. Chain vulnerabilities
One vulnerability can unlock functionality required to exploit another.
4. Prove impact safely
Use minimal, non-destructive proof-of-concepts.
5. Think like a defender
Understanding how the exploit works makes it easier to design effective remediation.
๐ Final Thoughts
THE DOOR is a great example of why modern penetration testing is more than running automated scanners.
The real challenge is understanding relationships between vulnerabilities.
The attack path:
๐ SQL Injection
โ
๐ Authentication Bypass
โ
๐ค Privileged Access
โ
โ๏ธ Command Injection
โ
๐ป Potential Code Execution๐ SQL Injection
โ
๐ Authentication Bypass
โ
๐ค Privileged Access
โ
โ๏ธ Command Injection
โ
๐ป Potential Code Executionshows how a relatively simple input-validation flaw can become part of a much more serious compromise when combined with weaknesses elsewhere in the application.
The defensive lessons are equally important:
Use parameterized queries.
Implement strong authentication and authorization.
Never construct shell commands from untrusted input.
Apply least privilege.
Validate every trust boundary.
And most importantly:
_๐ฅ _Always evaluate vulnerabilities as part of the complete application attack surface โ not just as isolated findings.
๐ Responsible Security Notice
This article is intended for CTFs, cybersecurity education, penetration-testing laboratories, and authorized security assessments. Do not attempt these techniques against real websites, e-commerce platforms, or infrastructure without explicit permission.
Learn the vulnerability. Understand the chain. Prove it safely. Fix the root cause. Report responsibly. ๐จ