/

CVE-2026-31877

Severity:

CRITICAL RISK

(9.8)

SQL Injection in Frappe Web Application Framework Endpoint

CVE-2026-31877

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Confidentiality and Integrity Compromise via Arbitrary SQL Query Manipulation

Severity:

CRITICAL RISK

(9.8)

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

A vulnerable endpoint in the Frappe web application framework processes specially crafted requests in a way that allows SQL injection.

Under these conditions, an attacker can manipulate database queries to extract sensitive information they would not normally be authorized to access.

Affected context

This vulnerability occurs in Frappe-based applications where a specific HTTP endpoint constructs SQL queries using request data without robust query parameterization or sanitization.

It is relevant in deployments where the framework has direct access to the backing database and the vulnerable route is reachable over the network.

The issue becomes especially risky when the affected endpoint is exposed to untrusted users or the public internet, and when the underlying database holds sensitive or high-value data.

Exploit preconditions

  • Attack surface: Network-exposed HTTP(S) endpoint within a Frappe application.
  • Required access: Ability to send crafted requests to the vulnerable route (typically unauthenticated or with low-privilege access, depending on configuration).
  • Trigger point: Server-side processing of request parameters that are concatenated into SQL statements or otherwise incorporated into queries without proper binding.
  • Why exploitation is possible: User-controlled input is merged into SQL commands in an unsafe manner, allowing attackers to alter the intended query structure rather than being treated as data only.

Why this happens

The root cause aligns with CWE-89: SQL Injection, where application code builds SQL statements by directly embedding user-controlled values into query strings.

Instead of using parameterized queries or an ORM abstraction that enforces proper binding, the vulnerable endpoint accepts request input and incorporates it into SQL logic, enabling attackers to inject additional clauses or entire statements.

This pattern breaks the separation between code and data at the database layer, allowing manipulation of the database query execution path.

Potential impact

  • Unauthorized reading of sensitive records, including user data and application configuration.
  • Circumvention of application-level authorization and access controls via direct query manipulation.
  • Exposure of credential-like information stored in the database (e.g., API keys, password hashes) depending on schema design.
  • Modification or deletion of database records, potentially leading to data corruption or loss if write operations are reachable.
  • Enumeration of database structure, such as table names and column metadata, aiding further attacks.

General mitigation guidance

Effective mitigation focuses on consistently treating all external input as untrusted and ensuring it never directly controls SQL structure.

Common defensive patterns include:

  • Using parameterized queries or prepared statements provided by the database driver or ORM, ensuring values are bound as data, not concatenated into SQL strings.
  • Relying on framework-level ORM query builders that abstract raw SQL and enforce safe query construction.
  • Applying strict input validation and normalization for fields that influence filtering, sorting, or other query parameters, allowing only expected formats and whitelisted values.
  • Avoiding dynamic SQL where possible; if dynamic behavior is required (e.g., column or sort selection), use whitelists and server-side mappings rather than passing user input directly.
  • Following the principle of least privilege at the database level so that the application account has only the minimum required permissions, reducing the blast radius of any injection.

How teams detect issues like this

Detection typically involves a combination of code-centric and behavior-centric approaches:

  • Static analysis: Configure SAST rules to flag string concatenation or interpolation involving SQL statements and user-controlled input within Frappe applications.
  • Code review signals: During manual reviews, scrutinize endpoints that construct queries, search for raw SQL usage, dynamic WHERE/ORDER BY clauses, and any bypass of ORM protections.
  • Runtime monitoring: Use database activity monitoring to identify anomalous query patterns, such as unexpected UNIONs, tautological conditions, or schema enumeration queries, originating from web traffic.
  • Security testing: Incorporate automated and manual SQL injection testing in CI/CD pipelines and pre-release security assessments, focusing on request parameters and query-building logic.
  • Policy enforcement: Establish development guidelines that require ORM usage or prepared statements and disallow ad-hoc string-based SQL construction without explicit security justification.

Sources

SourceLink
github.comgithub.com/frappe/frappe/security/advisories/GHSA-2c4m-999q-xhx4

Frequently asked

questions

Yes, if the vulnerable endpoint is exposed over the network and accessible to an attacker, they can send crafted requests remotely to exploit the SQL injection.

The required access depends on how the endpoint is configured; in many cases, the attack surface may be available to unauthenticated or low-privileged users who can reach the affected route and control the relevant request parameters.

The safest approach is to replace all string-built SQL in the affected path with parameterized queries or ORM abstractions, ensuring user input is always bound as data, and to constrain any dynamic aspects of queries through strict whitelisting and server-side mappings.

Adopt a development standard that forbids embedding user input directly in SQL, leverage framework features for safe query construction, enforce secure coding guidelines through code review and static analysis, and routinely test endpoints for injection vulnerabilities as part of continuous security testing.

Find out what's already
exploitable in your codebase.