Summary
Open Source Point of Sale contains an SQL Injection vulnerability in the Items search functionality when the custom attribute search feature is enabled.
Because user-supplied search parameters are interpolated directly into a HAVING clause without parameterization, an authenticated user with item search access may execute arbitrary SQL against the backend database.
Affected context
The vulnerability appears in the web-based item search endpoint of Open Source Point of Sale when the search_custom filter is enabled.
In this configuration, user-controlled data from a search GET parameter is incorporated into a dynamically constructed SQL query, specifically into a HAVING clause for custom attributes.
The issue is most relevant in deployments where:
- Users have authenticated access and permission to search items
- The application connects to a shared or production database
- Database accounts have broader read/write privileges beyond a minimal item catalog
Exploit preconditions
- Attack surface: HTTP(S) item search endpoint in the web UI or API.
- Required access: Authenticated user with basic permission to perform item searches.
- Configuration requirement: Custom attribute search feature enabled (e.g.,
search_customfilter active). - Trigger point: Submission of crafted input via the
searchGET parameter that is interpolated into the SQLHAVINGclause. - Why exploitation is possible: The application builds SQL fragments by string-concatenating untrusted input directly into the query, without parameter binding or sufficient input validation, enabling manipulation of the query structure.
Why this happens
This issue stems from building SQL queries through string concatenation using untrusted input, then executing the resulting statement directly against the database.
Instead of binding user parameters via prepared statements or a query builder, the code interpolates the search GET parameter into a HAVING clause when custom attribute search is enabled.
This pattern maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where attacker-controlled characters can escape intended query boundaries and alter logic, join additional tables, or access unrelated data.
Potential impact
- Exposure of sensitive data from other tables that the database user can access (e.g., customers, transactions, user accounts).
- Unauthorized modification or deletion of records, including inventory items and sales data.
- Creation of new records or alteration of financial and inventory information, impacting integrity and reporting.
- Potential retrieval of password hashes or session-related data, which could support further compromise.
- In some database configurations, execution of database-specific commands that may impact availability or facilitate lateral movement.
General mitigation guidance
Mitigation generally focuses on eliminating direct string interpolation in SQL construction and narrowing the trust boundary around user inputs:
- Use parameterized queries or a framework-provided query builder for all dynamic conditions, including
HAVINGclauses and custom attribute filters. - Restrict which fields and operators can be influenced by user input; treat user data only as values, never as query structure.
- Apply strict server-side validation and canonicalization to search parameters, enforcing expected formats (e.g., length limits, allowed character sets, and known attribute names).
- Introduce a whitelist-based mapping from user-selectable attributes to predefined SQL fragments, instead of passing attribute names or expressions directly.
- Configure database accounts with least-privilege access so that even if a query is manipulated, accessible data and operations are limited.
How teams detect issues like this
High-level detection typically combines code-focused review with runtime monitoring:
- Use static analysis tools or linters to flag direct concatenation of request parameters into SQL strings, especially around search and filter features.
- During code review, look for dynamic
WHEREorHAVINGclause construction that incorporates raw GET/POST variables, focusing on search and reporting modules. - Enforce secure coding guidelines via pull-request templates or automated checks that require parameterized queries for all database access.
- Deploy web application firewalls (WAFs) or database activity monitoring solutions that can detect common SQL injection patterns in incoming traffic or query logs.

