Summary
An SQL injection flaw exists in SourceCodester Hotel Management System 1.0 in the /index.php/reservation/check endpoint, where the room_type parameter is processed unsafely.
A remote attacker can manipulate this parameter to inject arbitrary SQL queries, potentially accessing or altering reservation and customer data when the application passes user input directly into database queries without proper safeguards.
Affected context
The vulnerability occurs in the reservation checking functionality of SourceCodester Hotel Management System 1.0, specifically in /index.php/reservation/check.
It is relevant when user-controlled input from the room_type parameter is incorporated into SQL statements without strict validation, encoding, or parameterization.
This typically manifests in deployments where the application has direct access to the backend database with broad privileges and user input is trusted as-is by the query-building logic.
Exploit preconditions
- Attack surface: Public-facing web interface, accessible over HTTP/HTTPS.
- Required access: Network access to the application; no prior authentication is necessarily required if the reservation check endpoint is exposed to anonymous users.
- Trigger point: Submission of crafted data in the room_type request parameter to /index.php/reservation/check (e.g., via query string or form data).
- Why exploitation is possible: The server-side logic appears to concatenate the room_type value directly into SQL statements without using prepared statements or robust input handling, enabling attackers to alter the structure of the executed query.
Why this happens
This issue is rooted in dynamically constructing SQL queries using untrusted input from the room_type parameter without proper separation of code and data.
Instead of binding user input as parameters, the application likely interpolates the raw room_type value into the query string, allowing malicious tokens to be interpreted as SQL syntax.
This matches CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), and also relates to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component, because the untrusted input flows into the database engine as a downstream consumer.
Potential impact
- Retrieval of sensitive hotel, reservation, and customer information from the database.
- Modification or deletion of booking records and associated transactional data.
- Creation of unauthorized bookings or manipulation of room availability and pricing data.
- Escalation to full database compromise, including reading application configuration data stored in the database.
- In some environments, potential execution of database-specific commands that could affect server stability or enable further lateral movement.
General mitigation guidance
Effective mitigation focuses on preventing user input from altering SQL structure and tightening data access:
- Use parameterized queries or prepared statements for all database interactions involving user-controlled values such as room_type.
- Apply strict server-side validation and normalization of room_type, restricting it to known identifiers or enumerated values rather than free-form text.
- Implement centralized query-building helpers or ORM layers that discourage raw SQL concatenation and enforce safe-by-default patterns.
- Limit database account privileges so the application can only perform the minimal set of operations needed, reducing impact if injection occurs.
- Introduce consistent input handling policies across the codebase, including clear guidelines for dealing with all externally sourced data.
How teams detect issues like this
Potential detection and assurance strategies include:
- Static application security testing (SAST) to identify string concatenation patterns used in SQL queries and direct use of unsanitized request parameters like room_type in query construction.
- Manual code review focusing on database access layers, looking for inline SQL that embeds $_GET, $_POST, or equivalent request variables.
- Runtime security monitoring and web application firewalls (WAFs) configured with rules to detect and log common SQL injection payload patterns on endpoints like /index.php/reservation/check.
- Database-side monitoring for anomalous query patterns, such as unexpected UNIONs, tautological WHERE clauses, or sudden spikes in error-generating queries.

