Summary
DbGate's /runners/load-reader endpoint allows an authenticated user to inject arbitrary JavaScript code into a server-side template via the functionName parameter.
When exploited, this flaw can lead to arbitrary code execution with the full privileges of the Node.js process, enabling command execution, file access, and access to connected databases in deployments where the vulnerable endpoint is exposed.
Affected context
The vulnerability appears in DbGate deployments that expose the /runners/load-reader HTTP endpoint and allow authenticated users with basic access to call it.
The risk is present when the server directly interpolates user-provided function names into JavaScript code templates on the backend without validation, while running the Node.js process with access to the host filesystem and stored database connection credentials.
Containerized or Docker-based deployments may limit system-wide impact, but can still suffer full compromise within the container and unauthorized access to databases reachable from DbGate.
Exploit preconditions
- Attack surface: HTTP API endpoint
POST /runners/load-readeron the DbGate server. - Required access: Valid authenticated DbGate user account with basic privileges; no administrative role or shell-execution permissions needed.
- Trigger point: Supplying a crafted
functionNamevalue that is interpolated into JavaScript code and executed server-side. - Why exploitation is possible: The application builds and evaluates JavaScript code using untrusted input without sanitization, validation, or robust sandboxing, allowing the injected code to escape the intended
require = nullrestriction and execute with full process privileges.
Why this happens
This issue stems from constructing executable JavaScript code by directly embedding user-controlled data into a server-side template and then evaluating it.
Rather than treating functionName as a simple identifier and validating it against a known set of safe values, the backend logic allows arbitrary content to be inserted into a code string, which is then executed by the Node.js engine.
This behavior aligns with CWE-94: Improper Control of Generation of Code ('Code Injection'), where dynamically generated code is influenced by untrusted input, bypassing intended sandbox limitations and enabling arbitrary script execution.
Potential impact
- Execute arbitrary OS commands with the privileges of the DbGate Node.js process.
- Read, modify, or delete files accessible to the DbGate server process.
- Retrieve and abuse stored database connection credentials, then access or manipulate connected databases.
- Pivot into other systems reachable from the DbGate environment, including internal databases and services.
- Fully compromise Docker or container environments at the level of the application container, often equivalent to root within that container.
- Disrupt availability of the DbGate service or corrupt hosted data.
General mitigation guidance
Effective mitigation involves treating all input that influences code generation as untrusted and avoiding dynamic evaluation patterns where possible.
Common defensive strategies include:
- Replacing dynamic code generation with static, predefined functions selected from a whitelist of allowed operations.
- Strictly validating parameters like
functionNameagainst an allowlist of safe identifiers, rejecting any unexpected values. - Avoiding
eval,Function, or similar runtime code-compilation mechanisms on server-side request data. - Implementing strong sandboxing for any required scripting, including explicit API exposure, restricted globals, and separation of untrusted code from core application privileges.
- Running DbGate with least-privilege OS accounts, constrained filesystem permissions, and hardened container settings to reduce blast radius if code execution occurs.
How teams detect issues like this
Organizations can look for this class of vulnerability using a combination of code inspection and automated scanning:
- Static analysis: Rules that flag use of
eval,new Function, dynamicvmcontexts, or string-based code construction where untrusted input contributes to the code body. - Code review: Manual checks for endpoints where parameters are interpolated into JavaScript templates, particularly around "runner", "scripting", or "plugin" features.
- Security testing: Targeted dynamic tests that send crafted
functionNamevalues to the/runners/load-readerendpoint and observe unusual server behavior, errors, or execution traces. - Policy enforcement: CI/CD checks and linters that prohibit unsafe code generation patterns or require explicit security review for any server-side scripting features.

