Summary
Several ERPNext HTTP endpoints were vulnerable to SQL injection, allowing attackers to manipulate database queries via specially crafted requests.
If an attacker can reach these endpoints, they may extract sensitive information from the ERPNext database and potentially interfere with its integrity and availability.
Affected context
This vulnerability occurs in ERPNext deployments where web-facing endpoints build SQL queries using untrusted request parameters.
It is most relevant in environments where ERPNext is exposed over the network (e.g., internet-facing or accessible from untrusted internal segments) and where the database user backing ERPNext has broad read access to business data.
The risk increases when security controls like web application firewalls, strict input validation, or least-privilege database accounts are not consistently enforced.
Exploit preconditions
- Attack surface: ERPNext HTTP endpoints reachable over the network (e.g., public or internal web access).
- Required access: Ability to send crafted HTTP requests to affected endpoints; no special privileges are assumed beyond network reachability.
- Trigger point: Handling of request parameters that are interpolated into SQL queries without proper parameterization or encoding.
- Why exploitation is possible: The application logic constructs or augments SQL statements using user-controlled input, allowing an attacker to alter the structure of the query instead of supplying only data values.
Why this happens
The underlying issue maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Affected ERPNext endpoints appear to compose SQL queries directly from HTTP request parameters, either through string concatenation or unsafe formatting, without consistently using bound parameters or robust query-building APIs.
As a result, database control characters and SQL syntax supplied by an attacker are interpreted as part of the executable query, breaking the intended separation between data and code at the database layer.
Potential impact
- Extraction of sensitive business records such as customer data, financial entries, or internal configuration.
- Enumeration of database schema, including table names and column metadata.
- Circumvention of application-level access controls by querying data the user should not see.
- Manipulation or deletion of records if the vulnerable queries support write operations.
- Use of the ERPNext database as a pivot point for further infrastructure compromise, depending on database privileges and configuration.
General mitigation guidance
Effective mitigation focuses on ensuring that untrusted input can never change the structure of SQL statements:
- Prefer parameterized queries or ORM query builders that separate SQL code from data values by design.
- Centralize database access patterns in well-reviewed data access layers instead of constructing ad-hoc SQL in controllers or views.
- Apply strict validation and canonicalization to incoming request parameters, rejecting unexpected formats and constraining values to whitelists where practical.
- Enforce least-privilege for the ERPNext database account so that it has only the minimal read/write rights needed by the application.
- Combine application-layer defenses with infrastructure controls such as web application firewalls tuned to detect and block common SQL injection patterns.
How teams detect issues like this
Organizations can use a combination of code-centric and runtime detection techniques:
- Static analysis: Configure SAST tools to look for direct string concatenation in SQL calls, raw query execution APIs, or dynamic construction of WHERE/ORDER clauses from request data.
- Code review: Flag any controller or API handler that builds SQL from HTTP parameters; check for consistent use of bound parameters and ORM abstractions.
- Dynamic testing: Use DAST or security testing tools to fuzz ERPNext endpoints with SQL injection payloads and monitor for errors, anomalies, or unexpected responses.
- Database monitoring: Enable query logging and anomaly detection at the database level to spot unusual query patterns or sudden spikes in metadata queries consistent with injection attempts.

