<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/github---scoville-req-ssrf-ssrf-protection-for-req-4awzo12ju" -->

---
title: GitHub - scoville/req_ssrf: SSRF protection for Req
description: ReqSSRF is an Elixir plugin for the Req HTTP client that guards against Server Side Request Forgery by validating URL schemes, IP addresses, and DNS resolution...
canonical: https://daily.dev/posts/github---scoville-req-ssrf-ssrf-protection-for-req-4awzo12ju
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: GitHub - scoville/req_ssrf: SSRF protection for Req | daily.dev
og:description: ReqSSRF is an Elixir plugin for the Req HTTP client that guards against Server Side Request Forgery by validating URL schemes, IP addresses, and DNS resolution...
og:url: https://daily.dev/posts/github---scoville-req-ssrf-ssrf-protection-for-req-4awzo12ju
og:image: https://api.daily.dev/og/posts/4AwZO12Ju.png
og:image:alt: GitHub - scoville/req_ssrf: SSRF protection for Req
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub - scoville/req_ssrf: SSRF protection for Req

**[ElixirStatus](https://daily.dev/sources/elixirstatus)** · 7 min read · 0 upvotes · 0 comments

## Summary

ReqSSRF is an Elixir plugin for the Req HTTP client that guards against Server Side Request Forgery by validating URL schemes, IP addresses, and DNS resolution before a request is made, and re-checking every redirect hop. It blocks requests to reserved IP ranges and unresolvable hosts, but explicitly does not defend against DNS rebinding (where a resolver answers differently at connection time) and cannot always distinguish a failed lookup from a missing DNS record due to OTP collapsing errors into :nxdomain. The README also documents residual risks: error messages can leak internal hostname existence, the server's own IP becomes the requester of record, and connection pools need manual idle-time tuning.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://github.com/scoville/req_ssrf>

## Questions this post answers

### How can I protect an Elixir Req HTTP client from SSRF attacks when fetching user-supplied URLs?

Attach the ReqSSRF plugin to a Req request instead of manually checking the URL: Req.new() |> ReqSSRF.attach() |> Req.get(url: submitted_url). It validates the scheme (http/https only by default), refuses IP addresses in IANA reserved ranges, resolves hostnames and checks both A and AAAA records, and re-validates on every redirect since Req re-runs request steps per hop.

_Developers hardening Elixir services against SSRF can track library updates like this on daily.dev._

### Does SSRF URL validation at request time protect against DNS rebinding attacks?

No, checking a URL's resolved address before connecting does not prevent DNS rebinding, because the host is resolved again separately when the actual connection is made and an attacker-controlled nameserver can answer differently the second time. Closing this gap requires pinning the connection to the validated address or denying egress to private ranges and metadata endpoints at the network level.

_Anyone weighing SSRF mitigations against DNS rebinding risk can follow related security writeups on daily.dev._

### Why would an SSRF check pass a hostname whose IPv4 address is unreachable but treat a failed DNS lookup as safe?

Erlang/OTP collapses every DNS resolution failure into the single reason :nxdomain, so a check cannot distinguish a resolver that refused to answer from a name that simply has no record for that address family. This means a name whose A lookup fails and whose AAAA record is public can pass validation, yet the actual request still connects over the untested A record.

_Elixir developers debugging SSRF edge cases can dig into OTP DNS behavior discussions on daily.dev._

## Similar posts on daily.dev

- [req\_ssrf](https://daily.dev/posts/req-ssrf-hzniwdspj) · ElixirStatus · 0 upvotes · 0 comments
- [GitHub - scoville/req\_circuit\_breaker: Circuit breaker plugin for Req using Fuse](https://daily.dev/posts/github---scoville-req-circuit-breaker-circuit-breaker-plugin-for-req-using-fuse-idpvlhtul) · ElixirStatus · 0 upvotes · 0 comments
- [Understanding SSRF: Concepts, Patterns and Practical Exploitation](https://daily.dev/posts/understanding-ssrf-concepts-patterns-and-practical-exploitation-wivb8rtso) · InfoSec Write-ups · 0 upvotes · 0 comments
- [Preventing SSRF in Laravel: Why Blocking Private IPs Fails](https://daily.dev/posts/preventing-ssrf-in-laravel-why-blocking-private-ips-fails-xpdzp3fxe) · FREEK.DEV · 0 upvotes · 0 comments

---

Tags: [#security](https://daily.dev/tags/security), [#elixir](https://daily.dev/tags/elixir), [#appsec](https://daily.dev/tags/appsec)

[View this post on daily.dev](https://daily.dev/posts/github---scoville-req-ssrf-ssrf-protection-for-req-4awzo12ju)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"GitHub - scoville/req_ssrf: SSRF protection for Req","url":"https://daily.dev/posts/github---scoville-req-ssrf-ssrf-protection-for-req-4awzo12ju","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/github---scoville-req-ssrf-ssrf-protection-for-req-4awzo12ju"},"datePublished":"2026-09-08T13:35:04.522Z","dateModified":"2026-09-08T13:35:27.494Z","description":"ReqSSRF is an Elixir plugin for the Req HTTP client that guards against Server Side Request Forgery by validating URL schemes, IP addresses, and DNS resolution...","image":"https://media.daily.dev/image/upload/s--CxzD6vbw--/f_auto/v1722860399/public/Placeholder%2005","thumbnailUrl":"https://media.daily.dev/image/upload/s--CxzD6vbw--/f_auto/v1722860399/public/Placeholder%2005","isAccessibleForFree":true,"articleSection":"ElixirStatus","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"ElixirStatus","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/22e4640538124187827caf8cc8e39190","url":"https://daily.dev/sources/elixirstatus"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/github---scoville-req-ssrf-ssrf-protection-for-req-4awzo12ju","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"security,elixir,appsec","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"ElixirStatus","item":"https://daily.dev/sources/elixirstatus"},{"@type":"ListItem","position":3,"name":"GitHub - scoville/req_ssrf: SSRF protection for Req"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/github---scoville-req-ssrf-ssrf-protection-for-req-4awzo12ju#faq","mainEntity":[{"@type":"Question","name":"How can I protect an Elixir Req HTTP client from SSRF attacks when fetching user-supplied URLs?","acceptedAnswer":{"@type":"Answer","text":"Attach the ReqSSRF plugin to a Req request instead of manually checking the URL: Req.new() |\u003e ReqSSRF.attach() |\u003e Req.get(url: submitted_url). It validates the scheme (http/https only by default), refuses IP addresses in IANA reserved ranges, resolves hostnames and checks both A and AAAA records, and re-validates on every redirect since Req re-runs request steps per hop. Developers hardening Elixir services against SSRF can track library updates like this on daily.dev."}},{"@type":"Question","name":"Does SSRF URL validation at request time protect against DNS rebinding attacks?","acceptedAnswer":{"@type":"Answer","text":"No, checking a URL's resolved address before connecting does not prevent DNS rebinding, because the host is resolved again separately when the actual connection is made and an attacker-controlled nameserver can answer differently the second time. Closing this gap requires pinning the connection to the validated address or denying egress to private ranges and metadata endpoints at the network level. Anyone weighing SSRF mitigations against DNS rebinding risk can follow related security writeups on daily.dev."}},{"@type":"Question","name":"Why would an SSRF check pass a hostname whose IPv4 address is unreachable but treat a failed DNS lookup as safe?","acceptedAnswer":{"@type":"Answer","text":"Erlang/OTP collapses every DNS resolution failure into the single reason :nxdomain, so a check cannot distinguish a resolver that refused to answer from a name that simply has no record for that address family. This means a name whose A lookup fails and whose AAAA record is public can pass validation, yet the actual request still connects over the untested A record. Elixir developers debugging SSRF edge cases can dig into OTP DNS behavior discussions on daily.dev."}}]}
```

