A look at slab/safeurl-elixir: 73 stars on GitHub, written primarily in Elixir, tracked under the Security category. HTTP client with built-in SSRF protection, compatible with Tesla and HTTPoison
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
SafeURL is a library that aids developers in protecting against a class of vulnerabilities
known as Server Side Request Forgery. It does this by validating a URL against a configurable
allow or block list before making an HTTP request.
See the Documentation on HexDocs.
Installation
To get started, add safeurl to your project dependencies in mix.exs. Optionally, you may
also add HTTPoison to your dependencies for making requests directly
through SafeURL:
def deps do
[
{:safeurl, "~> 1.0"},
{:httpoison, "~> 2.2"}, # Optional
]
end
To use SafeURL with your favorite HTTP Client, see the HTTP Clients section.
Usage
SafeURL blocks private/reserved IP addresses are by default, and users can add additional
CIDR ranges to the blocklist, or alternatively allow specific CIDR ranges to which the
application is allowed to make requests.
You can use allowed?/2 or validate/2 to check if a URL is safe to call. If you have the
HTTPoison application available, you can also call get/4 which will
validate the host automatically before making a web request, and return an error otherwise.
SafeURL can be configured to customize and override validation behaviour by passing the
following options:
:block_reserved - Block reserved/private IP ranges. Defaults to true.
:blocklist - List of CIDR ranges to block. This is additive with :block_reserved.
Defaults to [].
:allowlist - List of CIDR ranges to allow. If specified, blocklist will be ignored.
Defaults to [].
:schemes - List of allowed URL schemes. Defaults to ["http, "https"].
:dns_module - Any module that implements the SafeURL.DNSResolver behaviour.
Defaults to DNS from the :dns package.
:detailed_error - Return specific error if validation fails. If set to false, validate/2 will return {:error, :restricted} regardless of the reason. Defaults to true.
These options can be passed to the function directly or set globally in your config.exs
file:
While SafeURL already provides a convenient SafeURL.HTTPoison.get/3 method to validate hosts
before making GET HTTP requests, you can also write your own wrappers, helpers or
middleware to work with the HTTP Client of your choice.
HTTPoison
For HTTPoison, you can create a wrapper module that validates hosts
before making HTTP requests:
defmodule CustomClient do
def request(method, url, body, headers \\ [], opts \\ []) do
{safeurl_opts, opts} = Keyword.pop(opts, :safeurl, [])
with :ok <- SafeURL.validate(url, safeurl_opts) do
HTTPoison.request(method, url, body, headers, opts)
end
end
def get(url, headers \\ [], opts \\ []), do: request(:get, url, "", headers, opts)
def post(url, body, headers \\ [], opts \\ []), do: request(:post, url, body, headers, opts)
# ...
end
For Tesla, SafeURL provides a helper middleware out-of-the-box, which you can plug anywhere you're using Tesla:
defmodule DocumentService do
use Tesla
plug Tesla.Middleware.BaseUrl, "https://document-service/"
plug Tesla.Middleware.JSON
plug SafeURL.TeslaMiddleware, schemes: ~w[https], allowlist: ["10.0.0.0/24"]
def fetch(id) do
get("/documents/#{id}")
end
end
Custom DNS Resolver
In some cases you might want to use a custom strategy for DNS resolution. You can do so by
passing your own implementation of SafeURL.DNSResolver in the global or local
config.
No homepage URL was recorded for slab/safeurl-elixir in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
How active is development on slab/safeurl-elixir?
The most recent commit recorded on slab/safeurl-elixir was 1.8 years ago, based on the GitHub push timestamp. The repository has 4 forks — one of the better signals of community interest.
How many stars does slab/safeurl-elixir have?
slab/safeurl-elixir has 73 GitHub stars — refresh the page for the live number, or check github.com/slab/safeurl-elixir. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is slab/safeurl-elixir written in?
slab/safeurl-elixir is written primarily in Elixir. GitHub's language field is based on the largest share of bytes in the default branch.
What topics is slab/safeurl-elixir associated with?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/slab/safeurl-elixir is the definitive source.
Read full README in the tab above.
Curious whether safeurl-elixir is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about safeurl-elixir.