
CVE-2022-33171: TypeORM SQL Injection Vulnerability
CVE ID: CVE-2022-33171
Product: TypeORM
Affected Versions: < 0.3.0
Vulnerability Type: SQL Injection
Date Disclosed: June 28, 2022
The findOne(id) and findOneOrFail(id) functions in TypeORM before version 0.3.0 can be supplied with either a string or a FindOneOptions object. When the input to this function is a user-controlled parsed JSON object, supplying a crafted FindOneOptions instead of an id string leads to SQL injection.
The vulnerability exists because:
findOne() function accepts flexible input types (string or FindOneOptions object)The TypeORM maintainers stated that the root cause is insufficient input validation on the application side, not the library itself. However, this function is explicitly designed to accept user input, making the argument defensible that the library should handle this safely.
Upgrade to TypeORM 0.3.0 or later, which includes fixes for this vulnerability.