Summary
DbGate's JSON script runner builds JavaScript source code by concatenating user-provided values from the functionName field and then executing the result in a child Node.js process.
An attacker who can invoke the /runners/start endpoint with crafted JSON scripts may achieve remote code execution by injecting arbitrary JavaScript into the generated script.
Affected context
This vulnerability affects deployments of DbGate (versions 7.1.8 and prior) where the JSON script runner endpoint (POST /runners/start) is reachable to untrusted or semi-trusted clients.
The issue manifests specifically in JSON scripts that use assign commands, where the functionName parameter is used to construct JavaScript code.
Because the parameter is interpolated directly into source strings without neutralization or validation, any environment exposing this endpoint without strict access control may be at risk.
Exploit preconditions
- Attack surface: HTTP API endpoint
POST /runners/startfor JSON script execution - Required access: Ability to submit or influence JSON scripts containing
assigncommands with controlledfunctionNamevalues - Trigger point: Execution of dynamically generated JavaScript in a forked Node.js child process created by the script runner
- Why exploitation is possible: The
functionNameparameter is concatenated unescaped into JavaScript source code, allowing arbitrary code fragments to break out of expected syntax and inject attacker-controlled logic before execution
Why this happens
The root cause is the use of dynamic code generation that directly incorporates user-controlled input into executable JavaScript without proper validation or encoding.
Specifically, the JSON script runner takes the functionName field from assign commands and inserts it into JavaScript source via string concatenation, then evaluates this constructed source in a Node.js child process.
This pattern maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), combined with CWE-20: Improper Input Validation and CWE-1188: Insecure Default Initialization of Resource, because execution behavior is derived from untrusted configuration-like input instead of fixed, vetted logic.
Potential impact
- Remote execution of arbitrary JavaScript code within the Node.js child process
- Access to and manipulation of connected databases managed by DbGate
- Exposure or alteration of sensitive data accessible to the DbGate process
- Use of the compromised process as a foothold for lateral movement within the hosting environment
- Execution of arbitrary OS-level commands where the Node.js runtime has sufficient permissions
General mitigation guidance
Mitigation typically focuses on removing direct string-based code generation and eliminating the need to interpret user-controlled values as executable JavaScript.
Safer design patterns include:
- Restricting
functionNameto a fixed whitelist of known-safe identifiers or mapping it to pre-defined functions rather than generating code dynamically - Avoiding
eval-like constructs and dynamic compilation; using explicit function dispatch tables instead - Applying rigorous input validation and normalization to script parameters, ensuring they conform to expected formats and cannot alter code structure
- Isolating script execution in a minimally privileged environment with constrained access to the filesystem, network, and database resources
- Treating JSON scripts as untrusted data and designing the runner to operate on data structures rather than assembling and executing raw source code
How teams detect issues like this
Detection strategies for this class of issue often combine code-centric and operational approaches:
- Static analysis rules that flag concatenation of user inputs into strings subsequently passed to dynamic execution APIs (e.g.,
eval,Function,vmmodules, or custom runners) - Code review checklists that require justification for any dynamic code generation paths and explicit rejection of user-controlled identifiers being embedded in source code
- Logging and monitoring of JSON script submissions, especially unusual or rarely used
functionNamevalues, to identify suspicious patterns - Policy-based CI/CD checks that block merges when dangerous dynamic execution constructs are introduced without appropriate safeguards
Organizations may also use automated security testing tools that fuzz JSON script inputs to detect unexpected execution behavior.

