CVE-2021-47763

Order By: Pwn - Unauthenticated SQL Injection in Aimeos

Amit Schendel
Amit Schendel
Senior Security Researcher

Jan 16, 2026·5 min read

Executive Summary (TL;DR)

The Aimeos JSON API failed to validate the 'sort' parameter, passing it directly into a database query's 'ORDER BY' clause. This allows unauthenticated attackers to inject SQL fragments, triggering database errors that reveal schema information. While discovered in 2021, this high-severity flaw (CVSS 8.2) highlights the persistent danger of dynamic query construction.

An unauthenticated SQL injection vulnerability in the Aimeos Laravel e-commerce platform allows attackers to execute arbitrary SQL commands via the 'sort' parameter in the JSON API.

The Hook: Trust Issues

We often talk about modern frameworks like Laravel as if they are bulletproof vests. "Don't worry," we say, "the ORM handles the SQL. Prepared statements save the day." And for 90% of cases, that's true. But frameworks are only as secure as the developers implementing them, and there is one specific SQL clause that absolutely hates prepared statements: ORDER BY.

CVE-2021-47763 is a classic reminder that even in a robust ecosystem like Laravel, old-school vulnerabilities lurk in the shadows. This isn't a complex memory corruption bug or a race condition in a kernel driver. It is a good old-fashioned SQL injection in Aimeos, a popular e-commerce package, allowing any random person on the internet to ask your database questions it really shouldn't answer.

The target? The jsonapi/review endpoint. The weapon? A simple sort parameter intended to organize product reviews.

The Flaw: The 'Order By' Problem

To understand this bug, you need to understand why ORDER BY is the bane of secure coding. Standard SQL prepared statements (parameter binding) treat input as data, not identifiers. You can bind a value like WHERE id = ? (binding 1), but you cannot bind a column name like ORDER BY ? (binding created_at). If you try, the database interprets it as a string literal, sorting effectively by a constant value—which does nothing.

Because of this limitation, developers are forced to perform dynamic string insertion. They take the user's input ("sort by price") and append the string price to the SQL query. This is safe only if you strictly validate that the input is actually a valid column name.

Aimeos missed that step. In the vulnerable version (2021.10 LTS), the application took the sort parameter from the URL and handed it off to the underlying query builder. The code assumed the input was benign. It wasn't.

The Code: Architectural Autopsy

While the exact source code commit history for this older vulnerability is fragmented, the pattern is unmistakable to anyone who has audited PHP applications. The vulnerable logic typically looks like this:

// VULNERABLE PATTERN
$sort = $request->input('sort');
 
// The framework trusts the input and appends it to the query
$items = $manager->search( $criteria->sort( $sort ) );

When the input is passed down to the database layer, it constructs a query resembling:

SELECT * FROM mshop_review ORDER BY [USER_INPUT] ASC LIMIT 25

The fix is mundane but critical: Allow-listing. You must map external sort keys to internal database columns and reject anything else.

// SECURE PATTERN
$allowedSorts = ['ctime', 'rating', 'label'];
$sortInput = $request->input('sort');
 
if (!in_array($sortInput, $allowedSorts)) {
    throw new \Exception('Invalid sort parameter');
}
// Proceed with trusted value

Without this check, the database engine tries to parse whatever garbage the user sends as a column identifier.

The Exploit: Asking the Database to Reveal Itself

Exploiting this is trivially easy. We don't need authentication. We don't need a user account. We just need curl.

The proof-of-concept released on Exploit-DB demonstrates how fragile the parsing logic is:

curl -v "http://target.com/default/jsonapi/review?sort=--"

By sending -- (the SQL comment indicator), or other special characters, we disrupt the query structure. Since the application is running in a context where it expects a column name, the database throws a fit. If the server is configured with APP_DEBUG=true (which, terrifyingly, many are), the response will look something like this:

SQLSTATE[42S22]: Column not found: 1054 Unknown column '--' in 'order clause'

"So what?" you might ask. "It's just an error."

Not quite. An attacker can refine this. By injecting subqueries or using time-based blind injection vectors (e.g., sort=(CASE WHEN (SELECT 1)=1 THEN id ELSE date END)), they can confirm the existence of tables, guess column names, and eventually extract user hashes or customer PII. The error message confirms we are touching the database directly.

The Impact: Metadata Leakage

The primary impact here is Confidentiality. In a worst-case scenario (Error-Based SQLi), an attacker can map out the entire database schema. Knowing the exact table names (users, orders, transactions) and column names is 80% of the battle in a complex attack chain.

Once the schema is known, the attacker can craft highly specific payloads to extract administrative session tokens or modify the query logic to bypass other checks. While ORDER BY injections are generally harder to weaponize for direct data exfiltration (like UNION SELECT) compared to WHERE clause injections, they are perfectly sufficient for reconnaissance and, in some database dialects, full compromise via boolean inference.

This is a "High" severity issue because it is remotely exploitable without any credentials. It's an open door.

The Fix: Whitelisting is King

If you are running Aimeos 2021.10 LTS, you are statistically likely to be vulnerable unless you have applied subsequent patches. The remediation strategy is straightforward:

  1. Update: Move to a newer version of the aimeos-laravel package immediately.
  2. Hardening: Ensure your Laravel environment variable APP_DEBUG is set to false. Never show SQL errors to the end-user. It turns a difficult Blind SQLi into a trivial Error-Based SQLi.
  3. WAF Rules: Configure your Web Application Firewall to flag SQL keywords or comment characters (--, #, /*) in query parameters, specifically looking at the sort key.

Official Patches

Technical Appendix

CVSS Score
8.2/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N
EPSS Probability
0.03%
Top 91% most exploited

Affected Systems

Aimeos Laravel E-commerce Platform (2021.10 LTS)

Affected Versions Detail

Product
Affected Versions
Fixed Version
Aimeos Laravel
Aimeos
= 2021.10 LTSLatest 2021.x / 2022.x
AttributeDetail
CWE IDCWE-89 (SQL Injection)
Attack VectorNetwork (Unauthenticated)
CVSS v3.18.2 (High)
ImpactConfidentiality (High), Integrity (Low)
Exploit StatusPoC Available
Vulnerable ComponentJSON API / sort parameter
CWE-89
SQL Injection

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

Vulnerability Timeline

Vulnerability Discovered
2021-11-20
PoC Published on Exploit-DB
2021-11-22
CVE ID Published
2026-01-15

Subscribe to updates

Get the latest CVE analysis reports delivered to your inbox.