Skip to content

Unauthenticated Server Bound to All Network Interfaces #305

@Koukyosyumei

Description

@Koukyosyumei

Summary

The Express HTTP server is unconditionally started on the wildcard address '0.0.0.0', binding to every network interface, and no authentication middleware is registered on any route:

// src/server.ts:233
app.listen(port, '0.0.0.0', () => {  // ← binds to ALL interfaces
    console.error(`MCP server endpoint at http://localhost:${port}/mcp`);
});

No API key, Bearer token, or any other credential check exists anywhere in the middleware chain. Any TCP connection reaching the port — whether from loopback, LAN, VPN, or a Docker bridge — is served as a fully privileged MCP client.

Related | CVE-2026-23744 (MCPJam Inspector — 0.0.0.0 bind + no auth)

Scenario

  1. Developer starts dbhub --transport=http --dsn="postgres://..." on a
    workstation connected to a shared office network.
  2. Any other machine on the same subnet sends a single HTTP POST to
    http://<developer-LAN-IP>:8080/mcp with a JSON-RPC initialize request —
    no credentials required.
  3. After the handshake, the attacker calls execute_sql to dump, modify, or
    delete data in the connected database:

Patch Idea

Step 1 — Bind to loopback only unless the operator explicitly overrides:

// src/config/env.ts — add bind address resolution
export function resolveBindAddress(): string {
    return process.env.DBHUB_BIND_ADDRESS ?? '127.0.0.1';
}
// src/server.ts — replace '0.0.0.0' with the resolved address
const bindAddress = resolveBindAddress();
app.listen(port, bindAddress, () => { ... });

Step 2 — Add token-based authentication for production use:

// src/server.ts — add before all routes
const API_TOKEN = process.env.DBHUB_API_TOKEN;
if (API_TOKEN) {
    app.use('/mcp', (req, res, next) => {
        const auth = req.headers.authorization ?? '';
        if (auth !== `Bearer ${API_TOKEN}`) {
            return res.status(401).json({ error: 'Unauthorized' });
        }
        next();
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions