/

CVE-2026-130082

Severity:

HIGH RISK

(8.8)

SQL Injection (CWE-89) in django-tenants PostgreSQL

CVE-2026-130082

Received

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Cross-tenant data exposure and SQL execution as the application's database user

Severity:

HIGH RISK

(8.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 SQL injection vulnerability in django-tenants' PostgreSQL backend arises when tenant schema names are interpolated into SQL without proper escaping. If an attacker can choose or influence a schema name used by affected operations, they may read data belonging to other tenants or execute SQL with the application's database privileges.

Affected context

The vulnerability affects django-tenants deployments using the PostgreSQL backend when tenant schema names are not safely handled in SQL statements. The risk applies to schema-related operations such as setting the search path or creating, dropping, or altering schemas, when an attacker can influence the name supplied to those operations.

Exploit preconditions

  • Attack surface: PostgreSQL backend operations that use tenant schema names in SQL.
  • Required access: The ability to choose or influence a schema name that reaches an affected operation; this may depend on application access controls.
  • Trigger point: A schema-related statement such as SET search_path or a CREATE, DROP, or ALTER SCHEMA operation.
  • Why exploitation is possible: Unescaped schema names can be interpreted as SQL syntax rather than only as identifiers.

Why this happens

The underlying issue is SQL injection (CWE-89): data derived from a tenant schema name is inserted into SQL statements without correctly preserving its status as an identifier. Because SQL identifiers cannot generally be protected by value parameterization in the same way as ordinary data values, unsafe string construction can allow quote characters to alter the meaning of a statement.

Potential impact

  • An attacker may read data belonging to other tenants.
  • An attacker could execute SQL using the application's database privileges.
  • Schema operations could be altered, potentially affecting tenant data or database structure.
  • The impact may extend to other database-accessible resources, depending on the application's privileges.

General mitigation guidance

Defensive patterns include treating schema names as untrusted input and ensuring they remain identifiers, not executable SQL. Where possible, derive names from trusted server-side values and enforce a strict allowlist or schema-name format. Use database-aware identifier quoting for dynamic identifiers, and parameterized queries for ordinary data values. Limit the database account to the privileges needed by the application, and apply tenant isolation controls as defense in depth.

How teams detect issues like this

Review code paths that build SQL statements using tenant or schema names, especially search-path changes and schema creation, deletion, or alteration. Static analysis and code review can flag string concatenation or formatting in SQL construction and check whether dynamic identifiers use safe, database-aware handling. Policy checks can require allowlisted identifier sources, appropriate quoting, and least-privilege database roles; automated review tools may help identify risky patterns.

Sources

SourceLink
github.comgithub.com/django-tenants/django-tenants/blob/v4.0.0/django_tenants/postgresql_backend/base.py#L208-L213
github.comgithub.com/django-tenants/django-tenants/blob/v4.0.0/django_tenants/postgresql_backend/base.py#L46
github.comgithub.com/django-tenants/django-tenants/commit/46d89c0fccc820f88657e6ec152ba855072571ff
github.comgithub.com/django-tenants/django-tenants/releases/tag/v4.0.1
github.comgithub.com/django-tenants/django-tenants/security/advisories/GHSA-693j-7v9f-x7pw
vulncheck.comvulncheck.com/advisories/django-tenants-3.4.8-before-4.0.1-sql-injection-via-unescaped-schema-name

Frequently asked

questions

Exploitability depends on whether an attacker can influence a schema name that reaches an affected PostgreSQL operation. That ability may be exposed through an application feature or require other access.

The key prerequisite is the ability to choose or influence a tenant schema name used by an affected statement. Application authorization and database permissions affect the practical scope.

Keep schema names within a trusted, validated set and use database-aware identifier quoting when constructing statements with dynamic identifiers. Use parameterized queries for ordinary values.

Review dynamic SQL construction, validate and constrain identifier sources, and enforce least-privilege database roles alongside tenant-isolation controls.

Find out what's already
exploitable in your codebase.