Skip to content
SSRF Disclosed report Beginner CVE-2020-8118

Server-Side request forgery in New-Subscription feature of the calendar app

The calendar app's subscription feature allowed authenticated users to make the server fetch any URL and return the full response. An attacker could read internal network data and perform actions as the server.

foobar7 Follow

Originally disclosed on HackerOne

Bounty$100 Medium 5.0 View original
  • Triaged in under an hour
  • Fixed in 13 months
  • Paid in 13 months
  • Disclosed after 14 months

CVSS

8.5 High CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:L/A:N

Description

The "New Subscription" functionality of the official Calendar app allows authenticated users to direct the server to perform arbitrary external requests, and then displays the full response to the user. The requests can be directed to external websites as well as the internal network.

An attacker can use this vulnerability to exfiltrate data from the internal network that is not protected by other mechanisms, or to perform actions in the name of the server in the internal network which do not contain other protection mechanisms (reduced security is common in internal networks).

An attacker can also use this issue to scan the internal network as well as external websites for further vulnerabilities.

A user account is required, but it does not require extended permissions.

POC

GET /nextcloud/nextcloud/index.php/apps/calendar/v1/proxy?url=http%3A%2F%2Flocalhost%2Fsecret HTTP/1.1

HTTP/1.1 200 OK
[...]
secret

The "secret" file is an example of a file located in the internal network that is not protected by further authentication. Its content is displayed in full and as-is (the same is true for more complex files).

Solution

The given URL should be verified before making a request. If it is pointing to a private address, the request should not be performed. To reduce the impact of potential misuse of the host as a scanner, requests could be throttled.

Additionally, the impact of the issue could be reduced by processing the response server-side instead of client-side. Instead of displaying the entire HTTP response to the client, the response could be parsed and validated to ensure that it is in a calendar format. This way, non-calendar/ics information from internal networks would not leak to an attacker.

Impact

exfiltrate data from the internal network and perform actions in the name of the server in the internal network

The original report as published on HackerOne, by foobar7. 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. 5 min read.

Context

The target is the official Nextcloud Calendar app, a component of the Nextcloud server platform. The feature in question is "New Subscription": it lets an authenticated user add a calendar by pointing the app at a URL, so that the server fetches a remote calendar feed on the user's behalf. That design means the server makes outbound HTTP requests to addresses chosen by the user, and the report shows that the response is then handed back to the user in full.

The researcher classifies the issue as Server-Side Request Forgery (SSRF) and rates it 8.5 High using the CVSS 3.0 vector below. The platform record for the report lists it as medium severity with a CVSS score of 5.0, a 100.00 USD bounty, and disclosure on 2019-12-12.

Text
CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:L/A:N

Setup

The precondition is a user account on the Nextcloud instance. The report states that a user account is required but that it does not require extended permissions. No specific version, configuration or tooling is given. The proof of concept uses the Calendar app's proxy endpoint under the Nextcloud installation path.

Finding it

The researcher noticed that the "New Subscription" functionality allows authenticated users to direct the server to perform arbitrary external requests, and then displays the full response to the user. The requests can be directed to external websites as well as the internal network. That combination, server-side fetching of a user-chosen URL plus full response disclosure, is what turns a legitimate subscription feature into an SSRF primitive with a read channel.

Exploitation

Step 1: Request an internal URL through the proxy

The researcher sends a request to the Calendar app's proxy endpoint, passing a URL that points at localhost and a file called secret:

HTTP
GET /nextcloud/nextcloud/index.php/apps/calendar/v1/proxy?url=http%3A%2F%2Flocalhost%2Fsecret HTTP/1.1

