/

CVE-2026-45722

Severity:

HIGH RISK

(7.1)

SQL Injection in Nextcloud Tables App

CVE-2026-45722

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Limited Data Exfiltration and Database Probing via SQL Injection

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 missing sanitization in the Nextcloud Tables app allows a user with access to the app to inject SQL fragments into the ORDER BY clause of dynamically built queries.

While this is a constrained form of SQL injection, it can still be abused to exfiltrate data bit-by-bit or perform time-based probing of the database under specific conditions.

Affected context

The vulnerability occurs in the Nextcloud Tables app when user-controlled input is used to build the ORDER BY clause of SQL queries without proper sanitization or whitelisting.

It is relevant in deployments where:

  • The Tables app is installed and enabled
  • Users have permission to create or interact with tables using sortable columns
  • The backend database executes dynamically constructed queries based on client-supplied sort parameters

The issue does not typically allow arbitrary query construction, but it still exposes a measurable side channel through ORDER BY manipulation.

Exploit preconditions

  • Attack surface: Web interface or API endpoints of the Nextcloud Tables app where sorting or column ordering is user-controllable.
  • Required access: An authenticated Nextcloud account with access to the Tables app and the ability to interact with affected table views.
  • Trigger point: Submission of crafted parameters that influence the ORDER BY portion of a query (e.g., sort field or direction).
  • Why exploitation is possible: The application concatenates or interpolates user-supplied values directly into the ORDER BY clause without adequate sanitization, validation, or strict whitelisting, allowing limited SQL expressions to be injected.

Why this happens

This is a classic SQL injection issue (CWE-89) arising from treating user input as part of SQL syntax instead of data.

Specifically, the ORDER BY clause is built using values derived from client input (such as column names or sort expressions) without enforcing a strict, server-side whitelist of allowed identifiers or using parameterization where applicable.

While many developers focus on sanitizing values in WHERE or INSERT/UPDATE clauses, ORDER BY is often overlooked, creating a channel where an attacker can influence query execution and use timing or boolean outcomes to infer sensitive information.

Potential impact

  • An attacker may infer the value of sensitive data one bit at a time via crafted ORDER BY expressions and observing query behavior.
  • An attacker could perform time-based probing of the database using expressions that induce delays, aiding in data extraction or enumeration.
  • Application responsiveness could be degraded if the injected ORDER BY logic causes expensive operations or deliberate waits.
  • Combined with other weaknesses, the attacker may improve the precision of information-gathering about schema, performance characteristics, or row ordering patterns.

General mitigation guidance

Effective mitigation focuses on treating all query structure influenced by user input as untrusted and tightly constrained:

  • Apply strict whitelisting for sortable fields: map user-provided sort keys to a fixed set of known-safe column names or expressions on the server side.
  • Avoid directly interpolating user input into ORDER BY; where parameterization is not supported for identifiers, rely on server-side mappings rather than dynamic concatenation.
  • Normalize and constrain sort direction to a small enum (e.g., "asc" or "desc") validated against a whitelist.
  • Implement a clear separation between query logic and user input, ensuring that users can only select among predefined options rather than supply arbitrary SQL fragments.
  • Run the database with least-privilege accounts so that even if query behavior is influenced, the scope of accessible data and operations is limited.

How teams detect issues like this

Detection typically combines code-level analysis with behavioral observation:

  • Use static analysis or linters to flag dynamic SQL construction where ORDER BY, GROUP BY, or similar clauses include unsanitized user input or string concatenation.
  • During code review, pay particular attention to query-building helpers, repositories, and ORM escape hatches that manually construct ORDER BY clauses.
  • Apply secure coding policies that require whitelisting for all user-controlled identifiers and ban ad-hoc string concatenation in SQL-building code paths.
  • Employ application security testing (including SAST and DAST) that specifically tests for ORDER BY and time-based SQL injection patterns, not just classic UNION/BOOLEAN injections in WHERE clauses.

Sources

SourceLink
github.comgithub.com/nextcloud/security-advisories/security/advisories/GHSA-5h2w-c7px-hp4j
github.comgithub.com/nextcloud/tables/pull/2186
hackerone.comhackerone.com/reports/3446689

Frequently asked

questions

Yes, it is exploitable via the web interface or API, but only by authenticated users who have access to the Tables app and can influence sorting or ordering parameters.

The attacker must be a legitimate Nextcloud user with permissions to access and interact with the Tables app. Anonymous or unauthenticated users typically cannot exploit this path.

The safest fix is to eliminate dynamic SQL construction for ORDER BY and instead implement a strict server-side mapping from user-chosen sort options to a fixed set of allowed column names and directions, rejecting any unexpected values.

Adopt a defensive coding standard that:

  • Uses parameterized queries for all data values.
  • Enforces whitelisting for any query elements that cannot be parameterized (like column names or directions).
  • Requires security review of any dynamic query-building code and includes automated checks for string-based SQL concatenation.
Find out what's already
exploitable in your codebase.