SQL Injection Vulnerability in SQLAlchemy - CVE-2012-0805
Summary
CVE-2012-0805: Multiple SQL injection vulnerabilities in SQLAlchemy before 0.7.0b4, as used in Keystone, allow remote attackers to execute arbitrary SQL commands via the (1) limit or (2) offset keyword to the select function, or unspec... Affects sqlalchemy versions < 0.6.7-1. Fixed in 0.6.7-1. How to fix ↓
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.
No signup required · Results in about 60 seconds
Background
SQLAlchemy is a powerful and flexible 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 vulnerability in question affects versions of SQLAlchemy prior to 0.7.0b4, which are utilized in various applications, including Keystone. This vulnerability allows attackers to manipulate SQL queries, potentially leading to unauthorized data access or modification.
Vulnerability Detail
CVE-2012-0805 describes multiple SQL injection vulnerabilities in SQLAlchemy versions before 0.7.0b4. Attackers can exploit these vulnerabilities by injecting arbitrary SQL commands through the 'limit' or 'offset' keywords in the select function, or through unspecified vectors in the select.limit or select.offset functions. This can lead to severe consequences, including data leakage, data corruption, or complete system compromise, depending on the privileges of the database user.
How To Fix
Minimum fixed version
0.6.7-1
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 implementing input validation and sanitization to mitigate the risk of SQL injection. Ensure that all user inputs are properly escaped and validated before being included in SQL queries. Additionally, using parameterized queries can help prevent SQL injection attacks.
Conclusion
CVE-2012-0805 is a significant vulnerability affecting SQLAlchemy versions prior to 0.7.0b4, allowing for SQL injection attacks. It is essential to upgrade to a secure version to protect your applications from potential exploitation. Regular monitoring and vulnerability assessment using tools like Vulert can help maintain the security of your software.
See every vulnerability recorded for sqlalchemy →
FAQ
SQL injection is a code injection technique that exploits a vulnerability in an application's software by manipulating SQL queries. It allows attackers to execute arbitrary SQL code on a database.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability. It requires no signup and uses a manifest file like package-lock.json to monitor vulnerabilities.
The potential impacts include unauthorized access to sensitive data, data corruption, and the ability for attackers to execute administrative operations on the database.
Using older versions of SQLAlchemy that are vulnerable to CVE-2012-0805 is not safe. It is crucial to upgrade to a patched version to protect your application from SQL injection attacks.
If an immediate upgrade is not possible, implement input validation and sanitization, and consider using parameterized queries to reduce the risk of SQL injection.
Related vulnerabilities
Recent vulnerabilities recorded for sqlalchemy.