Summary
The Simple Responsive Tourism Website 1.0 application contains a SQL injection vulnerability in the Login component, specifically in the /tourism/classes/Login.php?f=login endpoint.
By manipulating the Username parameter, a remote attacker can inject SQL queries into the backend database, potentially bypassing authentication or accessing sensitive data when the application fails to properly sanitize user input.
Affected context
This vulnerability appears in deployments of SourceCodester Simple Responsive Tourism Website 1.0 where the login functionality is exposed over a network (e.g., public or internal web access).
It affects the PHP-based login handler at /tourism/classes/Login.php?f=login when it constructs SQL statements using the Username parameter directly or with insufficient sanitization.
The risk is higher when the application uses powerful database accounts, stores sensitive customer or booking data, or lacks additional access control layers beyond simple username/password checks.
Exploit preconditions
- Attack surface: HTTP(S) interface of the login endpoint at
/tourism/classes/Login.php?f=login. - Required access: Network access to the web application; no prior authentication is necessary to reach the login form.
- Trigger point: Submission of crafted values in the
Usernameparameter in login requests. - Why exploitation is possible: The server-side code appears to interpolate the
Usernameparameter into SQL queries without using parameterized statements or robust escaping, allowing attacker-controlled input to alter the intended SQL logic.
Why this happens
The root cause is the construction of SQL queries by concatenating or embedding raw user input from the Username parameter into SQL statements within Login.php.
This insecure pattern maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where special characters (such as quotes, operators, or comment markers) are not safely handled.
The presence of CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component further reflects that data sent to the database (a downstream component) is not properly neutralized, enabling crafted input to be interpreted as part of the SQL command instead of data.
Potential impact
- An attacker may bypass authentication and gain unauthorized access to user or administrative accounts.
- An attacker could read sensitive information stored in the database, such as user details, booking records, or configuration data.
- An attacker might modify or delete records, affecting the integrity and availability of tourism-related content or bookings.
- In some deployments, SQL injection could be leveraged to execute additional database functions, potentially escalating to remote code execution depending on the environment and database configuration.
General mitigation guidance
Mitigation generally focuses on eliminating direct concatenation of user input into SQL queries and enforcing strict separation between code and data.
Recommended defensive patterns include:
- Using parameterized queries or prepared statements for all database access in the login component and elsewhere, ensuring that input is always treated as data.
- Applying centralized input validation for authentication fields (e.g., usernames), restricting allowed characters to a minimal safe set appropriate to the domain.
- Implementing output encoding and query-building helpers that encapsulate safe database interaction, reducing the likelihood of ad hoc query construction.
- Running the database with least-privilege accounts so that even if a query is manipulated, accessible operations and data are minimized.
- Introducing layered defenses such as application-level access controls and rate limiting to reduce the impact of automated attacks.
How teams detect issues like this
Detection typically involves both code-centric and behavior-centric approaches:
- Static analysis: Configure code scanners or linters to flag instances of dynamic SQL construction using variables (e.g., string concatenation in PHP with
$_POST['Username']or similar patterns), especially in authentication code paths. - Code review: During manual reviews, pay close attention to login and user input handling, looking for unparameterized SQL, custom escaping routines, or direct interpolation of request parameters into queries.
- Dynamic testing: Use application security testing tools or targeted penetration tests to send crafted input through the login interface to identify injection behavior and confirm remediation.
- Runtime monitoring: Enable database query logging and anomaly detection to spot unusual patterns such as queries containing injected operators, comments, or always-true conditions originating from the login endpoint.

