minhajuddin

minhajuddin

Hi Guys,
I had to build a Gzip plug for one of my projects as I needed only a subset of pages to be Gzipped (PlugContrib.Gzip – plug_contrib v0.1.2). I’d love to hear any ideas to add to this plug_contrib package. Rack has a nice list of Middlewares listed at GitHub - rack/rack-contrib: Contributed Rack Middleware and Utilities · GitHub . Many of these are already present in Phoenix/Plug. I’d love to hear ideas on what people would like to have in this project. I’d love for this project to collect non core plugs which web apps may need from time to time :slight_smile:

Showing Posts 1 to 6

josevalim

josevalim

Creator of Elixir

Btw, Cowboy also supports gzipping. You only need to pass compress: true to the server configuration (on Phoenix this means under the :http/:https keys in your configuration):

config :my_app, MyApp.Endpoint,
  http: [compress: true, ...],
  https: [compress: true, ...]

The Plug can still be handy in many situations, for example, if you cannot compress all routes, the Plug gives you flexibility where the Cowboy configuration cannot.

minhajuddin

minhajuddin OP

Thanks, I did come across this. Like you said it compressed all the traffic. Our scenario required compression of just a subset of the routes :slight_smile:

nathanl

nathanl

Note that compression + SSL/TLS can open you to http://breachattack.com/. After some investigation, I think we’ll just do without gzip on our API responses, which are served over HTTPS. :frowning2:

josevalim

josevalim

Creator of Elixir

Plug.CSRFProtection uses a masked token which does not make it vulnerable to breach (although you need to be careful to not introduce something similar).

nathanl

nathanl

Good to know. Our API users request API tokens (with credentials) and send them back in requests. I’m not sure whether that makes us vulnerable (I don’t thoroughly understand BREACH), so at the moment I’m thinking we won’t use compression.

nathanl

nathanl

I think we’re safe from BREACH after all and can use gzip + https.

Essentially, I think the vulnerability is this:

  • Assume an attacker can make their victim make requests to our site. The
    attacker cannot see inside the HTTPS responses, but can see their
    length.
  • The attacker makes the victim make repeated requests to an endpoint that
    returns both an unchanging secret value (like an API token) and a
    value that the attacker can change (eg, a search term that gets echoed
    in the response).
  • The attacker keeps tweaking the search term in successive requests.
    Because gzip works by de-duplication, the closer the attacker gets to
    guessing the API token, the smaller the response gets. Eventually, they
    can guess it exactly, and can then impersonate their victim to
    our site.

I think we’re safe because:

  • We don’t have any endpoints which return both and API token and
    some value sent in the request.
  • In any case, we never send the same API token twice because the value
    we send is timestamped and signed; we use Phoenix.Token.sign/3. This
    should make guesing the value as describe above impossible.

If anybody knows otherwise, please chime in. I’ve also asked about it on the Information Security Stackexchange.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
CodeSync
:microphone: ElixirConf 2026 - Call for Talks is open! We’re heading to Chicago :united_states: :round_pushpin: In person + virtual :d...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews