You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
typeorm migration:generate embeds database schema metadata into JS/TS template literals, escaping backticks but not ${...}. An attacker who can write schema metadata (column comments, defaults, view definitions) achieves arbitrary code execution on the host that loads the generated migration.
Details
MigrationGenerateCommand.ts (L117-138) wraps each SQL statement in a JS template literal, escaping only backticks:
Attacker sets ALTER TABLE ... DEFAULT '${...}'; payload appears in generated migration
CHECK constraint
Not exploitable
MySQL information_schema.CHECK_CONSTRAINTS strips content from CHECK_CLAUSE
View definitions
Not tested
Requires PostgreSQL ViewEntity introspection; likely exploitable via pg_get_viewdef()
Suggested fix: Escape ${ to \${ (and \\ to \\\\) before embedding query strings into template literals, or switch to emitting the SQL as a JSON.stringify()-encoded regular string argument.
PoC
Prerequisites:
Any supported RDBMS (PostgreSQL, MySQL, MariaDB, CockroachDB, SQL Server, Oracle, SAP HANA, or Spanner) accessible to the developer running migration:generate
The attacker has DDL/write access to the database, or the application exposes a feature allowing users to set column COMMENT, DEFAULT, or view definition text
Steps:
Inject payload into schema metadata. Set a column comment or default containing ${...}:
-- PostgreSQLCOMMENT ON COLUMN users.name IS '${process.mainModule.require("child_process").execSync("id > /tmp/pwned")}';
-- MySQLALTERTABLE users MODIFY COLUMN name VARCHAR(255) COMMENT '${process.mainModule.require("child_process").execSync("id > /tmp/pwned")}';
Run migration generation on the developer/CI machine:
The payload appears in whichever migration direction restores the DB's current state. A malicious DB comment with a clean entity comment places it in down(). Attacker-influenced entity metadata places it in up(). Either direction executes the code when the method runs.
Impact
Code injection / RCE. An attacker with DB schema write access executes arbitrary JavaScript on any machine that generates and loads the migration. This crosses the DB-to-host trust boundary.
CI/CD pipelines that auto-generate and run migrations are the highest-risk target. Any TypeORM user running migration:generate against a database with attacker-influenced schema metadata is affected.
👉 For a structured walk-through of the changes in v1.0 — breaking changes, new features, security fixes, and the upgrade path from 0.3.x — see the v1.0 Release Notes.
The list below is the set of commits between 0.3.30 and 1.0.0 — fixes already shipped on the 0.3.x line are listed under their respective 0.3.x entries below.
internal error: internal error: invalid GitHub workflow:
:30:31: could not parse as YAML: mapping values are not allowed in this context [syntax-check]
Token-Permissions
⚠️ -1
internal error: internal error: invalid GitHub workflow:
:30:31: could not parse as YAML: mapping values are not allowed in this context [syntax-check]
Packaging
⚠️ -1
internal error: internal error: invalid GitHub workflow:
:30:31: could not parse as YAML: mapping values are not allowed in this context [syntax-check]
Pinned-Dependencies
⚠️ -1
internal error: internal error: invalid GitHub workflow:
:30:31: could not parse as YAML: mapping values are not allowed in this context [syntax-check]
Code-Review
⚠️ 2
Found 7/28 approved changesets -- score normalized to 2
Binary-Artifacts
🟢 10
no binaries found in the repo
Maintained
🟢 10
17 commit(s) and 11 issue activity found in the last 90 days -- score normalized to 10
Security-Policy
⚠️ 0
security policy file detected
CII-Best-Practices
⚠️ 0
no effort to earn an OpenSSF best practices badge detected
License
🟢 10
license file detected
Fuzzing
⚠️ 0
project is not fuzzed
Signed-Releases
⚠️ -1
no releases found
Branch-Protection
⚠️ -1
internal error: error during branchesHandler.setup: internal error: some github tokens can't read classic branch protection rules: https://github.com/ossf/scorecard-action/blob/main/docs/authentication/fine-grained-auth-token.md
SAST
⚠️ -1
internal error: internal error: invalid GitHub workflow:
:30:31: could not parse as YAML: mapping values are not allowed in this context [syntax-check]
Next steps: Take a moment to review the security alert above. Review
the linked package source code to understand the potential risk. Ensure the
package is not malicious before proceeding. If you're unsure how to proceed,
reach out to your security team or ask the Socket team for help at
support@socket.dev.
Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.
Mark the package as acceptable risk. To ignore this alert only
in this pull request, reply with the comment
@SocketSecurity ignore npm/typeorm@0.3.31. You can
also ignore all packages with @SocketSecurity ignore-all.
To ignore an alert for all future pull requests, use Socket's Dashboard to
change the triage state of this alert.
Warn
Obfuscated code: npm typeorm is 90.0% likely obfuscated
Next steps: Take a moment to review the security alert above. Review
the linked package source code to understand the potential risk. Ensure the
package is not malicious before proceeding. If you're unsure how to proceed,
reach out to your security team or ask the Socket team for help at
support@socket.dev.
Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.
Mark the package as acceptable risk. To ignore this alert only
in this pull request, reply with the comment
@SocketSecurity ignore npm/typeorm@0.3.31. You can
also ignore all packages with @SocketSecurity ignore-all.
To ignore an alert for all future pull requests, use Socket's Dashboard to
change the triage state of this alert.
Warn
Obfuscated code: npm yargs is 90.0% likely obfuscated
Next steps: Take a moment to review the security alert above. Review
the linked package source code to understand the potential risk. Ensure the
package is not malicious before proceeding. If you're unsure how to proceed,
reach out to your security team or ask the Socket team for help at
support@socket.dev.
Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.
Mark the package as acceptable risk. To ignore this alert only
in this pull request, reply with the comment
@SocketSecurity ignore npm/yargs@17.7.3. You can
also ignore all packages with @SocketSecurity ignore-all.
To ignore an alert for all future pull requests, use Socket's Dashboard to
change the triage state of this alert.
renovateBot
changed the title
chore(deps): update dependency typeorm to v0.3.29 [security]
chore(deps): update dependency typeorm to v0.3.31 [security]
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.3.28→0.3.31TypeORM: SQL Injection in UpdateQueryBuilder/SoftDeleteQueryBuilder orderBy (MySQL/MariaDB)
GHSA-9ggv-8w38-r7pm
More information
Details
Impact
Blind SQL injection vulnerability in
UpdateQueryBuilderandSoftDeleteQueryBuilderaffecting MySQL and MariaDB users.UpdateQueryBuilderandSoftDeleteQueryBuilder(including theiraddOrderByvariants) do not validate theorderparameter 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.orderByperforms this validation correctly; the affected builders do not.If any code path passes user-controlled input to
orderBy/addOrderByon 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:
SLEEP()to infer secret values bit by bit)LIMITpatternsSLEEP()-based query exhaustionCVSS 3.1: 8.6 (High) —
AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:LAffected 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–546The 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
orderargument before passing it toorderByoraddOrderByon update or soft-delete query builders:Do not pass user-controlled values to
orderBy/addOrderByonUpdateQueryBuilderorSoftDeleteQueryBuilderwithout this validation.References
SelectQueryBuilder.orderByfor the correct validation pattern this fix should mirrorSeverity
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
TypeORM: migration:generate template-literal code injection
GHSA-2rp8-mm9q-fp49
More information
Details
Summary
typeorm migration:generateembeds database schema metadata into JS/TS template literals, escaping backticks but not${...}. An attacker who can write schema metadata (column comments, defaults, view definitions) achieves arbitrary code execution on the host that loads the generated migration.Details
MigrationGenerateCommand.ts(L117-138) wraps each SQL statement in a JS template literal, escaping only backticks:Introspected schema strings reach this sink through driver query runners:
DEFAULT,COMMENT,CHECKconstraints, view definitionsPostgresQueryRunner.ts:1782,L1898,L2287,L4125COLUMN_DEFAULT,COLUMN_COMMENTMysqlQueryRunner.ts:2873-2974,L3580-3583CockroachQueryRunner.tsescapeComment()on each driver strips only null bytes, leaving${...}intact:When the migration file is loaded (
migration:run,import, orrequire), the JS engine evaluates${...}as live interpolation.Affected source:
MigrationGenerateCommand.tsPostgresDriver.tsescapeComment()— PostgresMysqlDriver.tsescapeComment()— MySQLCockroachDriver.tsescapeComment()— CockroachDBConfirmed injection vectors (MySQL):
COMMENTDEFAULTALTER TABLE ... DEFAULT '${...}'; payload appears in generated migrationCHECKconstraintinformation_schema.CHECK_CONSTRAINTSstrips content fromCHECK_CLAUSEViewEntityintrospection; likely exploitable viapg_get_viewdef()Suggested fix: Escape
${to\${(and\\to\\\\) before embedding query strings into template literals, or switch to emitting the SQL as aJSON.stringify()-encoded regular string argument.PoC
Prerequisites:
migration:generateCOMMENT,DEFAULT, or view definition textSteps:
${...}:.tsfile contains unescaped${...}:Output confirms code execution —
idran on the host and its output was interpolated into the SQL:The payload appears in whichever migration direction restores the DB's current state. A malicious DB comment with a clean entity comment places it in
down(). Attacker-influenced entity metadata places it inup(). Either direction executes the code when the method runs.Impact
Code injection / RCE. An attacker with DB schema write access executes arbitrary JavaScript on any machine that generates and loads the migration. This crosses the DB-to-host trust boundary.
CI/CD pipelines that auto-generate and run migrations are the highest-risk target. Any TypeORM user running
migration:generateagainst a database with attacker-influenced schema metadata is affected.Severity
CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:H/I:H/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Release Notes
typeorm/typeorm (typeorm)
v0.3.31Compare Source
Bug Fixes
require()calls that break bundlers (#12647) (30f9fc7)Full Changelog: typeorm/typeorm@0.3.30...0.3.31
v0.3.30Compare Source
The list below is the set of commits between
0.3.30and1.0.0— fixes already shipped on the0.3.xline are listed under their respective0.3.xentries below.Bug Fixes
shortenmethod to properly work with camelCase_aliases (#11283) (8a9a376)timestamptzpersistence/hydration correctly (#11774) (c26fc33)queryBuilder.update(#11296) (7084240)Features
incrementanddecrementofEntityManager(#11294) (2260718)joinproperty (#12375) (f4f762e)ADD VALUEwhen changing enum values if possible (#10956) (f1be21e)INSERT INTO ... SELECT FROM ...in QueryBuilder (#11896) (8fc0915)Performance Improvements
BREAKING CHANGES
0.3.30 (2026-05-18)
Bug Fixes
Reverts
0.3.29 (2026-05-08)
Bug Fixes
QueryBuilderparameter of type JSDatenot escaped correctly (#11867) (5153436)Features
returningoption to update/upsert operations (#11782) (11d9767)0.3.28 (2025-12-02)
Bug Fixes
findBymethod to MongoEntityManager (#11814) (38715bb)Features
jsonpathcolumn type in PostgreSQL (#11684) (4f05718)0.3.27 (2025-09-19)
Bug Fixes
Features
VirtualColumns to be initially non-selectable (#11586) (22b26d1)Performance Improvements
Reverts
[0.3.26](https://redirect.github.com/typeorm/typeorm/compare/0.3.25.
Configuration
📅 Schedule: (UTC)
🚦 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.
This PR was generated by Mend Renovate. View the repository job log.