GHSA-ch7p-mpv4-4vg4 CoreShop Vulnerable to SQL Injection via Admin Reports
Affected Version(s)CoreShop 4.1.2 Demo (tested) [Demo | CoreShop](https://docs.coreshop.com/CoreShop/Getting_Started/Demo/index.html)Earlier versions may also be affected if the same code path existsSummaryA blind SQL injection vulnerability exists in the application that allows an authenticated administrator-level user to extract database contents using boolean-based or time-based techniques.
The database account used by the application is read-only and non-DBA, limiting impact to confidential data disclosure only. No data modification or service disruption is possible.DetailsThe vulnerability occurs due to unsanitized user input being concatenated into a SQL query without proper parameterization.An attacker with administrative access can manipulate the affected parameter to influence the backend SQL query logic. Although no direct query output is returned, boolean and time-based inference techniques allow an attacker to extract data from the database.Impact**Vulnerability Type:** Blind SQL Injection**Impact:** Confidentiality onlyAn attacker can:Enumerate database schemaExtract all data accessible to the application’s database user**CVSS v3.1 (Base Score: 4.9 – Medium)**Steps to Reproduce:**Send a Normal Request:**Request the report endpoint with a valid `store` value (e.g. `store=1`) and observe that data is returned.**Inject a Boolean TRUE Condition:**Modify the parameter to `store=1 AND 1=1`.The response returns the same data as the normal request.**Inject a Boolean FALSE Condition:**Modify the parameter to `store=1 AND 2=1`.The response returns an empty dataset.**Confirm Injection Behavior:**The difference between TRUE and FALSE conditions confirms that the `store` parameter directly affects SQL query logic, indicating a boolean-based blind SQL injection.**Automated Confirmation Using sqlmap:**The vulnerable request was tested using `sqlmap` with the `store` parameter.sqlmap successfully confirmed the parameter as **boolean-based and time-based blind SQL injectable**.The tool was able to fingerprint the backend environment, including:Database Management System (DBMS)Database hostnamePHP versionAvailable database namesThis confirms that the injection is exploitable beyond simple logic manipulation and allows database-level information disclosure.SolutionTo mitigate the SQL injection risk, user input should not be directly concatenated into SQL queries. The `store` parameter is expected to represent a numeric store identifier and should therefore be handled safely.Two possible remediation approaches are recommended:**Strict Type Enforcement (Minimal Fix)**If the `store` parameter is intended to be numeric only, enforce integer casting when retrieving the value (e.g. `(int) $storeId`). This prevents injection by ensuring that only numeric values are used in the query.**Prepared Statements (Best Practice)**Alternatively, and preferably, the `store` parameter should be passed using parameter binding, consistent with the handling of other query values in this method. Using prepared statements fully prevents SQL injection and aligns with Doctrine DBAL best practices.Applying either approach would prevent attackers from injecting SQL logic through the `store` parameter.Parameter/admin/coreshop/report/get-data?report=products&_dc=1767720897882&from=1767200400&to=1798650000&**store=1**&objectType=all&orderState=%5B%5D&page=1&start=0&limit=50Line of CodeCoreShop/src/CoreShop/Bundle/CoreBundle/Report/SalesReport.php**Line 64 :**The `store` parameter is retrieved directly from the HTTP request via `ParameterBag`. This value originates from user-controlled input and is not validated or type-cast at this point.**Line 77 :**This check ensures the parameter is present, but does not enforce type safety or restrict the value to an expected format (e.g., integer).**Line 81 :**The user-supplied value is used to query the repository. While this lookup may fail for invalid values, it does not prevent the same value from later being used in a raw SQL context.**Line 107 :**At this point, the `$storeId` value is **directly concatenated into the SQL query string**. Unlike other parameters in the query (`orderDate`), this value is **not bound as a prepared statement parameter**.Example Fixed CodeOption 1: Strict Type Enforcement (Minimal Fix)If the `store` parameter is intended to be numeric only, enforce integer casting before using it in the query.This ensures that only numeric values are used and prevents SQL logic injection.Option 2: Prepared Statements (Recommended Fix)Use parameter binding for **all user-influenced values**, including `store`.This approach fully eliminates SQL injection risks and aligns with Doctrine DBAL best practices.
CVSS v3.1 score: 4.9