{"id":"CVE-2025-60542","aliases":["CVE-2025-60542","GHSA-q2pj-6v73-8rgj"],"related":[],"kind":"vulnerability","state":"published","title":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### 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)","format":"markdown","source":"ghsa"},{"lang":"es","text":"Vulnerabilidad de inyección SQL en TypeORM anterior a la 0.3.26 mediante una solicitud manipulada a repository.save o repository.update debido a la llamada a sqlstring con stringifyObjects por defecto en falso.","source":"nvd"}],"published":"2025-10-29T00:00:00.000Z","modified":"2026-10-27T12:10:00.343Z","severity":{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N","score":6.5,"rating":"MEDIUM"},"severities":[{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N","score":6.5,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N","score":6.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"HIGH"}],"cwes":["CWE-89"],"affected":[{"ranges":[{"version":"n/a","status":"affected"}],"source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.3.26"}],"ecosystem":"npm","package":"typeorm","purl":"pkg:npm/typeorm","source":"ghsa"}],"references":[{"url":"https://github.com/typeorm/typeorm/releases?q=security&expanded=true","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/typeorm/typeorm/pull/11574","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/typeorm/typeorm/releases/tag/0.3.26","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://medium.com/@alizada.cavad/cve-2025-60542-typeorm-mysql-sqli-0-3-25-a1b32bc60453","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-60542","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/typeorm/typeorm/commit/d57fe3bd8578b0b8f9847647fd046bccf825a7ef","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/mysqljs/sqlstring/blob/cd528556b4b6bcf300c3db515026935dedf7cfa1/lib/SqlString.js#L54","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/sidorares/node-mysql2/blob/e359f454a76ba5dc31b91adf7bdb4099ca317bb5/lib/base/connection.js#L524","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/sidorares/node-mysql2/blob/e359f454a76ba5dc31b91adf7bdb4099ca317bb5/lib/connection_config.js#L124","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/typeorm/typeorm/blob/0.3.25/src/driver/mysql/MysqlConnectionOptions.ts","tags":["web"],"sources":["ghsa"]},{"url":"http://github.com/typeorm/typeorm","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"mitre","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"total","date":"2025-10-30T20:28:03.239Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-60542","url":"https://www.cve.org/CVERecord?id=CVE-2025-60542","licence":"CVE Terms of Use","modified":"2025-10-30T20:28:41.544Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-q2pj-6v73-8rgj","url":"https://github.com/advisories/GHSA-q2pj-6v73-8rgj","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:30.128Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-60542","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-60542","licence":"Public domain","modified":"2026-10-27T12:10:00.343Z"}],"updatedAt":"2026-11-25T22:59:06.998Z","epss":{"score":0.00265,"percentile":0.19637,"date":"2026-12-01T12:00:22.000Z"}}