Code Injection Vulnerability in TypeORM: Migration Generation

typeorm Updated 22 Jul 2026

Summary

21/07/2026
MODERATE
Yes i
Moderate
5.7

GHSA-2rp8-mm9q-fp49: TypeORM: migration:generate template-literal code injection. Affects typeorm across 2 version ranges.

< 0.3.31 >= 1.0.0, < 1.1.0

Fixed in 0.3.31 or 1.1.0, depending on the release line you run. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

TypeORM is an open-source Object-Relational Mapping (ORM) library for TypeScript and JavaScript that enables developers to interact with databases using an object-oriented approach. It supports various databases, including PostgreSQL, MySQL, and MariaDB. The library allows for seamless database migrations, schema management, and data manipulation. However, a critical vulnerability has been identified in the migration generation process, which could allow attackers to execute arbitrary code on the host machine.

Vulnerability Detail

The vulnerability arises from the way TypeORM handles database schema metadata during the migration generation process. Specifically, the migration:generate command embeds this metadata into JavaScript/TypeScript template literals, escaping backticks but failing to escape ${...}. This oversight allows an attacker with write access to the database schema (through column comments, defaults, or view definitions) to inject malicious code. When the generated migration file is loaded, the JavaScript engine evaluates the injected code, leading to potential remote code execution (RCE) on the host running the migration.

How To Fix

Latest published version: 1.1.2 as of 22 Oct 2026

npm install typeorm@1.1.2

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 0.3.31 0.3.31
    npm install typeorm@0.3.31
  • >= 1.0.0, < 1.1.0 1.1.0
    npm install typeorm@1.1.0

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

As a temporary workaround, avoid using the migration:generate command on databases where schema metadata can be influenced by untrusted users. Additionally, ensure that any user with write access to the database schema is trusted and has limited privileges.

Conclusion

The code injection vulnerability in TypeORM's migration generation process poses a significant risk to applications that utilize this ORM. By understanding the nature of the vulnerability, applying the necessary updates, and implementing workarounds, developers can protect their applications from potential exploitation.

See every vulnerability recorded for typeorm →

Share this vulnerability

FAQ

An attacker with write access to the database schema can execute arbitrary JavaScript code on the host machine, potentially leading to data breaches or system compromise.

You can use Vulert, which monitors and alerts for open-source vulnerabilities in real-time. By analyzing your package-lock.json file, Vulert can identify if your application is affected by this vulnerability.

The vulnerability affects TypeORM versions prior to 0.3.31 and 1.1.0. Ensure you are using the latest version to mitigate the risk.

If immediate updates are not possible, implement the suggested workaround by restricting write access to the database schema and avoiding the use of the migration:generate command.

Yes, you can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without requiring any signup.

Related vulnerabilities

Recent vulnerabilities recorded for typeorm.

How To Fix

Latest published version: 1.1.2 as of 22 Oct 2026

npm install typeorm@1.1.2

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 0.3.31 0.3.31
    npm install typeorm@0.3.31
  • >= 1.0.0, < 1.1.0 1.1.0
    npm install typeorm@1.1.0

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback