Summary
A critical SQL injection vulnerability in OpenReplay's POST /{projectId}/cards/search endpoint allows untrusted input from the sort.field parameter to be interpolated into SQL queries.
If an attacker can send crafted requests to this endpoint, they may execute arbitrary SQL commands against the backend database, leading to data exfiltration, modification, or destruction.
Affected context
This vulnerability appears in OpenReplay deployments that expose the POST /{projectId}/cards/search API and use the sort.field request parameter to dynamically influence database query ordering.
The risk is present when:
- User-controlled values for
sort.fieldare incorporated into SQL without strict validation or parameterization, and - The application runs with a database account that has broad read/write privileges on application tables.
Any internet- or network-accessible instance of this endpoint is potentially affected, depending on access controls and API authentication.
Exploit preconditions
- Attack surface: HTTP API endpoint
POST /{projectId}/cards/search. - Required access: Ability to issue requests to the OpenReplay backend (through the UI, API client, or intercepted traffic). Authentication requirements depend on deployment configuration.
- Trigger point: Supplying a specially crafted
sort.fieldvalue that is propagated into the SQL query for card search or sorting. - Why exploitation is possible: The application treats
sort.fieldas trusted and concatenates it or otherwise embeds it into an SQL statement without robust parameterization or strict whitelisting, enabling the attacker to alter query structure.
Why this happens
The underlying flaw is a classic CWE-89: SQL Injection issue.
The server-side handler for POST /{projectId}/cards/search uses the sort.field parameter to influence the ORDER BY or similar clause of a SQL query but fails to strictly constrain the allowed values or use a safe, parameterized mechanism for column selection.
Instead of mapping sort.field to a fixed set of known-safe column identifiers, the implementation effectively blends user input into the query text, allowing adversaries to inject additional SQL tokens.
This insecure pattern arises whenever application logic dynamically constructs SQL from user-controlled strings rather than separating code from data.
Potential impact
- Extraction of sensitive information from OpenReplay's database, including session metadata and potentially user-related data.
- Unauthorized modification or deletion of stored records, impacting data integrity and auditability.
- Creation or alteration of application-level accounts or configuration data stored in the database.
- Escalation to broader system compromise if the database account has powerful privileges or if SQL features allow execution of server-side functions.
- Denial of service through destructive queries (e.g., dropping tables or locking resources).
General mitigation guidance
Effective mitigation for this class of issue centers on removing direct string interpolation in SQL and constraining dynamic query parts:
- Use parameterized queries or prepared statements for all variable data; never build SQL by concatenating request parameters.
- For dynamic sorting, map the
sort.fieldvalue to a predefined whitelist of column names, rejecting any value outside this set. - Encapsulate query construction in a data-access layer or ORM that exposes safe APIs for ordering, filtering, and pagination instead of raw SQL string handling.
- Enforce least privilege for the database account used by the application, limiting its ability to perform schema changes or access unrelated tables.
- Apply centralized input validation and normalization, particularly on parameters used for search, filtering, or sorting, to ensure they match expected formats and enumerations.
How teams detect issues like this
Organizations can identify and monitor this type of vulnerability through a combination of preventive and detective controls:
- Static analysis: Configure SAST rules to flag raw SQL construction, string concatenation in query builders, and direct use of request parameters in query strings.
- Code review: During manual reviews, scrutinize endpoints that support dynamic filtering or sorting, verifying that they use whitelists and parameterized access patterns for column names.
- Dynamic testing: Use automated scanners or custom test harnesses that inject SQL metacharacters into parameters like
sort.fieldto observe unexpected behavior or error messages. - Database monitoring: Enable query logging and anomaly detection to highlight unusual or syntactically suspicious SQL statements, particularly those containing repeated patterns of common injection payload fragments.

