Intel

AIKIDO-2026-565238

@mikro-orm/knex is vulnerable to SQL Injection

SQL InjectionGHSA-7j79-7q93-6v69 Published 6 days ago

65

Medium Risk

This Affects:

JS@mikro-orm/knex
4.0.0 - 6.6.15
Fixed in 6.6.16
Are you affected? Scan for Free

TL;DR

MikroORM validates the field of an orderBy clause against entity metadata but applies no validation to the order direction, which is concatenated into the generated SQL ORDER BY clause after only a toLowerCase() call. An application that binds a request value to the order direction lets an attacker place a raw SQL fragment inside ORDER BY, enabling blind or boolean-based extraction of data the query never selects. The vulnerable code lives in the shared SQL layer, so all SQL drivers are affected while MongoDB is not. The fix allow-lists the direction against the known QueryOrder values in a shared helper on AbstractSqlPlatform, with the MySQL and MSSQL overrides routed through it.

Who does this affect?

You are affected if you are using a version that falls within the vulnerable range and your application binds an attacker-influenced value to the order direction of an orderBy clause.

Background info

@mikro-orm/knex is vulnerable to SQL Injection in versions 4.0.0 - 6.6.15.

How to fix this

Upgrade the @mikro-orm/knex library to the patch version.