/

CVE-2026-47668

Severity:

CRITICAL RISK

(10.0)

Code Injection (CWE-94) in DbGate JSON Script Runner

CVE-2026-47668

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-20, CWE-94, CWE-1188

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(10.0)

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

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/start for JSON script execution
  • Required access: Ability to submit or influence JSON scripts containing assign commands with controlled functionName values
  • Trigger point: Execution of dynamically generated JavaScript in a forked Node.js child process created by the script runner
  • Why exploitation is possible: The functionName parameter 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 functionName to 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, vm modules, 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 functionName values, 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.

Sources

SourceLink
github.comgithub.com/dbgate/dbgate/releases/tag/v7.1.9
github.comgithub.com/dbgate/dbgate/security/advisories/GHSA-8v3q-9vmx-36vc
github.comgithub.com/runZeroInc/nuclei-templates/blob/main/http/vulnerabilities/dbgate-unauth-rce.yaml

Frequently asked

questions

Exploitability depends on how widely the /runners/start endpoint is exposed. If it is accessible to untrusted users or integrated systems without strict controls, a remote attacker can potentially submit crafted JSON scripts and gain code execution.

Not necessarily. If the JSON script runner endpoint is reachable over the network and accepts requests from external clients, no local access is required. Any authentication or authorization layer in front of the endpoint becomes the primary barrier to exploitation.

The most robust fix is to remove dynamic code generation for user-controlled values and instead use a fixed mapping of allowed operations, with functionName resolving only to predefined, non-dynamic handlers. Additionally, enforce strict validation and whitelisting of script parameters.

Avoid designs that interpret user input as code or identifiers that influence code generation. Favor data-driven execution models, apply strong input validation, and subject any dynamic execution mechanisms to dedicated security review and automated static analysis checks before release.

Find out what's already
exploitable in your codebase.