chrismccord

chrismccord

Creator of Phoenix

Security Releases for Phoenix

A minor vulnerability has been disclosed for applications redirecting to URLs provided by user input. Only applications passing user input to Phoenix.Controller.redirect/2 are affected. For example, code such as the following is vulnerable to this disclosure:

redirect(conn, to: params["redirect"])     

We have released new Phoenix versions v1.0.6, v1.1.8, v1.2.3, and v1.3.0-rc.1 which addresses this issue. If you are unable to upgrade, a fix to use in your own application can be found below.

Disclosure

From day one, the Phoenix team designed Phoenix.Controller.redirect/2 to protect against redirects allowing user input to redirect to an external URL where your application code otherwise assumes a local path redirect. This is why the :to option is used for “local” URL redirects and why you must pass the :external option to intentionally allow external URLs to be redirected to. It has been disclosed that carefully crafted user input may be treated by some browsers as an external URL. An attacker can use this vulnerability to aid in social engineering attacks. The most common use would be to create highly believable phishing attacks. For example, the following user input would pass local URL validation, but be treated by Chrome and Firefox as external URLs:

http://localhost:4000/?redirect=/\nexample.com

Not all browsers are affected, but latest Chrome and Firefox will issue a get request for example.com and successfully redirect externally.

  • Versions affected: v1.0.0, v1.0.1, v1.0.2, v1.0.3, v1.0.4, v1.1.0, v1.1.1, v1.1.2, v1.1.3, v1.1.4, v1.1.5, v1.1,6, v1.2.0, v1.2.1, v1.3.0-rc.0
  • Versions fixed: v1.0.5+, v1.1.7+, v1.2.3+, v1.3.0-rc.1+
  • Author: Jeff Dileo
  • Thanks to: Jeff Dileo and his colleagues at the NCC Security Advisory Group

Temporary Fix

If you are able to update via mix and hex, simply run mix deps.update phoenix to jump on the latest point release with this fix. Those unable to upgrade can add the following function and import to their controllers:

import Phoenix.Controller, except: [redirect: 2]

def redirect(conn, opts) do
  to = opts[:to]

  if to && String.contains?(to, "\\") ->
    raise ArgumentError, "unsafe characters detected for local redirect in URL #{inspect to}"
  else
    Phoenix.Controller.redirect(conn, opts)
  end
end

Thank You

I would like to thank the NCC Group for reporting this vulnerability and working with us to harden the Phoenix and Plug code-bases.

NCC Group is a global expert in cyber security and risk mitigation,
working with businesses to protect their brand, value and reputation
against the ever-evolving threat landscape. Our Security Consulting
services leverage our extensive knowledge of current security
vulnerabilities, penetration testing techniques and software development
best practices to enable organizations to secure their applications
against ever-present threats. At NCC Group we can boast unrivaled talent
and recognized world-class security expertise. Bringing together best in
class security consultancies iSEC Partners, Intrepidus Group, Matasano,
NCC Group and NGS we have created one of the largest, most respected
security consultancies in the world.

Where Next?

Popular in Phoenix News Top

chrismccord
LiveView 1.0.0-rc.0 is out! This 1.0 milestone comes almost six years after the first LiveView commit. I published a Phoenix blog highli...
New
New
chrismccord
I’m pleased to announce the first release candidate of Phoenix 1.6.0 has landed on the heels of a fresh LiveView 0.16 release! This relea...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
chrismccord
The final release of Phoenix 1.7 is out! Most of the new features have been outlined in the 1.7 RC thread, but it has been a few months s...
New
chrismccord
Announcement post dup’d here for convenience: Phoenix 1.7.2 is out! This minor release includes a couple features worth talking about. ...
New
chrismccord
Phoenix 1.3.5, 1.4.18, 1.5.14, and 1.6.14 have been released to resolve a vulnerability in wildcard check_origin configurations. Previou...
New
chrismccord
Hey folks, Phoenix 1.3.0 is out! The final release please brings tweaks to web directory and alias conventions that were estabished in ...
New
chrismccord
You can read the announcement on the blog, but I’ll dup most of it here for discussion purposes: ––––––––––––––––––––––––––––––––––––––...
451 13182 109
New
chrismccord
Check the announcement blog for details! Blog duped here for convenience: Phoenix 1.8.0-rc released! The first release candidate of P...
414 11568 167
New

Other popular topics Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement