TypeORM: migration:generate template-literal code injection
TypeORM's migration:generate command embeds database schema metadata into JavaScript/TypeScript template literals without properly escaping template interpolation syntax `${...}`. This allows an attacker who can write schema metadata such as column comments or defaults to inject arbitrary code that executes when the generated migration file is loaded. The vulnerability affects TypeORM versions before 0.3.31 and versions from 1.0.0 up to but not including 1.1.0.
AI Analysis
Technical Summary
The TypeORM migration:generate command constructs migration files by embedding SQL statements inside JS/TS template literals, escaping backticks but not the `${...}` interpolation syntax. Schema metadata from various database drivers (Postgres, MySQL/MariaDB, CockroachDB) such as column comments and defaults are included without escaping `${`, allowing an attacker with write access to schema metadata to inject arbitrary JavaScript code. When the generated migration file is loaded (via migration:run, import, or require), the injected code executes. Confirmed injection vectors include MySQL column COMMENT and DEFAULT fields. The suggested fix is to escape `${` sequences or switch to safer string encoding methods.
Potential Impact
An attacker with the ability to write schema metadata (e.g., column comments or defaults) can achieve arbitrary code execution on the host machine that loads the generated migration file. This can lead to full compromise of the development or CI environment where migrations are generated or run. The vulnerability does not affect runtime database operations but targets the migration generation and execution process.
Mitigation Recommendations
Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until a fix is available, avoid running migration:generate on databases where untrusted users can write schema metadata containing `${...}` sequences. Review and sanitize schema metadata inputs to prevent injection. Monitor official TypeORM repositories and advisories for patches that properly escape `${` in template literals or change the migration generation approach.
TypeORM: migration:generate template-literal code injection
Description
TypeORM's migration:generate command embeds database schema metadata into JavaScript/TypeScript template literals without properly escaping template interpolation syntax `${...}`. This allows an attacker who can write schema metadata such as column comments or defaults to inject arbitrary code that executes when the generated migration file is loaded. The vulnerability affects TypeORM versions before 0.3.31 and versions from 1.0.0 up to but not including 1.1.0.
CVSS v3.1
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The TypeORM migration:generate command constructs migration files by embedding SQL statements inside JS/TS template literals, escaping backticks but not the `${...}` interpolation syntax. Schema metadata from various database drivers (Postgres, MySQL/MariaDB, CockroachDB) such as column comments and defaults are included without escaping `${`, allowing an attacker with write access to schema metadata to inject arbitrary JavaScript code. When the generated migration file is loaded (via migration:run, import, or require), the injected code executes. Confirmed injection vectors include MySQL column COMMENT and DEFAULT fields. The suggested fix is to escape `${` sequences or switch to safer string encoding methods.
Potential Impact
An attacker with the ability to write schema metadata (e.g., column comments or defaults) can achieve arbitrary code execution on the host machine that loads the generated migration file. This can lead to full compromise of the development or CI environment where migrations are generated or run. The vulnerability does not affect runtime database operations but targets the migration generation and execution process.
Mitigation Recommendations
Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until a fix is available, avoid running migration:generate on databases where untrusted users can write schema metadata containing `${...}` sequences. Review and sanitize schema metadata inputs to prevent injection. Monitor official TypeORM repositories and advisories for patches that properly escape `${` in template literals or change the migration generation approach.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-2rp8-mm9q-fp49
- Osv Schema Version
- 1.4.0
- Aliases
- []
- Ecosystems
- ["npm"]
- Database Specific Severity
- MODERATE
- Cvss Version
- 3.1
Threat ID: 6a600aa09c2644c7f8fdfa9b
Added to database: 07/22/2026, 00:11:12 UTC
Last enriched: 07/22/2026, 00:38:03 UTC
Last updated: 07/22/2026, 00:38:03 UTC
Views: 2
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.