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

オープン
#29 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
TypeScript
スター
2
フォーク
1
平均マージ
6分
マージ済み PR(30日)
27

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sumamakhan761/tryinstance のほかの issue

sumamakhan761/tryinstance の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。