/

CVE-2026-72731

Severity:

HIGH RISK

(7.1)

SQL Injection (CWE-89) in Discourse Data Explorer Plugin

CVE-2026-72731

Received

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Unauthorized Database Read Access

Severity:

HIGH RISK

(7.1)

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 the Discourse Data Explorer plugin allows users who can run parameterized queries to escape intended parameter boundaries and execute arbitrary SQL statements. Because queries execute in a read-only transaction, attackers cannot modify data through this issue, but they may read information from any accessible database table.

Affected context

The vulnerability occurs in Discourse deployments using the Data Explorer plugin when parameterized queries are shared with users who are permitted to run them. It is particularly relevant where non-staff group members can execute shared queries and where recursive parameter interpolation or parameter declarations in SQL comments are processed before the final SQL statement is safely constrained.

Exploit preconditions

  • Attack surface: Discourse Data Explorer parameterized query execution
  • Required access: Permission to run a parameterized Data Explorer query, including access granted through group sharing
  • Trigger point: Processing and interpolation of user-supplied parameter values before query execution
  • Why exploitation is possible: Recursive interpolation and parameter parsing can allow supplied values to escape their intended context and introduce additional SQL statements

Why this happens

The underlying flaw is insufficient separation between user-controlled parameter values and SQL syntax. Recursive parameter interpolation allowed one parameter value to introduce another parameter, while parameter declarations embedded in SQL comments could influence parsing and enable statement injection. This behavior maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, because untrusted input could alter the structure of a database query rather than remain a data-only value.

Potential impact

  • Attackers may read sensitive information from accessible database tables
  • Confidential user, application, or operational data could be exposed
  • Query results may be used to support account compromise or further attacks
  • Excessive or repeated queries could contribute to database resource consumption
  • Data integrity is not expected to be directly affected when queries remain in read-only transactions

General mitigation guidance

Mitigation typically focuses on preserving strict separation between query structure and user-provided values.

Common defensive patterns include:

  • Using parameterized database APIs that bind values without recursive SQL interpolation
  • Treating parameter names, declarations, and comments as non-user-controlled query structure
  • Applying an allowlist-based query grammar or validated statement model
  • Restricting Data Explorer access and shared-query permissions according to least privilege
  • Executing reporting queries with database identities that can read only the required schemas and tables
  • Maintaining read-only transactions and limiting query execution time and resource usage
  • Avoiding exposure of sensitive tables through general-purpose reporting features

How teams detect issues like this

Organizations commonly detect this class of issue through:

  • Static analysis rules for string concatenation or recursive interpolation near SQL execution APIs
  • Code review checks for user-controlled parameter names, comments, or query fragments
  • Tests that verify parameters remain data values under nested, repeated, and malformed input conditions
  • Runtime monitoring for unusual query shapes, unexpected statement boundaries, and access to sensitive tables
  • Authorization policy checks covering shared-query execution and group membership changes
  • Automated security review tools that flag SQL construction paths and missing parameter binding

Sources

SourceLink
github.comgithub.com/discourse/discourse/commit/2bdab888cef561348470dee204a4879d83fbb5c3
github.comgithub.com/discourse/discourse/commit/3dc7f0da7aa18548281152e285244efb1cc8ad0d
github.comgithub.com/discourse/discourse/commit/674ba6fc64184fd7d8e21183c5d8cb22367faa6e
github.comgithub.com/discourse/discourse/commit/ce9ccf24ec3538172dc8f8199728e08f63e57693
github.comgithub.com/discourse/discourse/security/advisories/GHSA-wm63-83xp-59r5

Frequently asked

questions

An attacker generally needs permission to execute a parameterized Data Explorer query. This may include non-staff users who belong to a group with access to a shared query.

The affected queries run in a read-only transaction, so direct modification of database records is not expected. Unauthorized reading of accessible tables remains a significant confidentiality risk.

Remove recursive SQL interpolation and use strict parameter binding or a constrained query representation that cannot treat supplied values as SQL syntax.

Combine least-privilege query permissions with allowlisted query structures, focused database roles, negative tests for injection behavior, and monitoring of reporting-query access.

Find out what's already
exploitable in your codebase.