SQL Injection Vulnerability in SQLAlchemy: CVE-2019-7164

sqlalchemy Updated 02 Oct 2025

Summary

20/02/2019
N/A
Yes i
Critical
9.8

CVE-2019-7164: SQLAlchemy through 1.2.17 and 1.3.x through 1.3.0b2 allows SQL Injection via the order_by parameter. Affects sqlalchemy across 2 version ranges.

< 1.2.18+ds1-2 < 47c245b90cd3cfe76bc0cf078f740d12bf7ba2d1

Fixed in 1.2.18+ds1-2. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

SQLAlchemy is a popular SQL toolkit and Object-Relational Mapping (ORM) system for Python. It provides a full suite of well-known enterprise-level persistence patterns, designed for efficient and high-performing database access. The library is widely used in web applications and data-driven projects. However, versions up to 1.2.17 and 1.3.x through 1.3.0b2 are vulnerable to SQL injection attacks via the 'order_by' parameter, which can lead to unauthorized data access and manipulation.

Vulnerability Detail

CVE-2019-7164 is a critical SQL injection vulnerability found in SQLAlchemy, allowing attackers to manipulate SQL queries through the 'order_by' parameter. This vulnerability arises from improper validation of user input, which can lead to unauthorized access to sensitive data, data corruption, or even complete system compromise. The CVSS score for this vulnerability is 9.8, indicating a high severity level that necessitates immediate attention.

How To Fix

Minimum fixed version

1.2.18+ds1-2

This is the first release that contains the fix.

sudo apt-get install --only-upgrade sqlalchemy

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If an immediate upgrade is not feasible, consider sanitizing the input for the 'order_by' parameter to prevent SQL injection. This can be achieved by implementing strict validation rules in your application code to ensure that only expected values are processed. For example, you can use a whitelist approach to allow only certain fields for ordering.

Conclusion

CVE-2019-7164 is a significant SQL injection vulnerability in SQLAlchemy that poses serious risks to applications using affected versions. Immediate action is required to upgrade to a secure version or implement workarounds to protect against potential attacks. Regular monitoring and vulnerability assessments are essential for maintaining application security.

See every vulnerability recorded for sqlalchemy →

Share this vulnerability

FAQ

CVE-2019-7164 is a SQL injection vulnerability in SQLAlchemy that allows attackers to manipulate SQL queries through the 'order_by' parameter.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

The vulnerability can lead to unauthorized data access, data corruption, and potentially complete system compromise.

It is recommended to upgrade to SQLAlchemy version 1.2.18 or later to mitigate this vulnerability.

Yes, you can implement input validation and sanitization for the 'order_by' parameter as a temporary workaround.

Related vulnerabilities

Recent vulnerabilities recorded for sqlalchemy.

How To Fix

Minimum fixed version

1.2.18+ds1-2

This is the first release that contains the fix.

sudo apt-get install --only-upgrade sqlalchemy

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback