/

CVE-2026-42425

Severity:

HIGH RISK

(7.2)

SQL Injection / Unrestricted SQL Execution in OpenKM

CVE-2026-42425

Deferred

Vulnerability type

Category:

SQL Injection / Unrestricted SQL Execution

CWE:

CWE-89

Impact:

Arbitrary SQL Execution and Data Compromise by Admin Users

Severity:

HIGH RISK

(7.2)

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

OpenKM 6.3.12 exposes an unrestricted SQL execution capability in its administrative DatabaseQuery interface, allowing arbitrary SQL statements to be run against the application database.

Authenticated administrative users can abuse the qs parameter on the /admin/DatabaseQuery endpoint to exfiltrate sensitive data such as usernames and password hashes, or to modify or delete records.

Affected context

This vulnerability exists in OpenKM deployments that expose the /admin/DatabaseQuery endpoint to authenticated administrative users.

The interface accepts raw SQL input via the qs parameter and forwards it directly to the backing database without enforcing query whitelisting, structural constraints, or fine-grained authorization.

It is most relevant in environments where administrative accounts are shared, weakly protected, accessible over untrusted networks, or where an administrative compromise could propagate across multiple tenants or connected systems.

Exploit preconditions

  • Attack surface: HTTP(S) request to the /admin/DatabaseQuery endpoint of an OpenKM instance.
  • Required access: Valid authenticated administrative account, or an account with equivalent permissions to access the DatabaseQuery interface.
  • Trigger point: Submission of a crafted SQL statement via the qs parameter in a request to /admin/DatabaseQuery.
  • Why exploitation is possible: The endpoint passes the contents of qs directly to the database without adequate validation, parameterization, or restriction of the allowed SQL operations, enabling arbitrary SQL execution under the application's database role.

Why this happens

The core issue is an administrative feature that allows direct execution of unbounded SQL statements against the production database.

Instead of constraining administrative database operations to a limited set of parameterized, vetted queries, the DatabaseQuery interface accepts and executes raw SQL provided by the caller.

This aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), but in a specialized form where the application itself intentionally exposes a raw SQL channel without controls, effectively turning administrative input into executable SQL logic.

The absence of query whitelisting, least-privilege database roles for this feature, and strong separation between operational data access and diagnostic tooling makes arbitrary database actions possible.

Potential impact

  • Administrative users may execute arbitrary SELECT queries to retrieve sensitive information, including usernames and password hashes from tables like OKM_USER.
  • Attackers could modify, insert, or delete business data, potentially corrupting repositories, access control lists, or workflow states.
  • Database-level integrity and auditability can be undermined, impacting compliance and incident response.
  • Permission structures or roles may be altered, escalating privileges for other accounts or disabling security controls.
  • In some configurations, crafted SQL could be used to pivot into other database schemas or linked systems, depending on database connectivity and permissions.

General mitigation guidance

Mitigation focuses on reducing the power and reach of any feature that executes SQL, and on separating administrative diagnostics from core data access:

  • Replace raw SQL execution interfaces with narrowly scoped, parameterized operations that implement specific administrative tasks (e.g., predefined reports or maintenance actions).
  • Enforce strict input validation and query whitelisting for any remaining database tools, rejecting free-form SQL and limiting operations to read-only where feasible.
  • Run the application and any admin tooling under a database role with least privilege, ensuring it cannot perform destructive or schema-altering operations.
  • Restrict access to sensitive administrative endpoints using strong authentication, role-based access control, and network-level protections (e.g., VPN, IP allowlisting).
  • Separate production database environments from diagnostic or testing databases, and avoid exposing generic SQL consoles on production systems.
  • Implement robust administrative account hygiene: unique accounts, multi-factor authentication, and fine-grained roles instead of broad "super-admin" privileges.

How teams detect issues like this

Effective detection combines application-layer monitoring with configuration and code review:

  • Review source code and configuration for endpoints or tools that accept raw SQL strings, especially those wired directly to database execution APIs.
  • Use static analysis or grep-based searches to identify unparameterized database calls and generic query execution methods invoked with externally supplied input.
  • Configure application logging to capture access to /admin/DatabaseQuery, including requesting user identity, IP, and the nature (not necessarily full content) of executed queries for anomaly detection.
  • Monitor database audit logs for unusual or high-risk statements originating from the application's database user, such as mass DELETE/UPDATE, schema changes, or bulk reads of security-sensitive tables.
  • Establish policy in code review to flag and justify any introduction of administrative SQL console functionality or unbounded database tools.

Sources

SourceLink
github.comgithub.com/terrasystemlabs/Exploits/tree/main/OpenKM-Exploits
github.comgithub.com/terrasystemlabs/Exploits/tree/main/OpenKM-Exploits/nuclei-templates/openkm-sql-database-query
hub.docker.comhub.docker.com/r/openkm/openkm-ce
terrasystemlabs.comterrasystemlabs.com/post?slug=openkm-zero-day-vulnerabilities-terra-system-labs
exploit-db.comexploit-db.com/exploits/52520
openkm.comopenkm.com/
vulncheck.comvulncheck.com/advisories/openkm-unrestricted-sql-execution-via-databasequery

Frequently asked

questions

Yes, but it typically requires authenticated access to the OpenKM administrative interface over HTTP(S). If the admin UI is reachable from untrusted networks, a remote attacker who obtains admin credentials could exploit it.

An attacker must hold, or compromise, an administrative account (or any account authorized to use the DatabaseQuery interface). From there, they can submit arbitrary SQL via the qs parameter.

Remove or disable generic SQL execution endpoints in production and replace them with narrowly scoped, parameterized administrative operations. Ensure the application uses least-privilege database roles so that even administrative functions cannot perform arbitrary destructive actions.

Avoid exposing raw database query capabilities through web interfaces, even to administrators. Design admin features as explicit, parameterized workflows; apply role-based access control and network isolation; use code review and automated checks to block introduction of unbounded SQL execution paths; and adopt a security policy that disallows generic SQL consoles in production applications.

Find out what's already
exploitable in your codebase.