High

TypeORM vulnerable to SQL injection via crafted request to repository.save or repository.update

  • Disclosed: 29.10.2025
  • Updated: 11.10.2026 10:22

Summary

SQL Injection vulnerability in TypeORM before 0.3.26 via crafted request to repository.save or repository.update due to the sqlstring call using stringifyObjects default to false.

Details

Vulnerable Code:

js
const { username, city, name} = req.body;
const updateData = {
    username,
    city,
    name,
    id:userId
  }; // Developer aims to only allow above three fields to be updated    
const result = await userRepo.save(updateData);

Intended Payload (non-malicious):

username=myusername&city=Riga&name=Javad

OR

{username:\"myusername\",phone:12345,name:\"Javad\"}

SQL query produced:

sql
UPDATE `user` 
SET `username` = 'myusername', 
    `city` = 'Riga', 
    `name` = 'Javad' 
WHERE `id` IN (1);

Malicious Payload:

username=myusername&city[name]=Riga&city[role]=admin

OR

{username:\"myusername\",city:{name:\"Javad\",role:\"admin\"}}

SQL query produced with Injected Column:

sql
UPDATE `user` 
SET `username` = 'myusername', 
    `city` = `name` = 'Javad', 
    `role` = 'admin' 
WHERE `id` IN (1);

Above query is valid as city = name = Javad is a boolean expression resulting in city = 1 (false). “role” column is injected and updated.

Underlying issue was due to TypeORM using mysql2 without specifying a value for the stringifyObjects option. In both mysql and mysql2 this option defaults to false. This option is then passed into SQLString library as false. This results in sqlstring parsing objects in a strange way using objectToValues.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
npm package typeorm < 0.3.26 0.3.26

References

CVSS score 6.5/10
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N
Weakness (CWE)
CWE-89
Platform
npm
Package
typeorm
Disclosed
29.10.2025
Updated
11.10.2026 10:22

Sources and licenses

OSV / GitHub Advisory Database - GHSA-q2pj-6v73-8rgj - CC BY 4.0

Vulnerability history: typeorm

All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.

Total entries
6
First → latest
06.2019 07.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • Critical 3
  • High 1
  • Medium 2

Disclosures per year

  1. 2019: 1
  2. 2020: 0
  3. 2021: 1
  4. 2022: 1
  5. 2023: 0
  6. 2024: 0
  7. 2025: 1
  8. 2026: 2
  1. Medium · 5.7 CVE-2026-73651 < 0.3.31, >= 1.0.0, < 1.1.0 0.3.31, 1.1.0
  2. Medium · 5.9 ghsa-9ggv-8w38-r7pm >= 0.1.12, < 0.3.29 0.3.29
  3. TypeORM vulnerable to SQL injection via crafted request to repository.save or repository.update this entry
    High · 6.5 CVE-2025-60542 < 0.3.26 0.3.26
  4. Critical · 9.8 CVE-2022-33171 < 0.3.0 0.3.0
  5. Critical · 9.8 CVE-2020-8158 < 0.2.25 0.2.25
  6. Critical · 9.8 ghsa-w7q7-vjp8-7jv4 < 0.1.15 0.1.15

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.