Summary
WeGIA, a web manager for charitable institutions, contains a SQL injection vulnerability in the DespachoDAO memorando handling, where the id_memorando parameter from $_REQUEST is directly concatenated into SQL queries.
Any authenticated user who can control this parameter may execute arbitrary SQL commands against the application database, potentially exposing or altering sensitive institutional data.
Affected context
The vulnerability occurs in WeGIA installations prior to version 3.6.9 within the PHP data access layer file dao/memorando/DespachoDAO.php.
In this context, the id_memorando parameter is read from $_REQUEST (e.g., GET or POST) without validation or sanitation and embedded into SQL statements that run against the backend database.
The risk materializes when authenticated users can influence this parameter through application workflows that invoke the affected DAO methods.
Exploit preconditions
- Attack surface: HTTP endpoints that trigger queries in
DespachoDAO.phpusing theid_memorandoparameter. - Required access: Authenticated access to the WeGIA application with the ability to submit or modify requests containing
id_memorando. - Trigger point: Application actions that perform database operations (SELECT/UPDATE/DELETE/INSERT) in DespachoDAO based on the supplied
id_memorandovalue. - Why exploitation is possible: User-controlled data is directly interpolated into SQL strings without parameterization, escaping, or type enforcement, enabling crafted input to alter the intended SQL structure.
Why this happens
This issue stems from constructing SQL queries via string concatenation with untrusted input taken directly from $_REQUEST.
Instead of using prepared statements or bound parameters, the code embeds id_memorando variables directly into the SQL text, allowing an attacker to inject additional SQL tokens.
This is a classic instance of CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the application fails to treat user-supplied data strictly as data, mixing it with control syntax.
Potential impact
- Unauthorized reading of sensitive tables, including personal or institutional records.
- Modification or deletion of memorando-related data or other business records.
- Creation of rogue accounts or escalation of application privileges via database changes.
- Destruction or corruption of database contents, impacting application availability and integrity.
- Potential pivoting to access additional systems that rely on the same database or credentials.
General mitigation guidance
Effective mitigation focuses on separating data from control in all database interactions and reducing trust in incoming parameters:
- Replace string-concatenated SQL with prepared statements and bound parameters for all queries using
id_memorandoand other user-controlled values. - Enforce strict input validation and type checking (e.g., ensuring identifiers are integers) at the controller or DAO boundary before reaching the database layer.
- Centralize database access patterns to a data access layer that mandates parameterization and rejects dynamic SQL string building.
- Apply least-privilege to the database account used by WeGIA so that, even if a query is manipulated, its capabilities are limited to necessary operations.
- Use secure coding guidelines and development standards that explicitly forbid direct interpolation of
$_REQUEST,$_GET, or$_POSTinto SQL.
How teams detect issues like this
Organizations can detect this and similar flaws by combining code-level and behavior-level analysis:
- Static analysis: Configure SAST rules to flag direct use of
$_REQUEST,$_GET, or$_POSTvariables in SQL query strings and to require parameterized queries in DAO classes. - Code review: During manual reviews, focus on data access files (like
DespachoDAO.php) and look for concatenated SQL, missing input validation, and absence of prepared statements. - Policy enforcement: Introduce coding policies that prohibit raw SQL concatenation and enforce the use of a database abstraction layer or ORM with parameter binding.
- Runtime monitoring: Use database activity monitoring to spot anomalous or malformed SQL patterns that indicate injection attempts, and feed those insights back into secure development practices.

