chore(deps): update dependency typeorm to v0.3.31 [security] - #205
Conversation
jackchuka
left a comment
There was a problem hiding this comment.
typeorm 0.3.29 → 0.3.31 (devDependency + peerDependency of packages/typeorm-tailordb; peer range >=0.3 <1 unchanged, so no consumer impact).
Advisory: GHSA-2rp8-mm9q-fp49 (moderate, CVSS 5.7, CWE-94, no CVE assigned). typeorm migration:generate embedded introspected schema metadata into template literals escaping backticks but not ${...}, so anyone with DDL write access could plant ${process.mainModule.require("child_process").execSync(...)} in a column comment and get execution on the dev/CI host. Fix verified in the 0.3.31 tarball.
This repo is not exposed: the sink is the migration:generate CLI exclusively, which is never invoked here — no migration files, and the driver actively throws 'SchemaBuilder not supported in Tailordb prototype'. Hygiene bump, not remediation.
Checked the two internal paths this package monkey-patches (browser/driver/DriverFactory.js, browser/subscriber/Broadcaster.js): byte-identical between 0.3.29 and 0.3.31, so the DriverFactory.prototype.create patch is safe. 0.3.31 also tightens invalidWhereValuesBehavior to throw on writes and rejects empty where criteria on update/delete — this driver only forwards raw SQL, unaffected.
NB: zero CI ran — there is no paths-filter entry for typeorm-tailordb. Safe to merge.
This PR contains the following updates:
0.3.29→0.3.31TypeORM: 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 (2025-08-16)
Notes:
stringifyObjects: true, in order to avoid a potential security vulnerabilityin the mysql/mysql2 client libraries. You can revert to the old behavior by setting
connectionOptions.extra.stringifyObjects = false.@sap/hana-clientlibrary. The deprecatedhdb-poolis no longer necessary and can be removed. See https://typeorm.io/docs/drivers/sap/#data-source-options for the new pool options.
Bug Fixes
stringifyObjectsimplicitly (#11574) (d57fe3b)useIndexwhen cloning a QueryExpressionMap (or a QueryBuilder) (#10679) (66ee307), closes #10678 #10678Features
Configuration
📅 Schedule: (UTC)
🚦 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.
This PR was generated by Mend Renovate. View the repository job log.