Skip to content

Update dependency drizzle-orm to ^0.45.2 [SECURITY]#65

Open
renovate[bot] wants to merge 1 commit intomainfrom
renovate/npm-drizzle-orm-vulnerability
Open

Update dependency drizzle-orm to ^0.45.2 [SECURITY]#65
renovate[bot] wants to merge 1 commit intomainfrom
renovate/npm-drizzle-orm-vulnerability

Conversation

@renovate
Copy link
Copy Markdown
Contributor

@renovate renovate bot commented Apr 8, 2026

This PR contains the following updates:

Package Change Age Confidence
drizzle-orm (source) ^0.41.0^0.45.2 age confidence

Warning

Some dependencies could not be looked up. Check the Dependency Dashboard for more information.

GitHub Vulnerability Alerts

CVE-2026-39356

Summary

Drizzle ORM improperly escaped quoted SQL identifiers in its dialect-specific escapeName() implementations. In affected versions, embedded identifier delimiters were not escaped before the identifier was wrapped in quotes or backticks.

As a result, applications that pass attacker-controlled input to APIs that construct SQL identifiers or aliases, such as sql.identifier(), .as(), may allow an attacker to terminate the quoted identifier and inject SQL.

Affected components

The issue affects the identifier escaping logic used by the PostgreSQL, MySQL, SQLite, SingleStore, and Gel dialects.

Impact

This issue only affects applications that pass untrusted runtime input into identifier or alias construction. Common examples include dynamic sorting, dynamic report builders, and CTE or alias names derived from request parameters.

Depending on the database dialect, query context, and database permissions, successful exploitation may enable blind or direct data disclosure, schema enumeration, query manipulation, privilege escalation, or destructive operations.

Applications that use only static schema objects, or that strictly map user input through an allowlist of known column or alias names, are not affected.

Details

In affected versions, escapeName() wrapped the identifier but did not escape the quote delimiter inside the identifier value:

  • PostgreSQL / SQLite / Gel: " was not doubled to ""
  • MySQL / SingleStore: ` was not doubled to ``

Because of this, crafted input containing the dialect-specific identifier delimiter could break out of the quoted identifier and be interpreted as SQL syntax.

A representative vulnerable pattern is dynamic sorting using untrusted input:

const sortField = req.query.sort || 'id';

const rows = await db
  .select()
  .from(users)
  .orderBy(sql.identifier(sortField));

---

### Release Notes

<details>
<summary>drizzle-team/drizzle-orm (drizzle-orm)</summary>

### [`v0.45.2`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.45.2)

[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.45.1...0.45.2)

- Fixed `sql.identifier()`, `sql.as()` escaping issues. Previously all the values passed to this functions were not properly escaped
  causing a possible SQL Injection (CWE-89) vulnerability

Thanks to [@&#8203;EthanKim88](https://redirect.github.com/EthanKim88), [@&#8203;0x90sh](https://redirect.github.com/0x90sh) and [@&#8203;wgoodall01](https://redirect.github.com/wgoodall01) for reaching out to us with a reproduction and suggested fix

### [`v0.45.1`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.45.1)

[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.45.0...0.45.1)

- Fixed pg-native Pool detection in node-postgres transactions breaking in environments with forbidden `require()` ([#&#8203;5107](https://redirect.github.com/drizzle-team/drizzle-orm/issues/5107))

### [`v0.45.0`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.45.0)

[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.44.7...0.45.0)

- Fixed pg-native Pool detection in node-postgres transactions
- Allowed subqueries in select fields
- Updated typo algorythm => algorithm
- Fixed `$onUpdate` not handling `SQL` values (fixes [#&#8203;2388](https://redirect.github.com/drizzle-team/drizzle-orm/issues/2388), tests implemented by [L-Mario564](https://redirect.github.com/L-Mario564) in [#&#8203;2911](https://redirect.github.com/drizzle-team/drizzle-orm/pull/2911))
- Fixed `pg` mappers not handling `Date` instances in `bun-sql:postgresql` driver responses for `date`, `timestamp` types (fixes [#&#8203;4493](https://redirect.github.com/drizzle-team/drizzle-orm/issues/4493))

### [`v0.44.7`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.44.7)

[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.44.6...0.44.7)

- fix durable sqlite transaction return value [#&#8203;3746](https://redirect.github.com/drizzle-team/drizzle-orm/issues/3746) - thanks [@&#8203;joaocstro](https://redirect.github.com/joaocstro)

### [`v0.44.6`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.44.6)

[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.44.5...0.44.6)

- feat: add $replicas reference [#&#8203;4874](https://redirect.github.com/drizzle-team/drizzle-orm/issues/4874)

### [`v0.44.5`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.44.5)

[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.44.4...0.44.5)

- Fixed invalid usage of `.one()` in `durable-sqlite` session
- Fixed spread operator related crash in sqlite `blob` columns
- Better browser support for sqlite `blob` columns
- Improved sqlite `blob` mapping

### [`v0.44.4`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.44.4)

[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.44.3...0.44.4)

- Fix wrong DrizzleQueryError export. thanks [@&#8203;nathankleyn](https://redirect.github.com/nathankleyn)

### [`v0.44.3`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.44.3)

[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.44.2...0.44.3)

- Fixed types of `$client` for clients created by drizzle function

```ts
await db.$client.[...]
  • Added the updated_at column to the neon_auth.users_sync table definition.

