Skip to content

Security: fix unauthenticated SQL injection / authentication bypass (CWE-89) - #3

Open
javokhir-sec wants to merge 1 commit into
Harsh21Patel:mainfrom
javokhir-sec:fix/sql-injection
Open

Security: fix unauthenticated SQL injection / authentication bypass (CWE-89)#3
javokhir-sec wants to merge 1 commit into
Harsh21Patel:mainfrom
javokhir-sec:fix/sql-injection

Conversation

@javokhir-sec

Copy link
Copy Markdown

Summary

login.php builds the authentication SQL query by directly concatenating the email and password POST 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 in delete.php ($_GET['id'] concatenated into a DELETE) allows unauthenticated SQL injection / data deletion.

Fix

  • login.php: parameterized prepare() + bind_param() for the credential check.
  • delete.php: cast id to int and use a prepared DELETE.

Verified locally: injection payloads no longer authenticate, while valid credentials still log in normally.

Recommended follow-ups (not in this PR)

  • Hash passwords with password_hash() / password_verify() (currently stored in plaintext).
  • Require an authenticated session on all state-changing endpoints (e.g. delete.php).

Reported & fixed by Javokhir Tursunboyev (@javokhir-sec).

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.
@javokhir-sec

Copy link
Copy Markdown
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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant