/

CVE-2026-31896

Severity:

CRITICAL RISK

(9.8)

SQL Injection in WeGIA remover_produto_ocultar.php

CVE-2026-31896

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Execution and Data Compromise

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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::query without 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 to PDO::query with 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.

Sources

SourceLink
github.comgithub.com/LabRedesCefetRJ/WeGIA/security/advisories/GHSA-w7g3-87cr-8m83

Frequently asked

questions

Yes. As long as the vulnerable remover_produto_ocultar.php functionality is exposed via an HTTP(S) endpoint, an attacker who can reach it and control its parameters can attempt SQL injection remotely.

The description indicates that an authenticated (or auth-bypassed) attacker can exploit it. In practice, exploitation typically requires at least low-privileged access to the affected functionality, but the risk becomes higher if other flaws allow bypassing authentication or accessing the endpoint directly.

Replace all dynamically constructed SQL in the affected code path with prepared statements using bound parameters, remove extract($_REQUEST) in favor of explicit parameter handling, and enforce strict validation on each expected input field.

Standardize on parameterized queries throughout the codebase, ban unsafe APIs and patterns (such as direct variable interpolation into SQL and extract($_REQUEST)), enforce input validation, and adopt security-focused code review and automated static analysis to catch unsafe query construction early in development.

Find out what's already
exploitable in your codebase.