Summary
SourceCodester SUP Online Shopping 1.0 contains a SQL injection vulnerability in /admin/replymsg.php, where the msgid parameter is incorporated into database queries without sufficient sanitization or parameterization.
A remote attacker can manipulate this parameter to alter backend SQL queries, which may lead to unauthorized data access, data tampering, or other database-level impacts under typical deployment conditions.
Affected context
The vulnerability appears in the administrative messaging or reply functionality implemented in /admin/replymsg.php.
It manifests when user-controlled input from the msgid parameter is passed into SQL statements without robust validation or the use of prepared statements.
Any deployment that exposes this admin endpoint over the network and does not implement additional input filtering or access controls may be at risk, especially when the application connects to a database with broad privileges.
Exploit preconditions
- Attack surface: HTTP interface of the SUP Online Shopping 1.0 application, specifically requests reaching /admin/replymsg.php.
- Required access:
- Network access to the web application.
- In many real-world setups, access to /admin/ paths may require authentication, but this depends on the site's access controls.
- Trigger point: Supplying crafted values in the msgid request parameter (e.g., via query string or POST body, depending on implementation) so that it is concatenated into a SQL query.
- Why exploitation is possible: The application appears to build SQL queries using string concatenation with msgid, without using parameterized queries or sufficient input validation/escaping, allowing attacker-controlled fragments to change the structure of the SQL command.
Why this happens
The core issue aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), with aspects of CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component.
The application likely interpolates the msgid parameter directly into an SQL statement, treating untrusted user input as part of the query logic rather than as data.
This pattern allows special characters (such as quotes, comment markers, or operators) to escape the intended data context, enabling an attacker to inject additional conditions, union queries, or other SQL constructs.
The bug is structural: it stems from reliance on dynamic query construction, rather than consistently using parameterized statements and a strict separation between code and data.
Potential impact
- May allow reading sensitive information from database tables beyond what the application normally exposes.
- Could enable modification or deletion of records, such as messages, user data, or transactional records.
- May allow creation of new application accounts or escalation of logical privileges if user or role data is stored in the same database.
- Can potentially be chained with other weaknesses (e.g., weak database permissions) to gain broader server or application compromise.
- Might facilitate denial of service by corrupting data or issuing expensive queries that overload the database.
General mitigation guidance
Effective mitigation centers on treating all external inputs as untrusted and ensuring SQL query construction never relies on raw string concatenation:
- Use parameterized queries / prepared statements for all database interactions involving user-supplied values, ensuring the database interprets these values strictly as data.
- Introduce strict input validation for identifiers like msgid, enforcing expected formats (e.g., integer-only or constrained alphanumeric) and rejecting or normalizing anything outside those rules.
- Apply least-privilege access for the database account used by the application, limiting the potential blast radius of a successful injection.
- Centralize database access through vetted utility functions or an ORM abstraction to reduce the chance of ad hoc, insecure query construction.
- Establish secure-by-default coding guidelines that discourage dynamic SQL building patterns and require review of any exceptions.
How teams detect issues like this
Organizations can detect and monitor for this class of weakness using a combination of code-centric and runtime techniques:
- Static analysis: Configure security-focused linters or SAST tools to flag dynamic SQL construction, especially where variables like $_GET['msgid'] or $_POST['msgid'] are concatenated into query strings.
- Code review: During manual reviews, look for patterns such as direct embedding of request parameters inside SQL strings in PHP files (e.g., in /admin/replymsg.php). Require justification and defensive measures for any dynamic query logic.
- Security testing: Use targeted dynamic testing or interactive application security testing (IAST) to send crafted msgid values and observe whether SQL errors, unexpected responses, or timing anomalies suggest injection.
- Runtime monitoring: At the database layer, implement query logging or anomaly detection to highlight unusual patterns (e.g., unexpected UNION statements, tautological WHERE clauses) coming from the application's connection.

