CVE-2012-0805
NoneCVSS
—
EPSS
2.9%
Published
Jun 5, 2012
CISA due date
—
Cloudanix analysis
A flaw in a common software component could allow an attacker to steal or destroy information from an application's database.
- Exploitation
- Remote Unauthenticated
- Attacker needs
- None
- Complexity
- Low
- Impact
- Data Tampering
- Component
- Library
- Class
- SQL Injection
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Medium
What it actually does
The vulnerability allows for SQL injection because user-supplied input for 'limit' and 'offset' parameters is not properly sanitized before being used in raw SQL queries. This enables an attacker to execute arbitrary SQL commands within the security context of the application's database user, potentially leading to unauthorized data access, modification, or deletion, and in some database configurations, remote code execution on the database server.
Why it matters to the business
An attacker can exploit this vulnerability to cause a severe data breach, stealing sensitive company, customer, or user data. They could also alter or delete critical information, leading to data integrity loss and operational disruption. Such an incident can result in significant financial losses, reputational damage, regulatory penalties, and a loss of customer trust.
How an attack unfolds
A remote, unauthenticated attacker identifies an application endpoint that uses a vulnerable version of the SQLAlchemy library for database queries with pagination. The attacker crafts a malicious request containing SQL commands embedded within the values for 'limit' or 'offset' parameters. The application passes this malicious input directly to the SQLAlchemy 'select' function, which then incorporates it into the final SQL query. The database executes this modified query, allowing the attacker to bypass application logic and interact directly with the database to exfiltrate or manipulate data.
How to fix it
The definitive solution is to upgrade the SQLAlchemy library to version 0.7.0b4 or, preferably, the latest stable version compatible with your application. Given the age of this vulnerability, any version prior to 0.7.0b4 is critically outdated. If an immediate upgrade is not feasible, implement strict server-side input validation to ensure that all values passed to 'limit' and 'offset' parameters are integers. A Web Application Firewall (WAF) with rules against SQL injection can also provide a temporary, compensating control.
How to confirm the fix worked
To confirm remediation, use a software composition analysis (SCA) tool or manually inspect package manifests (e.g., requirements.txt, Pipfile.lock) to verify that all instances of SQLAlchemy are at version 0.7.0b4 or higher. To validate the absence of the vulnerability, security testing teams can use automated scanners or manual penetration testing techniques to inject SQL payloads into pagination parameters and confirm that the application correctly rejects the malicious input and does not produce a database error or unexpected behavior.
Typical attack path
- The attacker identifies a target application using a vulnerable version of SQLAlchemy.
- The attacker locates an API endpoint or web page feature (like a search results page) that uses pagination controlled by user-supplied 'limit' and 'offset' parameters.
- The attacker submits a crafted payload in these parameters, such as '10; SELECT password FROM users'.
- The vulnerable library fails to sanitize the input and constructs a malicious SQL query.
- The database executes the query, and the attacker is able to extract sensitive information or perform other unauthorized actions.
How to detect it
Monitor web server (e.g., Nginx, Apache) and application logs for HTTP requests where pagination parameters such as 'limit' or 'offset' contain non-numeric data, SQL keywords (e.g., SELECT, UNION, AND), or database-specific functions. On the database side, monitor for malformed queries originating from the application server, queries with unusual syntax, or queries with abnormally long execution times, which could indicate a time-based blind SQL injection attempt.
- /?limit=10%20AND%20SLEEP(5)
- /?offset=0%20UNION%20SELECT%201,2,3
- /?limit=10;%20SELECT%20@@version
- /?offset=0'%20AND%20'1'='1
What your security team should do
- Prioritize upgrading SQLAlchemy to the latest stable version in all applications, starting with those that are internet-facing.
- Use software composition analysis (SCA) tools to create an inventory of all open-source dependencies and identify any other outdated or vulnerable components.
- Configure Web Application Firewall (WAF) rules to detect and block SQL injection patterns, especially in URL parameters related to pagination like 'limit' and 'offset'.
The record
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 unspecified vectors to the (3) select.limit or (4) select.offset function.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| PyPI | sqlalchemy | 0 | 0.7.0b4 |
| PyPI | sqlalchemy | 0 | 0.7.0 |
| Debian:11 | sqlalchemy | 0 | 0.6.7-1 |
| Debian:12 | sqlalchemy | 0 | 0.6.7-1 |
| Debian:13 | sqlalchemy | 0 | 0.6.7-1 |
| Debian:6.0 | sqlalchemy | 0 | 0.6.3-3+squeeze1 |
| Red Hat:enterprise_linux:6::server | python-sqlalchemy | 0 | 0:0.5.5-3.el6_2 |
| Red Hat:enterprise_linux:6::workstation | python-sqlalchemy | 0 | 0:0.5.5-3.el6_2 |
Related vulnerabilities
- CVE-2026-87936 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')… CWE-89
- CVE-2026-87938 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')… CWE-89
- CVE-2026-114664 Frappe Framework before 16.33.0 contains a blind SQL injection vulnerability in the… CWE-89
- CVE-2026-114577 A vulnerability was found in oretnom23 php-travel-agency-system. CWE-89
- CVE-2026-113406 BA-Workflow developed by YS-infoware has a SQL Injection vulnerability. CWE-89
- CVE-2026-113405 BA-Workflow developed by YS-infoware has a SQL Injection vulnerability. CWE-89
- CVE-2026-107081 SQL injection via identifier injection in the tableName and tableFields POST parameters… CWE-89
- CVE-2026-112150 A security flaw has been discovered in vraj404 Criminal-Management-System up to… CWE-89