Summary
SourceCodester Online Voting System 1.0 contains a SQL injection vulnerability in the voting deletion endpoint. An attacker who can reach the remote endpoint may manipulate the ID argument to alter database queries, potentially exposing or modifying voting data.
Affected context
The vulnerability occurs in deployments of SourceCodester Online Voting System 1.0 where the /ajax.php?action=delete_voting endpoint is accessible over the network. Risk exists when the endpoint incorporates the supplied ID argument into a database query without sufficient parameterization or input validation.
Exploit preconditions
- Attack surface: The remotely accessible
/ajax.php?action=delete_votingapplication endpoint - Required access: Network access to the application; authentication requirements may depend on deployment configuration
- Trigger point: Processing of the
IDargument associated with voting deletion - Why exploitation is possible: User-controlled input may influence SQL query construction instead of being handled exclusively as a typed query parameter
Why this happens
The underlying bug is an injection flaw in which externally supplied data can affect the structure or behavior of a database query. If the ID argument is concatenated into SQL or insufficiently constrained before query execution, database syntax can be interpreted as part of the command rather than as data. This maps primarily to CWE-89: Improper Neutralization of Special Elements used in an SQL Command (SQL Injection) and broadly relates to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component.
Potential impact
- An attacker may read sensitive voting or application data
- An attacker could modify or delete voting records
- Database integrity and election-related results may be affected
- The application may experience unauthorized administrative actions depending on database privileges
- Sensitive information could be exposed through database query behavior
General mitigation guidance
Mitigation generally focuses on ensuring that database queries treat request values strictly as data.
Common defensive patterns include:
- Using parameterized queries or prepared statements for all database operations
- Applying allowlist validation and type checks to identifier fields such as
ID - Avoiding dynamic SQL construction from request parameters
- Limiting the database account to only the privileges required by the application
- Separating administrative deletion functions from broadly reachable endpoints
- Returning generic database errors that do not disclose query details
- Enforcing authorization checks independently of input validation
How teams detect issues like this
Organizations can look for this weakness through:
- Static analysis rules identifying string concatenation or interpolation in SQL execution paths
- Code review checks for request parameters passed directly to database APIs
- Dynamic application testing for unexpected database errors and query behavior
- Web application firewall or API policy rules monitoring suspicious database-oriented input patterns
- Logging and alerting for unusual access to deletion endpoints or abnormal query failures
Automated security review tools may help identify unsafe query construction, but findings should be verified against the application's database access patterns.

