Summary
The PHP-based student_management_system_by_php project contains a SQL injection vulnerability in the User Creation Handler (add_user_check.php) via the role parameter.
An attacker who can send crafted requests to the user creation endpoint may be able to execute arbitrary SQL queries, potentially exposing or modifying application data remotely.
Affected context
This issue affects deployments of the raisulislamg4 student_management_system_by_php project that expose the User Creation Handler (add_user_check.php) over a network-accessible interface.
The vulnerability is present when the role parameter from incoming requests is used in SQL statements without adequate neutralization or parameterization.
Any environment where the application connects to a relational database (such as MySQL) with an account that has broad privileges is at higher risk of data exposure or modification.
Exploit preconditions
- Attack surface: HTTP request to the user creation functionality, typically via add_user_check.php.
- Required access: Network access to the application; exploitation may occur with low or no prior authentication if user creation is not strictly restricted.
- Trigger point: Submission of a crafted role parameter value that is incorporated into a dynamic SQL query.
- Why exploitation is possible: The application constructs SQL statements from user-controlled input without using parameterized queries or sufficient escaping, allowing attacker-controlled SQL fragments to be executed by the database engine.
Why this happens
The root cause is unsafe construction of SQL queries using user input, specifically the role parameter, within the User Creation Handler.
Instead of relying on parameterized statements or a query builder, the handler appears to concatenate raw input into SQL strings, which maps directly to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Because this input is not consistently validated or constrained to an expected set of roles, the database interpreter receives queries that include attacker-supplied control characters and clauses, enabling unintended query execution.
Potential impact
- Extraction of sensitive information from user and student records, including personal data.
- Modification or deletion of user accounts, student records, or other critical tables.
- Creation of new administrative or privileged accounts, leading to full application takeover.
- Bypassing authentication or authorization checks by tampering with role-related logic in queries.
- Potential escalation to remote code execution on the server if the database or application environment is misconfigured to allow such actions.
General mitigation guidance
Effective mitigation focuses on treating all role values as untrusted and removing direct string concatenation from database interactions:
- Use parameterized (prepared) statements or an ORM/query builder that automatically binds variables rather than interpolating them into SQL strings.
- Constrain the role field to a fixed set of server-side enumerated values (e.g., using whitelists or mapping identifiers to constants) rather than trusting client-provided role names.
- Apply strict input validation on all parameters involved in SQL queries, rejecting unexpected formats instead of attempting to sanitize arbitrary strings.
- Reduce database account privileges to the minimum required for the application so that even if a query is abused, the blast radius is limited.
- Centralize database access logic to common helper functions or repositories, making it easier to enforce secure query patterns consistently across the codebase.
How teams detect issues like this
Organizations can detect this class of vulnerability with a combination of automated and manual techniques:
- Static analysis rules that flag dynamic SQL construction, especially concatenation of $_GET/$_POST/$_REQUEST variables directly into query strings in PHP.
- Code review checklists that require all SQL queries in request handlers (such as add_user_check.php) to use prepared statements and server-side role enumeration.
- Runtime security testing (SAST/DAST) that sends SQL meta-characters through parameters like role and monitors for error messages, anomalous responses, or timing differences.
- Central policies or linters that disallow database access outside of vetted data access layers, making ad-hoc query construction more visible.

