Skip to content

🔒 Fix: SQL Injection + XSS vulnerabilities (CWE-89, CWE-79) - #1

Open
javokhir-sec wants to merge 1 commit into
amine-CS96:mainfrom
javokhir-sec:fix/sqli-prepared-statements
Open

🔒 Fix: SQL Injection + XSS vulnerabilities (CWE-89, CWE-79)#1
javokhir-sec wants to merge 1 commit into
amine-CS96:mainfrom
javokhir-sec:fix/sqli-prepared-statements

Conversation

@javokhir-sec

Copy link
Copy Markdown

🛡️ Security Fix Summary

This PR fixes 5 Critical SQL Injection vulnerabilities and 1 Stored XSS vulnerability discovered by security researcher Javokhir Tursunboyev.

Vulnerabilities Fixed

# Type CWE CVSS File
1 SQL Injection (DELETE) CWE-89 9.8 Public/delete_product.php
2 SQL Injection (SELECT) CWE-89 9.8 Public/edit_product.php
3 SQL Injection (UPDATE) CWE-89 9.8 Public/edit_product.php
4 SQL Injection (INSERT) CWE-89 9.8 Public/index.php
5 Stored XSS CWE-79 6.1 Public/index.php

Changes Made

  1. Prepared Statements: Replaced all $mysqli->query() string interpolation with $mysqli->prepare() + bind_param()
  2. Output Escaping: Added htmlspecialchars() on all database output to prevent XSS
  3. Column Names: Fixed incorrect column name references (Designationname_product, etc.)

Proof of Concept (Before Fix)

# UNION SQLi — Extract MySQL version via visible output
curl 'http://target/edit_product.php?id=-1 UNION SELECT @@version,2,3,4,5'
# → Displays: "Edit Product 11.8.6-MariaDB-6"

# SQLi DELETE — Wipe all products
curl 'http://target/delete_product.php?id=1 OR 1=1'
# → All products deleted

After Fix

All queries use parameterized prepared statements. SQL injection is no longer possible.


🔐 Discovered by: Javokhir Tursunboyev
📧 CVE Request: Pending via MITRE CNA-LR

Addresses multiple critical vulnerabilities:
- CWE-89: SQL Injection in DELETE (delete_product.php) - switch to prepared statement
- CWE-89: SQL Injection in SELECT (edit_product.php) - switch to prepared statement
- CWE-89: SQL Injection in UPDATE (edit_product.php) - switch to prepared statement
- CWE-89: SQL Injection in INSERT (index.php) - switch to prepared statement
- CWE-79: Stored XSS in product listing (index.php) - add htmlspecialchars() on output
- Fix incorrect column name references (Designation→name_product, etc.)

Discovered by: Javokhir Tursunboyev (github.com/javokhir-sec)

Co-Authored-By: Claude <noreply@anthropic.com>
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