fix(webhooks): block SSRF to localhost, link-local, and private IP addresses
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 58/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- backend-api-design, security
Research direction
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.
Written by the indexing model from the issue text.
Description
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
- Webhook URLs must only allow
http:andhttps:protocols. - 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 beforefetch(...). - Redirects on outbound webhook
fetchrequests should be disabled (redirect: 'error') or re-validated against the same blocklist.
Where to Look
apps/api/src/webhooks/dto/create-webhook.dto.tsapps/api/src/webhooks/webhooks.service.ts(createWebhook,testWebhook,dispatch)
Solution / Implementation Guide
- In
CreateWebhookDto, update@IsUrl(...)to enforceprotocols: ['http', 'https']andrequire_protocol: true. - Add an
assertSafeWebhookUrl(rawUrl: string)helper inwebhooks.service.ts(or a shared utility) that:- Parses the URL with
new URL(rawUrl)and checksprotocol === 'http:' || protocol === 'https:'. - Resolves the hostname via
dns.lookupand rejects private, loopback, link-local, multicast, and reserved IPv4/IPv6 ranges.
- Parses the URL with
- Call
assertSafeWebhookUrlincreateWebhook,testWebhook, anddispatchbeforefetch(...), and setredirect: 'error'infetchoptions.
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 1
- Avg merge
- 6m
- Merged PRs (30d)
- 27
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sumamakhan761/tryinstance
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sumamakhan761/tryinstance#65 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
sumamakhan761/tryinstance#64 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
sumamakhan761/tryinstance#63 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sumamakhan761/tryinstance#62 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sumamakhan761/tryinstance#60 ·
Maintainers usually reply within 1 day
All issues in sumamakhan761/tryinstance
Similar issues
-
prio:low scope:hud
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OliverRomhagen/vrigstad-joyride#953 ·
Maintainers usually reply within 1 day
-
review-followup
Difficulty 1/5 Under an hour Newbie friendliness 92/100
griffinwork40/agent-afk#5446 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
kacper-szewczyk/Ticknest#346 ·
Maintainers usually reply within 1 day
-
echarts geo: a GeoJSON URL that returns 200 with a body that is not JSON is fetched on each refreshOpenbug plugin/echarts/geo
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Yeachan-Heo/gajae-code#8230 ·
Maintainers usually reply within 1 day