Summary
Workarounds
Applications can manually validate the order argument before passing it to orderBy or addOrderBy on update or soft-delete query builders:
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.orderByfor the correct validation pattern this fix should mirror
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
LIMITpatterns - 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–744src/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).
Untrusted input alters a database query, allowing the attacker to read or modify data the query was not intended to access. Typical impact: data disclosure or modification.
GHSA-9GGV-8W38-R7PM has a CVSS score of 5.9 (Medium). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (0.3.29); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Remediation advice
A fix has been released in 0.3.29 (1b66c44) and 1.0.0 (93eec63).
Frequently Asked Questions
- What is GHSA-9GGV-8W38-R7PM? GHSA-9GGV-8W38-R7PM is a medium-severity SQL injection vulnerability in typeorm (npm), affecting versions >= 0.1.12, <= 0.3.28. It is fixed in 0.3.29. Untrusted input alters a database query, allowing the attacker to read or modify data the query was not intended to access.
- How severe is GHSA-9GGV-8W38-R7PM? GHSA-9GGV-8W38-R7PM has a CVSS score of 5.9 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of typeorm are affected by GHSA-9GGV-8W38-R7PM? typeorm (npm) versions >= 0.1.12, <= 0.3.28 is affected.
- Is there a fix for GHSA-9GGV-8W38-R7PM? Yes. GHSA-9GGV-8W38-R7PM is fixed in 0.3.29. Upgrade to this version or later.
- Is GHSA-9GGV-8W38-R7PM exploitable, and should I be worried? Whether GHSA-9GGV-8W38-R7PM is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-9GGV-8W38-R7PM is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-9GGV-8W38-R7PM? Upgrade
typeormto 0.3.29 or later.