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/DatabaseQueryendpoint 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
qsparameter in a request to/admin/DatabaseQuery. - Why exploitation is possible: The endpoint passes the contents of
qsdirectly 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.

