Skip to content

Commit f154174

Browse files
1 parent a70c5d1 commit f154174

File tree

2 files changed

+97
-41
lines changed

2 files changed

+97
-41
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-q2pj-6v73-8rgj",
4+
"modified": "2025-10-31T17:38:00Z",
5+
"published": "2025-10-29T18:30:33Z",
6+
"aliases": [
7+
"CVE-2025-60542"
8+
],
9+
"summary": "TypeORM vulnerable to SQL injection via crafted request to repository.save or repository.update",
10+
"details": "### Summary\n\nSQL 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.\n\n### Details\n\nVulnerable Code:\n\n```js\nconst { username, city, name} = req.body;\nconst updateData = {\n username,\n city,\n name,\n id:userId\n }; // Developer aims to only allow above three fields to be updated \nconst result = await userRepo.save(updateData);\n```\n\nIntended Payload (non-malicious):\n\n\n`\nusername=myusername&city=Riga&name=Javad\n`\n\n_OR_\n\n`{username:\\\"myusername\\\",phone:12345,name:\\\"Javad\\\"}\n`\n\nSQL query produced:\n\n```sql\nUPDATE `user` \nSET `username` = 'myusername', \n `city` = 'Riga', \n `name` = 'Javad' \nWHERE `id` IN (1);\n\n```\n\nMalicious Payload:\n\n`username=myusername&city[name]=Riga&city[role]=admin\n`\n\n_OR_\n\n`{username:\\\"myusername\\\",city:{name:\\\"Javad\\\",role:\\\"admin\\\"}}\n`\n\nSQL query produced with Injected Column:\n\n```sql\nUPDATE `user` \nSET `username` = 'myusername', \n `city` = `name` = 'Javad', \n `role` = 'admin' \nWHERE `id` IN (1);\n\n```\n_Above query is valid as `city` = `name` = `Javad` is a boolean expression resulting in `city` = 1 (false). “role” column is injected and updated._\n\nUnderlying issue was due to TypeORM using mysql2 [without specifying a value for the stringifyObjects option](https://github.com/typeorm/typeorm/blob/0.3.25/src/driver/mysql/MysqlConnectionOptions.ts). In both mysql and mysql2 this [option defaults to false](https://github.com/sidorares/node-mysql2/blob/e359f454a76ba5dc31b91adf7bdb4099ca317bb5/lib/connection_config.js#L124). This option is then passed into [SQLString library as false](https://github.com/sidorares/node-mysql2/blob/e359f454a76ba5dc31b91adf7bdb4099ca317bb5/lib/base/connection.js#L524). This results in sqlstring [parsing objects in a strange way using objectToValues.](https://github.com/mysqljs/sqlstring/blob/cd528556b4b6bcf300c3db515026935dedf7cfa1/lib/SqlString.js#L54)",
11+
"severity": [
12+
{
13+
"type": "CVSS_V3",
14+
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N"
15+
},
16+
{
17+
"type": "CVSS_V4",
18+
"score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:L/SC:L/SI:H/SA:L/E:P"
19+
}
20+
],
21+
"affected": [
22+
{
23+
"package": {
24+
"ecosystem": "npm",
25+
"name": "typeorm"
26+
},
27+
"ranges": [
28+
{
29+
"type": "ECOSYSTEM",
30+
"events": [
31+
{
32+
"introduced": "0"
33+
},
34+
{
35+
"fixed": "0.3.26"
36+
}
37+
]
38+
}
39+
]
40+
}
41+
],
42+
"references": [
43+
{
44+
"type": "ADVISORY",
45+
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-60542"
46+
},
47+
{
48+
"type": "WEB",
49+
"url": "https://github.com/typeorm/typeorm/pull/11574"
50+
},
51+
{
52+
"type": "WEB",
53+
"url": "https://github.com/typeorm/typeorm/commit/d57fe3bd8578b0b8f9847647fd046bccf825a7ef"
54+
},
55+
{
56+
"type": "WEB",
57+
"url": "https://github.com/mysqljs/sqlstring/blob/cd528556b4b6bcf300c3db515026935dedf7cfa1/lib/SqlString.js#L54"
58+
},
59+
{
60+
"type": "WEB",
61+
"url": "https://github.com/sidorares/node-mysql2/blob/e359f454a76ba5dc31b91adf7bdb4099ca317bb5/lib/base/connection.js#L524"
62+
},
63+
{
64+
"type": "WEB",
65+
"url": "https://github.com/sidorares/node-mysql2/blob/e359f454a76ba5dc31b91adf7bdb4099ca317bb5/lib/connection_config.js#L124"
66+
},
67+
{
68+
"type": "WEB",
69+
"url": "https://github.com/typeorm/typeorm/blob/0.3.25/src/driver/mysql/MysqlConnectionOptions.ts"
70+
},
71+
{
72+
"type": "WEB",
73+
"url": "https://github.com/typeorm/typeorm/releases/tag/0.3.26"
74+
},
75+
{
76+
"type": "WEB",
77+
"url": "https://github.com/typeorm/typeorm/releases?q=security&expanded=true"
78+
},
79+
{
80+
"type": "WEB",
81+
"url": "https://medium.com/@alizada.cavad/cve-2025-60542-typeorm-mysql-sqli-0-3-25-a1b32bc60453"
82+
},
83+
{
84+
"type": "PACKAGE",
85+
"url": "http://github.com/typeorm/typeorm"
86+
}
87+
],
88+
"database_specific": {
89+
"cwe_ids": [
90+
"CWE-89"
91+
],
92+
"severity": "HIGH",
93+
"github_reviewed": true,
94+
"github_reviewed_at": "2025-10-31T17:38:00Z",
95+
"nvd_published_at": "2025-10-29T16:15:34Z"
96+
}
97+
}

advisories/unreviewed/2025/10/GHSA-q2pj-6v73-8rgj/GHSA-q2pj-6v73-8rgj.json

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)