fix: block telemetry endpoint from pointing at internal hosts

This commit is contained in:
Linus Rath
2026-04-28 17:16:30 +02:00
parent 0f3b506604
commit 81d8465a79
4 changed files with 134 additions and 2 deletions
+6 -2
View File
@@ -11,6 +11,7 @@ import {
reschedule,
DEFAULT_ENDPOINT,
getLoginCounts,
resolveEndpointAllowed,
} from '@/lib/telemetry';
/**
@@ -100,8 +101,11 @@ export async function POST(request: NextRequest) {
return NextResponse.json({ error: 'endpoint required' }, { status: 400 });
}
const trimmed = body.endpoint.trim();
if (trimmed && !/^https?:\/\//i.test(trimmed)) {
return NextResponse.json({ error: 'endpoint must be http(s)://' }, { status: 400 });
if (trimmed) {
const check = await resolveEndpointAllowed(trimmed);
if (!check.ok) {
return NextResponse.json({ error: check.reason }, { status: 400 });
}
}
const state = await loadState();
const before = state.endpoint;