v0.44.2

Compare Source

  • [BUG]: Fixed type issues with joins with certain variations of tsconfig: #​4535, #​4457

v0.44.1

Compare Source

v0.44.0

Compare Source

Error handling

Starting from this version, we’ve introduced a new DrizzleQueryError that wraps all errors from database drivers and provides a set of useful information:

  1. A proper stack trace to identify which exact Drizzle query failed
  2. The generated SQL string and its parameters
  3. The original stack trace from the driver that caused the DrizzleQueryError

Drizzle cache module

Drizzle sends every query straight to your database by default. There are no hidden actions, no automatic caching or invalidation - you’ll always see exactly what runs. If you want caching, you must opt in.

By default, Drizzle uses a explicit caching strategy (i.e. global: false), so nothing is ever cached unless you ask. This prevents surprises or hidden performance traps in your application. Alternatively, you can flip on all caching (global: true) so that every select will look in cache first.

Out first native integration was built together with Upstash team and let you natively use upstash as a cache for your drizzle queries

import { upstashCache } from "drizzle-orm/cache/upstash";
import { drizzle } from "drizzle-orm/...";

const db = drizzle(process.env.DB_URL!, {
  cache: upstashCache({
    // 👇 Redis credentials (optional — can also be pulled from env vars)
    url: '<UPSTASH_URL>',
    token: '<UPSTASH_TOKEN>',
    // 👇 Enable caching for all queries by default (optional)
    global: true,
    // 👇 Default cache behavior (optional)
    config: { ex: 60 }
  })
});

You can also implement your own cache, as Drizzle exposes all the necessary APIs, such as get, put, mutate, etc.
You can find full implementation details on the website

import Keyv from "keyv";
export class TestGlobalCache extends Cache {
  private globalTtl: number = 1000;
  // This object will be used to store which query keys were used
  // for a specific table, so we can later use it for invalidation.
  private usedTablesPerKey: Record<string, string[]> = {};
  constructor(private kv: Keyv = new Keyv()) {
    super();
  }
  // For the strategy, we have two options:
  // - 'explicit': The cache is used only when .$withCache() is added to a query.
  // - 'all': All queries are cached globally.
  // The default behavior is 'explicit'.
  override strategy(): "explicit" | "all" {
    return "all";
  }
  // This function accepts query and parameters that cached into key param,
  // allowing you to retrieve response values for this query from the cache.
  override async get(key: string): Promise<any[] | undefined> {
    ...
  }
  // This function accepts several options to define how cached data will be stored:
  // - 'key': A hashed query and parameters.
  // - 'response': An array of values returned by Drizzle from the database.
  // - 'tables': An array of tables involved in the select queries. This information is needed for cache invalidation.
  //
  // For example, if a query uses the "users" and "posts" tables, you can store this information. Later, when the app executes
  // any mutation statements on these tables, you can remove the corresponding key from the cache.
  // If you're okay with eventual consistency for your queries, you can skip this option.
  override async put(
    key: string,
    response: any,
    tables: string[],
    config?: CacheConfig,
  ): Promise<void> {
    ...
  }
  // This function is called when insert, update, or delete statements are executed.
  // You can either skip this step or invalidate queries that used the affected tables.
  //
  // The function receives an object with two keys:
  // - 'tags': Used for queries labeled with a specific tag, allowing you to invalidate by that tag.
  // - 'tables': The actual tables affected by the insert, update, or delete statements,
  //   helping you track which tables have changed since the last cache update.
  override async onMutate(params: {
    tags: string | string[];
    tables: string | string[] | Table<any> | Table<any>[];
  }): Promise<void> {
    ...
  }
}

