/

CVE-2026-65822

Severity:

HIGH RISK

(7.6)

SQL Injection (CWE-89) in ERPNext Inactive Customers Report

CVE-2026-65822

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Sensitive Information Disclosure and Database Query Manipulation

Severity:

HIGH RISK

(7.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

ERPNext contains a SQL injection vulnerability in the Inactive Customers report because an authenticated user's doctype filter is not validated before being inserted into raw SQL queries.

An attacker with valid ERPNext access may exploit this behavior to alter database queries and extract sensitive information.

Affected context

The issue occurs in ERPNext's Inactive Customers report, specifically where the doctype filter is processed by sales-detail and last-sales-amount queries. Deployments may be at risk when authenticated users can submit or influence this filter and the application constructs SQL statements through direct string interpolation rather than parameterized query handling.

Exploit preconditions

  • Attack surface: The ERPNext Inactive Customers report
  • Required access: An authenticated ERPNext account with permission to reach the affected reporting functionality
  • Trigger point: Processing of the doctype filter in the sales-detail and last-sales-amount database queries
  • Why exploitation is possible: The filter is accepted without adequate validation and is interpolated into raw SQL, allowing user-controlled input to influence query structure

Why this happens

The underlying bug is an unsafely constructed database query that combines user-controlled input with SQL text. Because the doctype filter is not constrained through strict allowlisting or safely bound as a query parameter, an attacker may affect the meaning of the resulting statement. This behavior maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

Potential impact

  • An attacker may retrieve sensitive business or customer information
  • Database queries could be altered or broadened beyond their intended scope
  • Confidentiality and integrity of ERP data could be affected
  • Application availability may be impacted by resource-intensive or malformed queries
  • Compromised data could support further attacks against business workflows

General mitigation guidance

Mitigation generally focuses on removing user influence over SQL syntax and reducing trust in report filters.

Common defensive patterns include:

  • Use parameterized queries or framework query builders for all dynamic values
  • Apply strict allowlists for fields, doctypes, and other query-shaping inputs
  • Separate identifiers from values and avoid direct string interpolation
  • Validate inputs against expected types, formats, and permitted application context
  • Enforce least-privilege database permissions for the application account
  • Restrict report access according to business need and role permissions
  • Prefer secure-by-default reporting APIs that do not expose raw query construction

How teams detect issues like this

Organizations can look for this weakness through:

  • Static analysis rules identifying string interpolation or concatenation in SQL statements
  • Code review checks for report filters passed directly into query-building logic
  • Tests that verify invalid doctypes and unexpected filter values are rejected
  • Runtime monitoring for anomalous report queries, broad data access, and unusual database errors
  • Policy enforcement requiring parameterized queries or approved database abstraction layers
  • Automated security review tools that flag CWE-89 patterns during development

Sources

SourceLink
github.comgithub.com/frappe/erpnext/commit/29dd6e6681d20bbacb69517d2d2c875aa929eb9e
github.comgithub.com/frappe/erpnext/commit/f43af6624610e874e61ad3faf8701e5e6be6271a
github.comgithub.com/frappe/erpnext/pull/55721
github.comgithub.com/frappe/erpnext/releases/tag/v15.116.0
github.comgithub.com/frappe/erpnext/releases/tag/v16.23.0
github.comgithub.com/frappe/erpnext/security/advisories/GHSA-x35x-4mvx-h959

Frequently asked

questions

It may be exploitable through the ERPNext web application when the affected report is accessible to an authenticated user; direct network access to the database is not necessarily required.

The attacker generally needs a valid account with sufficient permission to access or invoke the Inactive Customers report and submit its filter values.

Use parameterized queries or a trusted query builder, and constrain query-shaping identifiers such as doctypes through strict allowlists.

Combine secure database APIs with code review rules, automated scanning, negative input tests, least-privilege database permissions, and narrowly scoped report authorization.

Find out what's already
exploitable in your codebase.