GHSA-9ggv-8w38-r7pm: TypeORM SQL Injection Vulnerability

MODERATE
CVSS 5.9
CWE-89
Published
Advisory Summary

GHSA-9ggv-8w38-r7pm is a MODERATE (CVSS 5.9) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting TypeORM libraries in the npm ecosystem. The issue involves sql injection in updatequerybuilder/softdeletequerybuilder orderby (mysql/mariadb). Remediation is available by upgrading affected packages to version 0.3.29.

GHSA-9ggv-8w38-r7pm at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-9ggv-8w38-r7pm
Severity MODERATE
CVSS v3.1 Base Score 5.9
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product TypeORM
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.9

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix GHSA-9ggv-8w38-r7pm

To remediate this vulnerability, upgrade all affected TypeORM dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

typeorm fixed: 0.3.29
npm install typeorm@0.3.29
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls typeorm

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-9ggv-8w38-r7pm, inspect your project dependencies using npm:

npm ls typeorm

Analyze the terminal output to locate any version of TypeORM in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.3.29), your application is affected.

Note: The npm ls typeorm 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 TypeORM, 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

### Impact Blind SQL injection vulnerability in `UpdateQueryBuilder` and `SoftDeleteQueryBuilder` affecting MySQL and MariaDB users. `UpdateQueryBuilder` and `SoftDeleteQueryBuilder` (including their `addOrderBy` variants) do not validate the `order` parameter against an allowlist of permitted values (`ASC`/`DESC`). The caller-supplied value is stored verbatim and concatenated directly into the generated SQL string without quoting or parameterization. `SelectQueryBuilder.orderBy` performs this validation correctly; the affected builders do not. If any code path passes user-controlled input to `orderBy`/`addOrderBy` on an update or soft-delete query, an attacker can inject arbitrary SQL via the sort direction — even when the column name itself is hardcoded. Demonstrated impact includes: - **Data exfiltration** via time-based blind extraction (e.g. using `SLEEP()` to infer secret values bit by bit) - **Row targeting manipulation** in queries using `LIMIT` patterns - **Denial of service** via `SLEEP()`-based query exhaustion CVSS 3.1: **8.6 (High)** — `AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L` Affected files (relative to commit `73fda419`): - `src/query-builder/UpdateQueryBuilder.ts`: lines 383–419 and 718–744 - `src/query-builder/SoftDeleteQueryBuilder.ts`: lines 352–388 and 520–546 The vulnerability was introduced in commit `03799bd2` (v0.1.12) and is present through the latest release (v0.3.28). ### Patches A fix has been released in 0.3.29 (1b66c44) and 1.0.0 (93eec63). ### Workarounds Applications can manually validate the `order` argument before passing it to `orderBy` or `addOrderBy` on update or soft-delete query builders: ```ts const direction = userInput.toUpperCase(); if (direction !== 'ASC' && direction !== 'DESC') { throw new Error('Invalid sort direction'); } qb.orderBy(column, direction as 'ASC' | 'DESC'); ``` Do not pass user-controlled values to `orderBy`/`addOrderBy` on `UpdateQueryBuilder` or `SoftDeleteQueryBuilder` without this validation. ### References - Introduced in commit 03799bd2 (v0.1.12) - Confirmed present in v0.3.28 (commit 73fda419) - See `SelectQueryBuilder.orderBy` for the correct validation pattern this fix should mirror

GHSA-9ggv-8w38-r7pm Affected TypeORM Versions

1 component(s)
Fixed Versions:
0.3.29
Product / Package Ecosystem Affected Versions Fixed Version
typeorm
npm
≥ 0.1.12
< 0.3.29
0.3.29

References

Frequently Asked Questions

