unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <bofh@yhbt.net>
To: Sam Sanoop <sams@snyk.io>
Cc: unicorn-public@yhbt.net
Subject: Re: [RFC] http_response: ignore invalid header response characters
Date: Fri, 26 Feb 2021 11:15:52 +0000
Message-ID: <20210226111552.GA22901@dcvr> (raw)
In-Reply-To: <20201126115902.GA8883@dcvr>

cf. https://yhbt.net/unicorn-public/20201126115902.GA8883@dcvr/T/

This RFC patch isn't necessary and it's a waste of CPU cycles
for existing users returning valid responses.

I've confirmed nginx will return 502 (Bad Gateway) errors if
either the header key OR header value have "\r" (CR) in it.  The
client never sees the bad response through nginx, only the 502
from nginx.

For anybody unfamiliar with unicorn: unicorn was always designed
to have nginx in front of it, otherwise clients can trivially
DoS it.

I tested with nginx/1.14.2 on Debian stable (10.x).  Also,
varnish/6.1.1 (again on Debian stable) will fail with a 503
error when it sees "\r" in either the header key or value
(nowadays I rely on varnish quite a bit)

Again, thanks for the concern, but no action is necessary for
correctly configured deployments using nginx with or w/o varnish.

The following config.ru can be edited by uncommenting either
of the "cr*" lines to trigger the 502 from nginx.  Leaving
both lines commented shows a 200 "HI\n" response as expected.

==> config.ru <==
#\-E none
use Rack::CommonLogger
run lambda { |env|
  [ 200, {
     'Content-Type' => 'text/plain',
     'Content-Length' => '3',
     # uncommenting either of the following lines causes nginx to 502
     # varnish will 503
     #  "cr\rkey" => "cr-key",
     #  "cr-val" => "cr\rkey",
    },
    [ "HI\n" ]
  ]
}

      parent reply	other threads:[~2021-02-26 11:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-26 11:59 Eric Wong
2021-01-06 17:53 ` Eric Wong
2021-01-13 23:20   ` Sam Sanoop
2021-01-14  4:37     ` Eric Wong
2021-01-28 17:29       ` Sam Sanoop
2021-01-28 22:39         ` Eric Wong
2021-02-17 21:46           ` Sam Sanoop
2021-02-26 11:15 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210226111552.GA22901@dcvr \
    --to=bofh@yhbt.net \
    --cc=sams@snyk.io \
    --cc=unicorn-public@yhbt.net \
    --subject='Re: [RFC] http_response: ignore invalid header response characters' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhbt.net/unicorn-public
	git clone --mirror http://ou63pmih66umazou.onion/unicorn-public

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 unicorn-public unicorn-public/ https://yhbt.net/unicorn-public \
		unicorn-public@yhbt.net unicorn-public@bogomips.org mongrel-unicorn@rubyforge.org mongrel-unicorn-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
	public-inbox-index unicorn-public

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.unicorn
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	../../unicorn.git

AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git