Summary
A SQL injection flaw in the registration handler of the SourceCodester Multi-Vendor Online Grocery Management System allows crafted Name input to alter backend database queries.
When user-supplied registration data is concatenated directly into SQL statements, attackers can remotely manipulate or access data beyond their intended permissions.
Affected context
This vulnerability occurs in the user registration workflow, specifically within the save_client function in classes/Users.php.
It is relevant where the application accepts a Name field from clients, builds SQL queries using string concatenation, and executes them without proper parameterization or robust input handling.
Deployments exposed to the internet or shared networks, with reachable registration endpoints and direct database connections, are more likely to be impacted.
Exploit preconditions
- Attack surface: Public or network-accessible registration endpoint handling client creation.
- Required access: Ability to submit registration requests (e.g., via web form or direct HTTP calls).
- Trigger point: Processing of the Name parameter by the
save_clientfunction when constructing and executing SQL statements. - Why exploitation is possible: The Name value is embedded directly into an SQL query without parameterized statements or proper escaping, allowing attacker-controlled input to change the query structure.
Why this happens
The underlying issue is the direct inclusion of untrusted user input into dynamically constructed SQL commands.
Instead of using prepared statements or ORM-layer parameter binding, the save_client function appears to concatenate the Name field into query strings, making the database interpret parts of user input as SQL logic.
This maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') and is related to CWE-74: Improper Neutralization of Special Elements in Output, as special characters are not correctly sanitized before being sent to the database engine.
Potential impact
- Attackers may read sensitive data from user and client tables beyond their own account.
- Malicious users could modify or delete customer records, orders, and inventory data.
- SQL injection can be used to create new privileged accounts or escalate existing privileges.
- The application database could be corrupted, leading to partial or total data loss.
- In certain configurations, attackers may chain database access to compromise the underlying host environment.
General mitigation guidance
Mitigation generally focuses on treating all user-provided fields, including Name, as untrusted and preventing them from altering query structure.
Common defensive patterns include:
- Using parameterized queries and prepared statements for all database operations instead of string concatenation.
- Employing an ORM or database abstraction layer that enforces safe query building by default.
- Implementing centralized input validation for registration fields to enforce expected formats and lengths.
- Applying least-privilege to database accounts so that application-level credentials cannot perform unnecessary administrative actions.
- Designing error handling so that database error messages do not reveal query details or schema information.
How teams detect issues like this
Detection can combine automated and manual review techniques:
- Static analysis rules that flag dynamic SQL construction using string concatenation or unsafe interpolation in PHP files (e.g.,
Users.php). - Code review practices that require inspection of all data access layers for parameterized queries and validation routines.
- Runtime monitoring for anomalous SQL patterns, such as unexpected logical operators or union queries originating from registration requests.
- Security-focused test cases and dynamic application security testing that systematically probe input fields like Name for SQL injection behavior.
- Integration of automated code scanning tools into CI/CD pipelines to enforce policies against unsafe query construction.

