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

Đang mở
#29 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
58/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, typescript

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
2
Fork
1
Merge trung bình
6 phút
Pull request đã merge (30 ngày)
27

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của sumamakhan761/tryinstance

Tất cả issue của sumamakhan761/tryinstance

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.