For more usage example you can check our docs

v0.43.1

Compare Source

Fixes

v0.43.0

Compare Source

Features

  • Added cross join (#​1414)
  • Added lateral left, inner, cross joins to PostgreSQL, MySQL, Gel, SingleStore
  • Added drizzle connection attributes to SingleStore's driver instances

Fixes

  • Removed unsupported by dialect full join from MySQL select api
  • Forced Gel columns to always have explicit schema & table prefixes due to potential errors caused by lack of such prefix in subquery's selection when there's already a column bearing same name in context
  • Added missing export for PgTextBuilderInitial type
  • Removed outdated IfNotImported type check from SingleStore driver initializer
  • Fixed incorrect type inferrence for insert and update models with non-strict tsconfigs (#​2654)
  • Fixed invalid spelling of nowait flag (#​3554)
  • Add join lateral support
  • Remove .fullJoin() from MySQL API

v0.42.0

Compare Source

Features

Duplicate imports removal

When importing from drizzle-orm using custom loaders, you may encounter issues such as: SyntaxError: The requested module 'drizzle-orm' does not provide an export named 'eq'

This issue arose because there were duplicated exports in drizzle-orm. To address this, we added a set of tests that checks every file in drizzle-orm to ensure all exports are valid. These tests will fail if any new duplicated exports appear.

In this release, we’ve removed all duplicated exports, so you should no longer encounter this issue.

pgEnum and mysqlEnum now can accept both strings and TS enums

If you provide a TypeScript enum, all your types will be inferred as that enum - so you can insert and retrieve enum values directly. If you provide a string union, it will work as before.

enum Test {
  a = 'a',
  b = 'b',
  c = 'c',
}

const tableWithTsEnums = mysqlTable('enums_test_case', {
  id: serial().primaryKey(),
  enum1: mysqlEnum(Test).notNull(),
  enum2: mysqlEnum(Test).default(Test.a),
});

await db.insert(tableWithTsEnums).values([
  { id: 1, enum1: Test.a, enum2: Test.b, enum3: Test.c },
  { id: 2, enum1: Test.a, enum3: Test.c },
  { id: 3, enum1: Test.a },
]);

const res = await db.select().from(tableWithTsEnums);

expect(res).toEqual([
  { id: 1, enum1: 'a', enum2: 'b', enum3: 'c' },
  { id: 2, enum1: 'a', enum2: 'a', enum3: 'c' },
  { id: 3, enum1: 'a', enum2: 'a', enum3: 'b' },
]);

Improvements

  • Make inArray accept ReadonlyArray as a value - thanks @​Zamiell
  • Pass row type parameter to @planetscale/database's execute - thanks @​ayrton
  • New InferEnum type - thanks @​totigm

Issues closed


Configuration

📅 Schedule: (UTC)

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

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, 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 force-pushed the renovate/npm-drizzle-orm-vulnerability branch from 9cdc1dc to 8dfdead Compare April 8, 2026 17:39
@renovate renovate bot changed the title Update dependency drizzle-orm to ^0.45.2 [SECURITY] Update dependency drizzle-orm to ^0.45.0 [SECURITY] Apr 8, 2026
@renovate renovate bot force-pushed the renovate/npm-drizzle-orm-vulnerability branch from 8dfdead to 357db06 Compare April 8, 2026 22:56
@renovate renovate bot changed the title Update dependency drizzle-orm to ^0.45.0 [SECURITY] Update dependency drizzle-orm to ^0.45.2 [SECURITY] Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants