Severity:

HIGH RISK

(7.6)

SQL Injection in Contact Activity Timeline API Endpoint

CVE-2026-3105

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Data Exposure and Manipulation via SQL Injection

Severity:

HIGH RISK

(7.6)

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 Contact Activity timeline API endpoint allows authenticated users to influence the database query by manipulating the sort direction parameter.

Because the parameter was not strictly validated against an allowlist of expected values, an attacker could inject arbitrary SQL fragments into the query and potentially impact the confidentiality and integrity of stored data.

Affected context

The vulnerability occurs in the backend API responsible for retrieving contact activity timelines, specifically when building SQL queries that use a client-provided sort direction parameter.

It becomes relevant in deployments where authenticated users can call the affected API endpoint and where the application dynamically concatenates this parameter into the ORDER BY or related clauses without strict validation or sanitization.

The risk is heightened in environments where the application account has broad database privileges or where detailed error messages are exposed.

Exploit preconditions

  • Attack surface: The contact activity timeline retrieval API endpoint, accessible via authenticated HTTP(S) requests.
  • Required access: Valid authenticated user account with permission to invoke the contact activity timeline API.
  • User-controlled input: A query parameter (or field) controlling the sort direction, which is incorporated into the SQL statement.
  • Trigger point: The vulnerable code path is executed whenever the API endpoint processes a request and constructs the SQL query for fetching contact activities.
  • Why exploitation is possible: The sort direction parameter was not validated against a strict allowlist (e.g., ASC or DESC) and was likely interpolated directly into the SQL query, enabling attackers to inject additional SQL tokens or clauses.

Why this happens

This issue stems from constructing SQL queries with untrusted input that is not constrained to a fixed set of safe values.

Instead of using a strict allowlist or mapping user-friendly values to hardcoded SQL keywords, the application incorporates the sort direction parameter directly into the query string.

This pattern aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command, where user input is allowed to alter the structure of a SQL query, potentially enabling injection of arbitrary SQL commands.

Potential impact

  • An attacker may be able to modify the query logic to read additional records beyond those intended by the API design.
  • The attacker could potentially access sensitive contact-related data they should not be authorized to view.
  • Under certain database privilege configurations, the attacker could manipulate or delete data in the underlying tables.
  • The attacker may be able to infer database schema details or internal query structure from error responses or timing behavior.

General mitigation guidance

Effective mitigation focuses on removing the ability for user input to alter SQL structure, especially in control fields like sort direction or column names.

Common hardening patterns include:

  • Enforcing a strict allowlist for sort direction values (e.g., mapping user input to a fixed set like ASC or DESC, and rejecting or defaulting on any unexpected value).
  • Avoiding direct interpolation of client-supplied values into SQL query strings, particularly in ORDER BY clauses.
  • Centralizing query construction logic so that dynamic components are carefully vetted and transformed into safe internal representations.
  • Restricting database permissions for the application account to only the operations and tables it truly needs.
  • Normalizing API contracts so that clients choose from predefined sort options instead of providing raw query fragments or keywords.

How teams detect issues like this

Organizations can look for this class of issue through a combination of code-focused and runtime-focused techniques:

  • Static analysis: Configure SAST rules to flag string concatenation in SQL query construction, particularly where user input influences ORDER BY or other structural clauses.
  • Code review: During manual review, pay special attention to endpoints that accept parameters for sorting, filtering, or field selection, verifying that these are controlled by allowlists or mappings instead of direct interpolation.
  • Security testing: Use parameter fuzzing in QA or staging environments to send unexpected values for direction and sort parameters and observe whether the application returns SQL errors or behaves unexpectedly.
  • Central policies: Implement coding standards that mandate the use of query builders or ORM abstractions for all dynamic queries, and require explicit allowlists for all user-controlled query modifiers.

Sources

SourceLink
github.comgithub.com/mautic/mautic/security/advisories/GHSA-r5j5-q42h-fc93

Frequently asked

questions

Yes. It is exploitable over the network via the affected API endpoint, but it requires a valid authenticated account that can access the contact activity timeline API.

The attacker must be authenticated and have sufficient permissions to invoke the vulnerable API. Elevated roles may increase the amount or sensitivity of data that can be accessed or modified, but the injection flaw itself does not require administrative privileges.

The safest pattern is to prevent user input from controlling SQL structure. For sort direction and similar control fields, use strict allowlists or hardcoded mappings, and build queries with parameterized APIs or query builders so that only values—not SQL keywords or operators—are influenced by user input.

Adopt consistent secure coding practices: always treat client input as untrusted, use parameterized queries or ORM methods, enforce allowlists for any query modifiers like sort direction or column selection, and integrate automated security checks (SAST, code review guidelines, and security tests) into the development lifecycle.

Find out what's already
exploitable in your codebase.