Folded headers can cause 503 responses, or even no response at all

Bug #1752324 reported by Tim Burke
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Confirmed
Medium
Unassigned

Bug Description

To repro:

$ curl -v http://saio:8090/v1/AUTH_test/c/obj -X POST -H "$(echo -e 'x-object-meta-can:we\n do: multiline?')"
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to saio (127.0.0.1) port 8090 (#0)
> POST /v1/AUTH_test/c/tox.ini HTTP/1.1
> User-Agent: curl/7.35.0
> Host: saio:8090
> Accept: */*
> x-object-meta-can:we
> do: multiline?
>
< HTTP/1.1 503 Service Unavailable
< Content-Length: 118
< Content-Type: text/html; charset=UTF-8
< X-Trans-Id: txafd7c2fb28fa44958469b-005a96ac2c
< X-Openstack-Request-Id: txafd7c2fb28fa44958469b-005a96ac2c
< Date: Wed, 28 Feb 2018 13:18:36 GMT
<
* Connection #0 to host saio left intact
<html><h1>Service Unavailable</h1><p>The server is currently unavailable. Please try again at a later time.</p></html>

Proxy has tracebacks like

Trying to POST /AUTH_test/c/obj:
Traceback (most recent call last):
  File "/vagrant/swift/swift/proxy/controllers/base.py", line 1616, in _make_request
    headers=headers, query_string=query)
  File "/vagrant/swift/swift/common/bufferedhttp.py", line 210, in http_connect
    ipaddr, port, method, path, headers, query_string, ssl)
  File "/vagrant/swift/swift/common/bufferedhttp.py", line 241, in http_connect_raw
    conn.putheader(header, str(value))
  File "/usr/lib/python2.7/httplib.py", line 990, in putheader
    raise ValueError('Invalid header name %r' % (header,))
ValueError: Invalid header name ' Do' (txn: tx9d9e4455ded5485e8ad97-005a96aaef)

Even more fun is when your folded headers *don't* have a colon:

$ curl -v http://saio:8090/v1/AUTH_test/c/obj -X POST -H "$(echo -e 'x-object-meta-can:we\n do\n multiline?')"
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to saio (127.0.0.1) port 8090 (#0)
> POST /v1/AUTH_test/c/obj HTTP/1.1
> User-Agent: curl/7.35.0
> Host: saio:8090
> Accept: */*
> x-object-meta-can:we
> do
> multiline?
>
* Empty reply from server
* Connection #0 to host saio left intact
curl: (52) Empty reply from server

Proxy says

Feb 28 13:22:14 saio proxy-server: STDERR: Traceback (most recent call last):
Feb 28 13:22:14 saio proxy-server: STDERR: File "/usr/local/lib/python2.7/dist-packages/eventlet/greenpool.py", line 82, in _spawn_n_impl
Feb 28 13:22:14 saio proxy-server: STDERR: func(*args, **kwargs)
Feb 28 13:22:14 saio proxy-server: STDERR: File "/usr/local/lib/python2.7/dist-packages/eventlet/wsgi.py", line 734, in process_request
Feb 28 13:22:14 saio proxy-server: STDERR: proto.__init__(sock, address, self)
Feb 28 13:22:14 saio proxy-server: STDERR: File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
Feb 28 13:22:14 saio proxy-server: STDERR: self.handle()
Feb 28 13:22:14 saio proxy-server: STDERR: File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
Feb 28 13:22:14 saio proxy-server: STDERR: self.handle_one_request()
Feb 28 13:22:14 saio proxy-server: STDERR: File "/usr/local/lib/python2.7/dist-packages/eventlet/wsgi.py", line 388, in handle_one_request
Feb 28 13:22:14 saio proxy-server: STDERR: self.environ = self.get_environ()
Feb 28 13:22:14 saio proxy-server: STDERR: File "/usr/local/lib/python2.7/dist-packages/eventlet/wsgi.py", line 618, in get_environ
Feb 28 13:22:14 saio proxy-server: STDERR: env['headers_raw'] = headers_raw = tuple((k, v.strip()) for k, v in headers)
Feb 28 13:22:14 saio proxy-server: STDERR: File "/usr/local/lib/python2.7/dist-packages/eventlet/wsgi.py", line 618, in <genexpr>
Feb 28 13:22:14 saio proxy-server: STDERR: env['headers_raw'] = headers_raw = tuple((k, v.strip()) for k, v in headers)
Feb 28 13:22:14 saio proxy-server: STDERR: ValueError: need more than 1 value to unpack

clayg (clay-gerrard)
Changed in swift:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Samuel Merritt (torgomatic) wrote :

RFC 7230 deprecates folded headers; see section 3.2.4.

I'd be fine with not adding more code to support a deprecated bit of RFC 2616.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.