/

CVE-2026-30951

Severity:

HIGH RISK

(7.5)

SQL Injection in Sequelize JSON/JSONB Where Clauses

CVE-2026-30951

Modified

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Data Exfiltration and Query Manipulation

Severity:

HIGH RISK

(7.5)

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

Sequelize versions prior to 6.37.8 contain a SQL injection vulnerability in JSON/JSONB where-clause handling, where user-controlled JSON path keys can influence a CAST(... AS <type>) expression.

If an attacker can control JSON object keys passed into Sequelize queries, they can inject arbitrary SQL and read data from other tables in the same database.

Affected context

The issue arises in Node.js applications using Sequelize (before 6.37.8) when:

  • The application uses JSON or JSONB columns in database queries
  • JSON path expressions are constructed from dynamic or user-controlled keys
  • The internal _traverseJSON() helper derives a cast type by splitting keys on ::
  • The derived cast type is embedded directly into CAST(... AS <type>) without proper escaping

This typically affects APIs that accept flexible JSON filters or field paths and pass them into Sequelize's JSON/JSONB querying helpers.

Exploit preconditions

  • Attack surface: Application endpoints or code paths that accept JSON structures and use them to build Sequelize JSON/JSONB where clauses.
  • Required access: Ability to supply or influence JSON object keys (not just values) used in query construction, often via HTTP request bodies, query parameters, or message payloads.
  • Trigger point: Execution of a Sequelize query that invokes _traverseJSON() and constructs CAST(... AS <type>) using the attacker-controlled JSON key segment after ::.
  • Why exploitation is possible: The JSON path key is split on :: and the substring after :: is treated as a SQL type name and interpolated directly into the CAST expression without parameterization or validation, enabling injection into the SQL query text.

Why this happens

This vulnerability stems from unsafe string interpolation when constructing SQL fragments based on parsed JSON path components.

The _traverseJSON() function interprets pathPart::typeName as a JSON path pathPart combined with a cast type typeName, but it treats typeName as trusted input and inserts it raw into the CAST(... AS <typeName>) clause.

This pattern maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, where untrusted data is concatenated into SQL rather than bound as parameters or validated against a strict allowlist.

The underlying bug class is dynamic query generation that mixes user-controlled metadata (JSON keys) with SQL syntax without robust sanitization or type validation.

Potential impact

  • An attacker may inject arbitrary SQL fragments into CAST expressions, potentially altering the structure of the generated query.
  • An attacker could exfiltrate sensitive data from other tables accessible to the database user.
  • An attacker can bypass logical filters or modify WHERE clauses to return broader or unintended result sets.
  • Under certain schemas and permissions, an attacker might modify or delete data by leveraging stacked or nested injection patterns, depending on the database and query context.

General mitigation guidance

Effective mitigation focuses on treating all components of SQL, including type names and path expressions, as untrusted unless explicitly validated:

  • Avoid building SQL fragments from raw string manipulation in ORM internals; prefer parameterized constructs or structured query APIs where possible.
  • Validate any cast type or similar meta-parameters against a strict allowlist of expected SQL types before using them in a CAST expression.
  • Disallow or normalize special delimiters (such as ::) in user-controlled JSON keys when they are used to form query paths.
  • Apply defense-in-depth by limiting database account privileges to only the tables and operations the application requires, so that injected queries have reduced impact.
  • Prefer secure-by-default query builder patterns that separate data (parameters, keys) from SQL syntax, even for advanced features like JSON path navigation and casting.

How teams detect issues like this

Organizations can look for this class of issue through a combination of static analysis, code review, and runtime monitoring:

  • Static analysis and review: Search for ORM helpers or utility functions that:
  • Parse user-controlled strings to derive SQL types, operators, or column fragments.
  • Use string concatenation to build CAST, WHERE, or JSON path expressions rather than parameterized methods.
  • Interpret delimiters like :: in user input for special SQL behavior.
  • Policy enforcement: Establish coding guidelines that prohibit direct embedding of uncontrolled input into SQL type names, operators, or identifiers, and enforce them via lint rules or pre-merge checks.
  • Runtime monitoring: Inspect database query logs for unusual or highly dynamic CAST(... AS ...) patterns or unexpected type names originating from API inputs.
  • Automated security tooling, including SAST and ORM-specific linters, can be configured to flag dynamic SQL construction and use of unvalidated type casts.

Sources

SourceLink
github.comgithub.com/sequelize/sequelize/security/advisories/GHSA-6457-6jrx-69cr
access.redhat.comaccess.redhat.com/errata/RHSA-2026:8498
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-30951
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2446250
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-30951.json

Frequently asked

questions

Exploitability depends on whether an attacker can control JSON object keys that your application passes into Sequelize's JSON/JSONB querying APIs. If keys are derived directly or indirectly from request data without restriction, exploitation is typically straightforward.

Not necessarily. If unauthenticated endpoints accept JSON input and feed it into affected Sequelize queries, an anonymous attacker may exploit the bug. In many applications, however, the vulnerable paths are behind authenticated APIs, limiting exploitation to authenticated users with access to those endpoints.

The safest pattern is to avoid deriving SQL syntax elements—such as type names, operators, or identifiers—from user-controlled input. Instead, map any dynamic behavior to a fixed allowlist of supported types and operators, and use ORM or parameterized query APIs that prevent raw string injection.

Treat all aspects of a query, including metadata like JSON paths and type casts, as untrusted unless validated. Design helper functions so that user input is only ever used as parameter values, not embedded into SQL syntax, enforce strict validation/allowlists for any dynamic behavior, and include automated checks in CI to detect unsafe string-based SQL construction.

Find out what's already
exploitable in your codebase.