Summary
SourceCodester Online Voting System 1.0 contains a SQL injection vulnerability in the category-saving endpoint. A remote attacker may be able to manipulate the Category parameter to alter database queries, potentially accessing or changing application data when the endpoint is reachable and insufficiently protected.
Affected context
The weakness occurs in the Online Voting System's AJAX request handler at /voting/ajax.php?action=save_category. It may affect deployments where this endpoint is remotely accessible, the Category value reaches database queries without adequate parameterization, and authorization or input validation controls do not sufficiently constrain requests.
Exploit preconditions
- Attack surface: The remotely reachable category-saving AJAX endpoint
- Required access: Ability to send requests accepted by the endpoint; authentication requirements depend on the deployment
- Trigger point: Processing of the
Categoryargument during category creation or update - Why exploitation is possible: User-controlled input may be incorporated into a database query without reliable separation between data and SQL instructions
Why this happens
The underlying bug is an injection flaw in which externally controlled category data is interpreted as part of a database command. This maps primarily to CWE-89: Improper Neutralization of Special Elements used in an SQL Command (SQL Injection). The related CWE-74 classification reflects the broader failure to separate untrusted input from an interpreter's command syntax.
Potential impact
- An attacker may read information from application-accessible database tables
- An attacker could modify, insert, or delete voting-system records
- The application may experience integrity loss or service disruption
- Exposed credentials or sensitive records could support further compromise
General mitigation guidance
Mitigation generally focuses on ensuring that database commands never interpret user-controlled values as SQL syntax.
Common defensive patterns include:
- Using parameterized queries or prepared statements for all database operations
- Applying allowlist-based validation appropriate to category names and identifiers
- Enforcing authorization checks independently of input validation
- Limiting the database account to only the permissions required by the application
- Avoiding detailed database errors in responses and maintaining secure logging
- Reducing endpoint exposure when category management does not need to be public
How teams detect issues like this
Organizations can identify similar weaknesses through:
- Static analysis rules that flag string concatenation or interpolation in SQL statements
- Code review checks for database calls receiving request parameters directly
- Dynamic testing of authenticated and unauthenticated endpoint paths using safe, non-destructive test cases
- Monitoring for anomalous category-management requests, database errors, and unusual query activity
- Policy enforcement requiring parameterized database access in application code
Automated code review and application security testing tools may help identify injection-prone data flows.

