GHSA-8v3q-9vmx-36vc: DbGate: Unauthenticated Remote Code Execution via JSON Script Runner
SummaryDbGate's JSON script runner (`POST /runners/start`) allows remote code execution via code injection in the `functionName` parameter of JSON script `assign` commands. The `functionName` value is interpolated directly into dynamically generated JavaScript source code via string concatenation. The generated code is then executed in a forked Node.js child process.DetailsStep 1: User Input Entry Point**File:** `packages/api/src/controllers/runners.js` - `start()` methodThe `/runners/start` endpoint accepts a POST body containing a `script` object. When `script.type == 'json'`, the request follows a different code path than raw shell scripts:This path skips:The `run-shell-script` permission checkThe `allowShellScripting` platform-level checkThe only validation performed is `checkSecureDirectoriesInScript()`, which `props.fileName` valuesStep 2: JSON-to-JavaScript Conversion (Injection Point)**File:** `packages/tools/src/ScriptWriter.ts` - `assignCore()` methodThe JSON script's `commands` array contains objects with `type: "assign"`. The `assignCore` method generates JavaScript by direct string concatenation of user-controlled values:Both `variableName` and `functionName` are attacker-controlled values taken directly from the JSON request body and interpolated into the generated JavaScript source code.Step 3: Function Name Compilation**File:** `packages/tools/src/packageTools.ts` - `compileShellApiFunctionName()`Before interpolation, `functionName` passes through this function:An attacker supplying `functionName: "x;MALICIOUS_CODE;//"` gets:This is syntactically valid JavaScript: `dbgateApi.x` evaluates (and is discarded), `MALICIOUS_CODE` executes, and `//` comments out the trailing `(${JSON.stringify(props)});`.Step 4: Generated JavaScript TemplateThe complete generated script that gets executed:Step 5: Execution via child_process.fork()**File:** `packages/api/src/controllers/runners.js` - `startCore()` methodThe generated JavaScript string is written to a temporary file and executed as a new Node.js process via `child_process.fork()`. This provides the attacker with a full Node.js runtime, including access to `process`, `child_process`, `fs`, `net`, and all other Node.js built-in modules.The `require = null` sandbox can be bypassed via:`process.mainModule.require()` - separate reference unaffected by the null assignment`module.constructor._load()` - internal module loader, also unaffectedAdditional Injection PointsThe same unsanitised string interpolation pattern exists in:| Endpoint | Parameter | File |
|----------|-----------|------|
| `POST /runners/start` | `functionName` in assign commands | `ScriptWriter.ts` - `assignCore()` |
| `POST /runners/start` | `variableName` in assign commands | `ScriptWriter.ts` - `assignCore()` |
| `POST /runners/load-reader` | `functionName` parameter | `ScriptWriter.ts` - `loaderScriptTemplate` |PoCThe request to the out of band host was as follows:A bearer token is required to reach the endpoint, but in what appears to be the default deployment, authentication is disabled. Authentication needs to be explicitly set via environment variables. If this has not been explicitly set, per the defaults, a token can be retrieved using:Impact| Scenario | Impact | CVSS Score | CVSS Vector | 
|----------|--------|--------|--------|
| Anonymous auth mode (default deployment) (`authProvider: "Anonymous"`) | Unauthenticated RCE | 10.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H |
| Authenticated deployment | Authenticated RCE - any user with API access |  9.9 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H |Timeline| Date | Event |
|------|-------|
| 2026-03-31 | Vulnerability discovered |
| 2026-04-07 | Advisory report prepared and submitted to maintainer |
| 2026-04-22 | Fix released (v7.1.9) |
| 2026-04-24 | Maintainer acknowledgment |
| 2026-05-20 | Public disclosure |AcknowledgementsDiscovery assisted by Neo from @ProjectDiscoveryInitial research direction inspired by @H0j3n — https://github.com/runZeroInc/nuclei-templates/blob/main/http/vulnerabilities/dbgate-unauth-rce.yaml
CVSS v3.1: 10