/

CVE-2026-33133

Severity:

HIGH RISK

(7.2)

SQL Injection in WeGIA loadBackupDB()

CVE-2026-33133

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary Database Modification and Account Takeover

Severity:

HIGH RISK

(7.2)

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

WeGIA versions 3.6.5 and 3.6.6 contain an SQL injection flaw in the backup restoration feature, where uploaded SQL backup archives are imported without any validation or restriction.

An attacker who can upload a crafted backup file may execute arbitrary SQL statements, including creating rogue administrator accounts, changing passwords, or altering application data.

Affected context

This vulnerability affects WeGIA deployments that expose the backup restore functionality in versions 3.6.5 and 3.6.6.

It typically manifests when:

  • Users are allowed to upload and restore database backups through the web interface
  • The application directly executes SQL from uploaded backup files
  • There is no filtering, validation, or restriction on which SQL statements are permitted during restore

The issue resides specifically in the loadBackupDB() function that processes and imports SQL backup archives.

Exploit preconditions

  • Attack surface: Web interface or API endpoint used to upload and restore database backup archives.
  • Required access: Ability to authenticate or otherwise reach the backup upload/restore functionality; in many deployments this is limited to administrative or privileged users, but misconfigurations could broaden access.
  • Trigger point: Submission of a crafted backup archive that contains malicious SQL statements followed by a restore operation via loadBackupDB().
  • Why exploitation is possible: The restore logic assumes that backup files are trustworthy and executes their contents as SQL without parsing, validation, or whitelisting, effectively treating user-supplied files as authoritative database commands.

Why this happens

The root cause is an insecure design in the backup restoration mechanism where untrusted input (uploaded backup archives) is treated as trusted SQL and executed verbatim.

Instead of constraining restores to data-only operations or a controlled set of statements, the loadBackupDB() function allows arbitrary SQL commands from the uploaded file.

This maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), as user-controllable content directly influences the SQL executed by the database without sanitization, validation, or structural enforcement.

Potential impact

  • Creation of rogue administrator or privileged user accounts in the application database
  • Modification or reset of existing user passwords, enabling account takeover
  • Deletion, corruption, or tampering with critical application data and logs
  • Escalation of privileges within the application by altering role or permission tables
  • Exfiltration of sensitive information by inserting SQL commands that dump data to attacker-accessible locations
  • Disruption of service availability by dropping tables or altering schema

General mitigation guidance

Mitigation should focus on treating backup files as untrusted input and constraining what the restore process can do:

  • Design the backup/restore feature to operate on data-only dumps that exclude schema changes, user tables, and privileged metadata.
  • Implement strict parsing and validation of backup content, rejecting any SQL commands outside an allowed subset (for example, inserts into a narrow set of known tables).
  • Apply principle of least privilege at the database level so the account used for restores cannot create administrative users, alter credentials, or modify security-related tables.
  • Require strong authentication and role-based authorization for access to backup upload and restore capabilities, and avoid exposing this feature in lower-trust environments.
  • Prefer structured migration and seeding mechanisms over free-form SQL execution for application-level data initialization and recovery.

How teams detect issues like this

Detection efforts can target both source code and runtime behavior:

  • Static analysis and code review:
  • Flag any functionality that reads user-uploaded files and passes their contents directly to database execution APIs.
  • Look for restore or migration utilities that accept arbitrary SQL or do not restrict target tables and commands.
  • Review backup/restore flows for absence of content validation, parsing, or schema checks.
  • Runtime monitoring and logging:
  • Enable detailed database logging for administrative and schema-changing operations initiated by the application account.
  • Monitor for unusual patterns during backup restore operations, such as creation of new admin users, changes to authentication tables, or DDL statements.
  • Policy and tooling:
  • Use automated security scanning tools that detect generic SQL injection patterns and insecure DB execution paths.
  • Integrate security-focused code review checklists specifically for maintenance and administrative features like backup and restore.

Sources

SourceLink
github.comgithub.com/LabRedesCefetRJ/WeGIA/pull/1459
github.comgithub.com/LabRedesCefetRJ/WeGIA/releases/tag/3.6.7
github.comgithub.com/LabRedesCefetRJ/WeGIA/security/advisories/GHSA-qqff-p8fc-hg5f

Frequently asked

questions

It can be remotely exploitable if an attacker can reach the backup upload and restore interface over the network. Exploitation typically occurs through the normal web interface workflow by supplying a crafted backup archive.

In many configurations, yes: backup and restore features are usually restricted to authenticated administrators. However, if these endpoints are misconfigured or exposed to lower-privilege users, those users could exploit the flaw to gain administrative control.

The safest pattern is to eliminate arbitrary SQL execution from uploaded backup files. Restrict restore operations to validated, data-only dumps; enforce strict whitelisting of allowed tables and commands; and run restores under a database account that lacks permission to modify authentication and security-sensitive structures.

Treat all uploaded files as untrusted; avoid executing their contents directly against the database. Use parameterized operations, structured import formats (such as CSV or application-level export formats), least-privilege database accounts, and security reviews of administrative utilities like backup and migration tools before release.

Find out what's already
exploitable in your codebase.