fix(webhooks): block SSRF to localhost, link-local, and private IP addresses

Abierto
#29 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
58/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
node.js, typescript

Línea de trabajo

Start with apps/api/src/webhooks/dto/create-webhook.dto.ts and apps/api/src/webhooks/webhooks.service.ts, focusing on createWebhook, testWebhook, and dispatch. Check how the project handles DNS lookup and IP range validation, then verify URL checks cover creation and immediately before requests. Done when unsafe protocols and resolved addresses are rejected and redirects cannot reach unvalidated destinations.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

backend bug
Problem Description

In apps/api/src/webhooks/dto/create-webhook.dto.ts, CreateWebhookDto validates url using @IsUrl({ require_tld: false }) without restricting URL protocols or blocking internal/private network addresses.

This allows users to register webhook URLs pointing to localhost, 127.0.0.1, 169.254.169.254 (cloud metadata), or private IP ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, ::1, fc00::/7).
In apps/api/src/webhooks/webhooks.service.ts, both testWebhook and dispatch call fetch(endpoint.url) directly with no IP/protocol/DNS blocklist and follow redirects by default, enabling Server-Side Request Forgery (SSRF).


Expected Behavior
  1. Webhook URLs must only allow http: and https: protocols.
  2. Loopback, link-local (169.254.0.0/16), private RFC1918/IPv6, multicast, and unspecified (0.0.0.0) addresses must be blocked both on creation and after DNS resolution right before fetch(...).
  3. Redirects on outbound webhook fetch requests should be disabled (redirect: 'error') or re-validated against the same blocklist.

Where to Look
  • apps/api/src/webhooks/dto/create-webhook.dto.ts
  • apps/api/src/webhooks/webhooks.service.ts (createWebhook, testWebhook, dispatch)

Solution / Implementation Guide
  1. In CreateWebhookDto, update @IsUrl(...) to enforce protocols: ['http', 'https'] and require_protocol: true.
  2. Add an assertSafeWebhookUrl(rawUrl: string) helper in webhooks.service.ts (or a shared utility) that:
    • Parses the URL with new URL(rawUrl) and checks protocol === 'http:' || protocol === 'https:'.
    • Resolves the hostname via dns.lookup and rejects private, loopback, link-local, multicast, and reserved IPv4/IPv6 ranges.
  3. Call assertSafeWebhookUrl in createWebhook, testWebhook, and dispatch before fetch(...), and set redirect: 'error' in fetch options.
Lenguaje dominante
TypeScript
Estrellas
2
Forks
1
Merge medio
6 min
PR fusionados (30 d)
27

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de sumamakhan761/tryinstance

Todos los issues de sumamakhan761/tryinstance

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.