What is GHSA-9ggv-8w38-r7pm?
GHSA-9ggv-8w38-r7pm is a security vulnerability in TypeORM involving SQL Injection in UpdateQueryBuilder/SoftDeleteQueryBuilder orderBy (MySQL/MariaDB) under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which TypeORM versions are affected?
Affected versions include releases prior to 0.3.29 across affected packages: typeorm.
What version fixes GHSA-9ggv-8w38-r7pm?
Upgrading to 0.3.29 (or the latest patched release for your respective branch) resolves the vulnerability.
Is typeorm affected?
Yes, typeorm is affected in releases prior to 0.3.29. Upgrade your dependency to 0.3.29 or later.
What is the CVSS score of GHSA-9ggv-8w38-r7pm?
GHSA-9ggv-8w38-r7pm has a CVSS v3.1 base score of 5.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with GHSA-9ggv-8w38-r7pm?
GHSA-9ggv-8w38-r7pm is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (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.).
How can I check npm dependencies for GHSA-9ggv-8w38-r7pm?
Run the dependency tree command: 'npm ls typeorm'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-9ggv-8w38-r7pm",
  "modified" : "2026-06-19T19:18:49Z",
  "published" : "2026-06-19T19:18:49Z",
  "aliases" : [ ],
  "summary" : "TypeORM: SQL Injection in UpdateQueryBuilder/SoftDeleteQueryBuilder orderBy (MySQL/MariaDB)",
  "details" : "### Impact\n\nBlind SQL injection vulnerability in `UpdateQueryBuilder` and `SoftDeleteQueryBuilder` affecting MySQL and MariaDB users.\n\n`UpdateQueryBuilder` and `SoftDeleteQueryBuilder` (including their `addOrderBy` variants) do not validate the `order` parameter against an allowlist of permitted values (`ASC`/`DESC`). The caller-supplied value is stored verbatim and concatenated directly into the generated SQL string without quoting or parameterization. `SelectQueryBuilder.orderBy` performs this validation correctly; the affected builders do not.\n\nIf any code path passes user-controlled input to `orderBy`/`addOrderBy` on an update or soft-delete query, an attacker can inject arbitrary SQL via the sort direction — even when the column name itself is hardcoded.\n\nDemonstrated impact includes:\n- **Data exfiltration** via time-based blind extraction (e.g. using `SLEEP()` to infer secret values bit by bit)\n- **Row targeting manipulation** in queries using `LIMIT` patterns\n- **Denial of service** via `SLEEP()`-based query exhaustion\n\nCVSS 3.1: **8.6 (High)** — `AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L`\n\nAffected files (relative to commit `73fda419`):\n- `src/query-builder/UpdateQueryBuilder.ts`: lines 383–419 and 718–744\n- `src/query-builder/SoftDeleteQueryBuilder.ts`: lines 352–388 and 520–546\n\nThe vulnerability was introduced in commit `03799bd2` (v0.1.12) and is present through the latest release (v0.3.28).\n\n### Patches\n\nA fix has been released in 0.3.29 (1b66c44) and 1.0.0 (93eec63).\n\n### Workarounds\n\nApplications can manually validate the `order` argument before passing it to `orderBy` or `addOrderBy` on update or soft-delete query builders:\n\n```ts\nconst direction = userInput.toUpperCase();\nif (direction !== 'ASC' && direction !== 'DESC') {\n  throw new Error('Invalid sort direction');\n}\nqb.orderBy(column, direction as 'ASC' | 'DESC');\n```\n\nDo not pass user-controlled values to `orderBy`/`addOrderBy` on `UpdateQueryBuilder` or `SoftDeleteQueryBuilder` without this validation.\n\n### References\n\n- Introduced in commit 03799bd2 (v0.1.12)\n- Confirmed present in v0.3.28 (commit 73fda419)\n- See `SelectQueryBuilder.orderBy` for the correct validation pattern this fix should mirror",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "typeorm"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.1.12"
      }, {
        "fixed" : "0.3.29"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.3.28"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/typeorm/typeorm/security/advisories/GHSA-9ggv-8w38-r7pm"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/typeorm/typeorm/commit/1b66c44d0410bdc56a0dcefb46be41867ec0fffc"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/typeorm/typeorm/commit/93eec630630b219b162ba4e0c072afa851697cff"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/typeorm/typeorm"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-19T19:18:49Z",
    "nvd_published_at" : null
  }
}