fix(server): SSRF guard on cross-instance invite preview fetch

This commit is contained in:
Jannis Braun
2026-04-29 22:19:10 +02:00
parent 4476c55963
commit 5481eb9e7e
2 changed files with 26 additions and 0 deletions
@@ -1,4 +1,5 @@
import type { AvatarColor } from '@backspace/shared';
import { validateExternalUrl } from './ssrf.js';
export interface SpaceInviteSnapshot {
spaceId: string;
@@ -24,6 +25,11 @@ export async function fetchSpaceInviteSnapshot(
timeoutMs = 5000,
): Promise<SpaceInviteSnapshot | null> {
const url = `${spaceInstanceOrigin}/api/spaces/invite/${encodeURIComponent(inviteCode)}/preview`;
try {
await validateExternalUrl(url);
} catch {
return null;
}
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), timeoutMs);
try {