Summary
A SQL injection vulnerability in WeGIA's deletar_tag.php endpoint allows user-controlled input from HTTP request parameters to be concatenated directly into SQL queries without sanitization or prepared statements.
If an attacker can send crafted requests to this endpoint, they may be able to modify or delete database records, or in some environments, execute additional database-specific commands under the application's database account.
Affected context
This vulnerability occurs in WeGIA deployments that expose the html/socio/sistema/deletar_tag.php script to users, either directly or via application workflows.
It arises where request parameters are automatically extracted with extract($_REQUEST) and the resulting $id_tag variable is used in SQL statements through string concatenation.
The risk is higher when the database user account has broad privileges over tables used for tags or related entities, and when input validation or access control around tag deletion is weak or inconsistent.
Exploit preconditions
- Attack surface: HTTP interface of the WeGIA application, specifically requests reaching
deletar_tag.php. - Required access: Ability to send crafted requests containing
id_tag(or equivalent) parameters; this may be unauthenticated or authenticated depending on deployment access controls. - Trigger point: Processing of the deletion request where
extract($_REQUEST)populates$id_tag, which is then interpolated directly into SQL queries on lines 16–17. - Why exploitation is possible: The application performs dynamic SQL construction using untrusted request data, with no input validation, escaping, or prepared statements, allowing attackers to alter the intended SQL command structure.
Why this happens
The core issue is the direct interpolation of untrusted user input into SQL queries, mapping to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
The use of extract($_REQUEST) introduces an additional risk by implicitly creating variables from request parameters, making data flow harder to reason about and validate.
Instead of treating client-supplied values as data bound through parameterized queries, the implementation concatenates $id_tag into the SQL string, allowing control characters and SQL syntax from the attacker to modify the semantics of the query.
Potential impact
- An attacker may delete arbitrary tag records or related entries in the database.
- An attacker could manipulate WHERE clauses to affect more rows than intended, leading to bulk modification or deletion.
- Depending on database configuration, the attacker may read additional data via UNION-based or error-based SQL injection techniques.
- In environments where the database account has elevated privileges, the attacker could create, alter, or drop tables, impacting application integrity and availability.
- In some database platforms, the attacker could potentially execute stored procedures or database-specific functions that extend impact beyond basic data access.
General mitigation guidance
Effective mitigation focuses on ensuring that user-controlled data cannot alter SQL command structure:
- Replace string concatenation in SQL with parameterized queries or prepared statements so that values are always bound as data, not syntax.
- Avoid
extract($_REQUEST)and similar patterns that implicitly trust and expose request parameters; instead, explicitly read and validate expected inputs. - Apply input validation to enforce strict type and format constraints (e.g., numeric-only identifiers for tag IDs) before any database interaction.
- Configure database accounts with least privilege, limiting their ability to create, drop, or modify schema objects beyond what the application genuinely requires.
- Introduce application-level access controls around deletion operations to reduce who can reach sensitive endpoints.
How teams detect issues like this
Organizations can detect and prevent similar issues through a combination of review and tooling:
- Use static analysis rules to flag direct concatenation of
$_GET,$_POST,$_REQUEST, orextract()-derived variables into SQL strings. - During code review, treat any use of
extract()as a signal for deeper inspection, and verify that all database interactions use prepared statements or safe query builders. - Enforce coding standards that mandate parameterized queries for all SQL access and discourage dynamic SQL construction.
- Employ application security testing (SAST and DAST) tools configured to search for SQL injection patterns and unvalidated request parameters in database calls.
- Monitor application and database logs for anomalous query patterns that include unexpected SQL keywords in user-supplied fields.