The url parameter is URL-encoded (http%3A%2F%2Flocalhost%2Fsecret decodes to http://localhost/secret). Because the server performs the fetch, the request reaches the loopback interface rather than the client's network.

Step 2: Read the response

The server answers with a normal success status and returns the fetched content:

HTTP
HTTP/1.1 200 OK
[...]
secret

The body contains the content of the target file. The report notes that the secret file is an example of a file located in the internal network that is not protected by further authentication, and that its content is displayed in full and as-is. The same is true for more complex files.

Root cause

The report's recommended fix is to verify the user-supplied URL before making the request, and not to perform it if the URL points to a private address. The report's recommended fix states the missing check directly: the given URL should be verified before making a request, and if it is pointing to a private address, the request should not be performed. The proof of concept shows that a loopback address is reachable through the proxy.

The second half of the flaw is in how the result is handled. The response is displayed to the user in full. The report suggests processing it server-side instead, parsing and validating it to ensure it is in a calendar format. The report suggests that processing the response server-side instead, parsing and validating it to ensure it is in a calendar format, would reduce the impact, since non-calendar/ics information from internal networks would then not leak to an attacker.

Impact

An attacker with an ordinary authenticated account can use the vulnerability to exfiltrate data from the internal network that is not protected by other mechanisms. They can also perform actions in the name of the server in the internal network which do not contain other protection mechanisms; the report notes that reduced security is common in internal networks. Beyond reading and acting, the issue can be used to scan the internal network as well as external websites for further vulnerabilities.

The conditions are those stated: a user account is required, but no extended permissions are. The impact is bounded by what the server itself can reach and by whether the internal targets have their own authentication, since the report's example relies on a file that is not protected by further authentication.

Fix

The report proposes three measures:

  1. Verify the given URL before making a request, and do not perform the request if it points to a private address.
  2. Throttle requests to reduce the impact of potential misuse of the host as a scanner.
  3. Process the response server-side instead of client-side, parsing and validating it to ensure it is in a calendar format, so that non-calendar/ics information from internal networks does not leak to an attacker.

Variants to test

  • Other URL-accepting features in the same product, such as feed or subscription importers, tested with a loopback address in the same way. A positive result is a response body containing content the client could not otherwise reach.
  • Redirect-based bypasses of any private-address check: point the parameter at an external URL that redirects to an internal one. A positive result is internal content returned after the redirect.
  • Alternative representations of internal addresses (for example other encodings or host forms) against a deployment that has added a filter. A positive result is the filter being passed while the server still reaches the internal target.
  • Non-HTTP schemes accepted by the fetcher. A positive result is content from a local file or another service being returned in the response.

Hunting notes

This kind of bug tends to hide in features that fetch remote content on the user's behalf: calendar and feed subscriptions, URL previews, importers, webhooks and image or file fetchers. During recon, the signal is any endpoint that takes a URL parameter and returns fetched content, especially one whose response is rendered back to the user. The researcher demonstrated impact with a single request that returned the contents of an internal file in full, which shows both reach into the internal network and a read channel back to the attacker, the two properties a program needs to see before accepting an SSRF report.

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. 13 min read.

What happened, in plain words

Nextcloud is a piece of software that organisations install on their own servers to store files and share calendars, a bit like running your own private version of Google Drive and Google Calendar. The Calendar app is an add-on for Nextcloud that shows your calendars in a web page. One of its features is called "New Subscription": you give it a web address (a URL), and the server fetches a calendar file from that address so it can show the events in your calendar. This is handy because many calendars are published online as a file that updates regularly, and the server can pull in the latest version for you.

The server performs the fetch on the user's behalf. So when you type in a URL, the server goes off and visits that address on your behalf. Normally that is fine, but the researcher found that the server will visit any address you give it, including addresses that only the server itself can reach, such as its own internal network. And then it shows you the full response. That combination is dangerous: it means an ordinary user can use the server as a kind of spy, asking it to fetch things from places the user could never reach directly, and then reading the results.

This kind of bug is called Server-Side Request Forgery, or SSRF. The name describes it well: the server is tricked into making a request (forgery) that it should not make, on the attacker's behalf. A simple comparison: imagine you are at a hotel reception and you ask the receptionist to call a phone number for you. If the receptionist will dial any number, including internal extensions that guests cannot reach, and then read out loud whatever the person on the other end says, you have just used the receptionist as a way to reach private parts of the building. That is SSRF.

The researcher rated the issue 8.5 High using a scoring system called CVSS 3.0. The platform where the report was published lists it as medium severity with a score of 5.0, a bounty of 100.00 USD, and disclosure on 2019-12-12. The difference between the two scores is not explained in the report; the researcher's own vector is shown below.

Text
CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:L/A:N

This line is a compact way of describing how serious a vulnerability is. Each part is a code:

  • AV:N means the attack can be carried out over the network, not requiring physical access.
  • AC:L means the attack is easy to carry out (low complexity).
  • PR:L means the attacker needs low privileges, in this case just a normal user account.
  • UI:N means no action is needed from another user; the attacker does everything themselves.
  • S:C means the impact can spread beyond the vulnerable component (scope changed).
  • C:H means confidentiality impact is high: data can be read.
  • I:L means integrity impact is low: some data could be changed.
  • A:N means no availability impact: the service is not taken down.

Context

The target is the official Nextcloud Calendar app, which is a component of the Nextcloud server platform. The feature in question is "New Subscription": it lets a logged-in user add a calendar by pointing the app at a URL, so that the server fetches a remote calendar feed on the user's behalf. That design means the server makes outbound HTTP requests to addresses chosen by the user, and the report shows that the response is then handed back to the user in full.

A few terms here are worth unpacking for someone new to this. An HTTP request is the message your browser sends to a web server when you visit a page or load a resource; the server replies with an HTTP response, which contains a status code (like 200 for success) and a body (the content). A URL is just a web address, like https://example.com/calendar.ics. A calendar feed is a file, usually ending in .ics, that contains events in a standard format; calendar apps can subscribe to such a file and refresh it periodically. The server is the computer that runs Nextcloud; it may sit inside an organisation's private network, behind a firewall, where it can reach other internal machines that people on the internet cannot.

The researcher classifies the issue as Server-Side Request Forgery (SSRF) and rates it 8.5 High using the CVSS 3.0 vector shown above. The platform record for the report lists it as medium severity with a CVSS score of 5.0, a 100.00 USD bounty, and disclosure on 2019-12-12.

Setup

The precondition is a user account on the Nextcloud instance. The report states that a user account is required but that it does not require extended permissions. In plain terms: you need to be able to log in, but you do not need to be an administrator or have any special rights. No specific version, configuration or tooling is given in the report. The proof of concept uses the Calendar app's proxy endpoint under the Nextcloud installation path.

A proxy endpoint is a URL on the server that is designed to fetch something on your behalf and pass the result back to you. The word "proxy" means a go-between: you ask the proxy, and the proxy asks the real destination. In this case the endpoint lives under /apps/calendar/v1/proxy, which is part of the Calendar app's web interface.

Finding it

The researcher noticed that the "New Subscription" functionality allows authenticated users to direct the server to perform arbitrary external requests, and then displays the full response to the user. The requests can be directed to external websites as well as the internal network. That combination, server-side fetching of a user-chosen URL plus full response disclosure, is what turns a legitimate subscription feature into an SSRF primitive with a read channel.

To put it another way: the feature was built to fetch calendar files from the internet. The proof of concept shows a user can give it an address on the internal network and the server returns what it found there. The "read channel" is simply the fact that the response comes back to the user, so the attacker can see what the server saw.

Exploitation

Step 1: Request an internal URL through the proxy

The researcher sends a request to the Calendar app's proxy endpoint, passing a URL that points at localhost and a file called secret:

HTTP
GET /nextcloud/nextcloud/index.php/apps/calendar/v1/proxy?url=http%3A%2F%2Flocalhost%2Fsecret HTTP/1.1

Let us go through this line piece by piece:

  • GET is the HTTP method, meaning "please give me this resource". It is the same method your browser uses when you type an address into the address bar.
  • /nextcloud/nextcloud/index.php/apps/calendar/v1/proxy is the path to the proxy endpoint on the server. The repeated nextcloud is just part of the installation path in this example.
  • ?url= starts the query string, which is the part of a URL that carries parameters. Here the parameter is named url.
  • http%3A%2F%2Flocalhost%2Fsecret is the value of the url parameter, but it is URL-encoded. URL encoding replaces certain characters with a percent sign and two hexadecimal digits so they can travel safely inside a URL. %3A is a colon (:), %2F is a slash (/). So the value decodes to http://localhost/secret.
  • HTTP/1.1 at the end says which version of the HTTP protocol is being used.

Why localhost? localhost is a special hostname that always means "this same computer". When the server resolves localhost, it talks to itself, not to the internet. The file /secret is an example of something sitting on the server's own machine or internal network that is not protected by a login. Because the server performs the fetch, the request reaches the loopback interface (the internal "self" network of the machine) rather than the client's network. The attacker's browser could never reach localhost on the server; only the server can.

Step 2: Read the response

The server answers with a normal success status and returns the fetched content:

HTTP
HTTP/1.1 200 OK
[...]
secret

Line by line:

  • HTTP/1.1 200 OK is the status line of the response. 200 is the standard code for success, and OK is its human-readable label. It means the server did what was asked.
  • [...] stands for the response headers and other lines that the report has omitted for brevity. Headers are extra information about the response, such as its content type or length.
  • secret is the body of the response: the actual content that was fetched from http://localhost/secret.

The body contains the content of the target file. The report notes that the secret file is an example of a file located in the internal network that is not protected by further authentication, and that its content is displayed in full and as-is. The same is true for more complex files. In other words, the server did not just fetch the file; it handed the entire contents straight back to the user who asked.

Root cause

The report's recommended fix is to verify the user-supplied URL before making the request, and not to perform it if the URL points to a private address. The report's recommended fix states the missing check directly: the given URL should be verified before making a request, and if it is pointing to a private address, the request should not be performed. The proof of concept shows that a loopback address is reachable through the proxy.

A private address is an address on an internal network, one that is not meant to be reachable from the public internet. Checking for private addresses before fetching is the standard defence against SSRF: if the URL resolves to something internal, refuse to fetch it.

The second half of the flaw is in how the result is handled. The response is displayed to the user in full. The report suggests processing it server-side instead, parsing and validating it to ensure it is in a calendar format. "Client-side" means the processing happens in the user's browser rather than on the server. The report suggests that processing the response server-side instead, parsing and validating it to ensure it is in a calendar format, would reduce the impact, since non-calendar/ics information from internal networks would then not leak to an attacker. In plain terms: if the server only ever showed you the parts of the response that look like a calendar, then a file that is not a calendar would not be shown to you at all.

Impact

An attacker with an ordinary authenticated account can use the vulnerability to exfiltrate data from the internal network that is not protected by other mechanisms. "Exfiltrate" means to steal data by copying it out. They can also perform actions in the name of the server in the internal network which do not contain other protection mechanisms; the report notes that reduced security is common in internal networks. Beyond reading and acting, the issue can be used to scan the internal network as well as external websites for further vulnerabilities. Scanning means probing many addresses to see which ones respond, which helps an attacker map out what is there.

The conditions are those stated: a user account is required, but no extended permissions are. The impact is bounded by what the server itself can reach and by whether the internal targets have their own authentication, since the report's example relies on a file that is not protected by further authentication.

Fix

The report proposes three measures:

  1. Verify the given URL before making a request, and do not perform the request if it points to a private address.
  2. Throttle requests to reduce the impact of potential misuse of the host as a scanner. "Throttle" means limit how often requests can be made, so an attacker cannot fire off thousands of probes quickly.
  3. Process the response server-side instead of client-side, parsing and validating it to ensure it is in a calendar format, so that non-calendar/ics information from internal networks does not leak to an attacker.

Variants to test

The technical write-up lists further things a tester might try, to see whether the same class of bug appears elsewhere or survives a partial fix:

  • Other URL-accepting features in the same product, such as feed or subscription importers, tested with a loopback address in the same way. A positive result is a response body containing content the client could not otherwise reach.
  • Redirect-based bypasses of any private-address check: point the parameter at an external URL that redirects to an internal one. A positive result is internal content returned after the redirect. A redirect is when a server tells your browser (or another server) to go to a different address instead.
  • Alternative representations of internal addresses (for example other encodings or host forms) against a deployment that has added a filter. A positive result is the filter being passed while the server still reaches the internal target.
  • Non-HTTP schemes accepted by the fetcher. A scheme is the first part of a URL, like http:// or file://. A positive result is content from a local file or another service being returned in the response.

Hunting notes

This kind of bug tends to hide in features that fetch remote content on the user's behalf: calendar and feed subscriptions, URL previews, importers, webhooks and image or file fetchers. A webhook is a URL that one system calls automatically when something happens, again a case of a server making a request to an address someone else chose. During recon (the early phase of looking around a target), the signal is any endpoint that takes a URL parameter and returns fetched content, especially one whose response is rendered back to the user. The researcher demonstrated impact with a single request that returned the contents of an internal file in full, which shows both reach into the internal network and a read channel back to the attacker, the two properties a program needs to see before accepting an SSRF report.

Glossary

  • API: a defined way for one piece of software to talk to another, like a menu of requests a service will accept.
  • Authentication: proving who you are, usually by logging in with a username and password.
  • Authorised / authenticated user: someone who has logged in successfully.
  • Bounty: a payment made by an organisation to a researcher who reports a valid security bug.
  • Calendar feed: a file, usually in .ics format, containing calendar events that an app can subscribe to and refresh.
  • Client-side: processing that happens in the user's browser rather than on the server.
  • CVSS: a standard scoring system for rating the severity of security vulnerabilities, from 0 to 10.
  • Endpoint: a specific URL on a server that accepts requests and does something.
  • Exfiltrate: to copy data out of a system without permission, usually to an attacker-controlled place.
  • GET: the HTTP method used to ask for a resource, such as a web page or file.
  • HTTP: the protocol browsers and servers use to exchange requests and responses on the web.
  • HTTP response: the reply a server sends back, containing a status code, headers and a body.
  • Loopback interface: the internal network of a single machine, where localhost points; traffic never leaves the computer.
  • Private address: an address on an internal network that is not meant to be reachable from the public internet.
  • Proxy: a go-between that makes a request on someone else's behalf and passes the result back.
  • Recon: the early phase of exploring a target to find out what it exposes.
  • Redirect: a server instruction to go to a different address instead of the one requested.
  • Scheme: the first part of a URL, such as http://, https:// or file://, which says how to reach the resource.
  • Server: the computer that runs a service and responds to requests from clients.
  • Server-Side Request Forgery (SSRF): a vulnerability where an attacker makes the server send a request to an address of the attacker's choosing, often to reach internal systems.
  • Throttle: to limit the rate at which requests are allowed, for example a maximum per minute.
  • URL: a web address, such as https://example.com/page.
  • URL encoding: replacing characters in a URL with percent signs and hexadecimal codes so they can be transmitted safely, for example %3A for a colon.
  • Webhook: a URL that one system calls automatically when an event happens, so a server makes a request to an address someone else supplied.

More by foobar7

View all

17 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.