registry auth survives an http to https token realm redirect behind a TLS proxy

This commit is contained in:
jarek committed 2026-08-20 08:28:26 +02:00
1 parent 3d208e6f22
commit f50c3e52f3
10 files changed
+154 -14

No files matched your search

@@ -1,6 +1,7 @@
import { json } from '@sveltejs/kit';
import { unixSocketRequest, httpsAgentRequest } from '$lib/server/docker';
import type { DockerClientConfig } from '$lib/server/docker';
import { isSafeNotificationUrl } from '$lib/server/url-safety';
import type { RequestHandler } from './$types';
interface TestConnectionRequest {
@@ -79,6 +80,15 @@ export const POST: RequestHandler = async ({ request }) => {
return json({ success: false, error: 'Host is required' }, { status: 400 });
}
// SSRF guard: host/port come straight from the request body. A remote
// Docker/Hawser daemon legitimately lives on a LAN, so allow private
// ranges but block loopback + cloud metadata (169.254.169.254) + reserved
// so this tester can't be used to probe the control plane or metadata IMDS.
const hostSafety = isSafeNotificationUrl(`${protocol}://${host}:${port}`);
if (!hostSafety.ok) {
return json({ success: false, error: `Host not allowed: ${hostSafety.reason}` }, { status: 200 });
}
const headers: Record<string, string> = {
'Content-Type': 'application/json'
};