Security: fix unauthenticated SQL injection / authentication bypass (CWE-89) - #3
Open
javokhir-sec wants to merge 1 commit into
Open
Security: fix unauthenticated SQL injection / authentication bypass (CWE-89)#3javokhir-sec wants to merge 1 commit into
javokhir-sec wants to merge 1 commit into
Conversation
login.php built the authentication query by concatenating the email and password POST parameters directly into SQL, allowing an unauthenticated attacker to bypass login (e.g. email=' OR 1=1 LIMIT 1-- -) and reach the admin panel. delete.php concatenated $_GET['id'] into a DELETE query. Both are converted to parameterized (prepared) statements; delete.php also casts the id to int. Valid logins continue to work; injection payloads no longer authenticate.
Author
|
Hi @Harsh21Patel, Just following up on this critical security fix PR — it addresses an unauthenticated SQL injection leading to authentication bypass (CWE-89, CVSS 9.8) in login.php. This allows anyone to access the admin panel without credentials. The fix replaces string concatenation with prepared statements. Could you please review? Thank you! — Javokhir (@javokhir-sec) |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
login.phpbuilds the authentication SQL query by directly concatenating theemailandpasswordPOST parameters, with no escaping or parameterization. An unauthenticated attacker can bypass login and reach the admin panel.I'm reporting this responsibly; this PR contains the fix.
Impact (CWE-89 SQL Injection → CWE-287 Auth Bypass)
Pre-authentication: sending
email=' OR 1=1 LIMIT 1-- -(any password) bypasses the login and returns the admin panel (table.php). The same class of bug indelete.php($_GET['id']concatenated into aDELETE) allows unauthenticated SQL injection / data deletion.Fix
login.php: parameterizedprepare()+bind_param()for the credential check.delete.php: cast id to int and use a preparedDELETE.Verified locally: injection payloads no longer authenticate, while valid credentials still log in normally.
Recommended follow-ups (not in this PR)
password_hash()/password_verify()(currently stored in plaintext).delete.php).Reported & fixed by Javokhir Tursunboyev (@javokhir-sec).