Summary
A critical SQL injection vulnerability in the WeGIA web manager for charitable institutions allows user-controlled request parameters to be concatenated directly into SQL queries in remover_produto_ocultar.php.
An authenticated (or authentication-bypassing) attacker can inject arbitrary SQL, leading to data exfiltration, data manipulation, or time-based denial of service through expensive database operations.
Affected context
The vulnerability occurs within the WeGIA PHP application, specifically in the remover_produto_ocultar.php script that handles product removal or hiding operations.
The script uses extract($_REQUEST) to promote incoming request parameters to local variables and then interpolates them directly into a SQL statement executed with PDO::query without prepared statements or parameter binding.
Any deployment where this script is reachable and the database user has significant privileges is exposed to elevated risk.
Exploit preconditions
- Attack surface: HTTP(S) endpoint that routes to remover_produto_ocultar.php (e.g., product removal/hide functionality).
- Required access: Typically authenticated user access; risk increases if other flaws permit authentication bypass or direct access to the endpoint.
- Input control: Ability to influence request parameters consumed by
extract($_REQUEST)(GET, POST, or other request variables). - Trigger point: Server-side execution of the vulnerable SQL query within remover_produto_ocultar.php.
- Why exploitation is possible: User-controlled variables are interpolated directly into a SQL query string executed via
PDO::querywithout prepared statements, quoting, or validation, allowing crafted input to alter the intended query structure.
Why this happens
The underlying issue is classic SQL injection arising from unsafe construction of SQL queries using untrusted input.
The pattern extract($_REQUEST) implicitly promotes all request parameters to local variables, obscuring where data originates and bypassing explicit validation.
These variables are then concatenated directly into an SQL string passed to PDO::query, which executes the final string verbatim on the database.
This behavior maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where application logic treats attacker-controlled input as part of the SQL syntax rather than as data.
Potential impact
- Reading sensitive data from application tables, including user records or institutional information.
- Modifying, inserting, or deleting database records, potentially corrupting financial or operational data.
- Creating or altering application accounts, roles, or permissions stored in the database.
- Triggering time-based or computationally heavy queries to degrade performance or cause denial of service.
- Chaining with other weaknesses (e.g., weak DB configuration) to execute additional backend operations.
General mitigation guidance
Effective mitigation focuses on eliminating dynamic SQL built from untrusted input and tightening the trust boundary around HTTP request data.
Recommended defensive patterns include:
- Replacing string-concatenated SQL with prepared statements and bound parameters for all user-influenced values.
- Avoiding
extract($_REQUEST)and similar APIs that implicitly introduce unvalidated variables; instead, read specific parameters explicitly. - Applying strict input validation and normalization for all request parameters, using whitelists for identifiers and numeric ranges for IDs.
- Segregating database privileges so that the application account has only the minimal rights required for its operations.
- Centralizing database access through a limited set of repository or data-access functions to enforce consistent query construction patterns.
How teams detect issues like this
Detection approaches can combine code-level analysis with behavioral monitoring:
- Static analysis rules that flag use of
extract($_REQUEST), direct interpolation of$_GET,$_POST, or derived variables into SQL strings, and calls toPDO::querywith concatenated input. - Manual code review checklists that require reviewers to verify that all database interactions use parameterized queries and that request data is never directly embedded in SQL.
- Application security testing (SAST/DAST) targeting endpoints that perform data modification, including tests for time-based and error-based injection patterns.
- Runtime monitoring and database logging to identify anomalous queries with suspicious patterns (e.g., injected logical operators, comment markers, or long delays).
- Integration of automated security scanning tools in CI/CD pipelines to prevent merging of new code that constructs SQL using untrusted data.

