Summary
Sourcecodester Online Thesis Archiving System v1.0 contains a SQL injection vulnerability in /otas/view_archive.php that allows crafted input to be interpreted as part of a database query.
If user-controlled parameters are not properly sanitized, an attacker can manipulate queries to access, modify, or delete thesis records and related data.
Affected context
This vulnerability appears in the web application layer of the Online Thesis Archiving System, specifically when retrieving archive records through /otas/view_archive.php.
It is typically exposed when user-supplied input (for example, query string or form parameters) is concatenated directly into SQL statements for viewing thesis archive details.
The issue is most relevant in deployments where database accounts have broad privileges and where no additional query-layer protections (such as parameterization or strong input validation) are enforced.
Exploit preconditions
- Attack surface: Public or internal web interface, via HTTP requests sent to /otas/view_archive.php
- Required access: Ability to send crafted requests to the affected endpoint (often unauthenticated or low-privilege user context, depending on configuration)
- Trigger point: Parameters consumed by view_archive.php that influence SQL queries used to retrieve thesis archive data
- Why exploitation is possible: The application constructs SQL statements by directly embedding untrusted input, allowing injection of arbitrary SQL fragments that the database executes
Why this happens
The root cause is the use of dynamically constructed SQL queries that interpolate user-controlled values without proper parameterization or escaping.
This aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where metacharacters such as quotes, operators, or comment markers are not neutralized before being passed to the database.
At an abstract level, the bug class is "string concatenation for queries" instead of using prepared statements with bound parameters, making the query structure partially controllable by the attacker.
Potential impact
- Access to thesis archive records that the attacker should not be able to read
- Modification or deletion of existing thesis entries and related metadata
- Insertion of malicious or fraudulent records into the archive
- Enumeration of database schema information (tables, columns, users)
- Potential compromise of other application data stored in the same database, depending on schema and permissions
General mitigation guidance
Effective mitigation focuses on eliminating direct string-based query construction and tightening data access boundaries:
- Use parameterized queries or prepared statements for all database interactions, especially in view_archive.php and similar endpoints
- Apply strict server-side validation and normalization of all input that influences SQL, limiting values to expected formats and types (e.g., numeric IDs, fixed enums)
- Encapsulate database access in a data access layer that prohibits raw query concatenation by default
- Restrict database account privileges to the minimum required for the application's functions, avoiding powerful roles for routine web queries
- Implement defense-in-depth controls such as application-layer error handling that avoids exposing raw SQL or stack traces
How teams detect issues like this
Detection typically combines code-level and traffic-level analysis:
- Use static analysis rules or SAST tools to flag SQL query construction that concatenates $_GET/$_POST/$_REQUEST or other user inputs
- During code review, look for raw SQL strings built with string interpolation, concatenation operators, or untyped variable embedding in view_archive.php and related modules
- Enforce secure coding guidelines and automated CI checks that require parameterized queries for all new or changed database access code
- Monitor application logs and database logs for anomalous query patterns, such as unexpected use of SQL keywords (UNION, OR 1=1, comments) in parameters

