fix(mcp-oauth): use fixed localhost base for callback URL parsing

Cubic AI reviewer flagged the use of the untrusted Host header as the
URL base in startCallbackServer. The server only binds to 127.0.0.1,
so hardcoding "http://127.0.0.1" as the URL base is robust against
malformed or manipulated Host values and matches upstream behavior
prior to the node:http refactor.
This commit is contained in:
YeonGyu-Kim
2026-05-12 12:54:24 +09:00
parent 100819f0bc
commit 8e07ef642e
+1 -2
View File
@@ -57,8 +57,7 @@ export async function startCallbackServer(startPort: number = DEFAULT_PORT): Pro
}, TIMEOUT_MS)
const server = createServer((request: IncomingMessage, response: ServerResponse) => {
const host = request.headers.host ?? "127.0.0.1"
const url = new URL(request.url ?? "/", `http://${host}`)
const url = new URL(request.url ?? "/", "http://127.0.0.1")
if (url.pathname !== "/oauth/callback") {
response.statusCode = 404