Possibility to force an admin to install recommended applications
The endpoint /nextcloud/index.php/core/apps/recommended can be accessed via GET without an anti-CSRF token, so if an admin visits a malicious page, the installation of recommended applications starts automatically. An attacker could force an admin to install applications, increasing the attack surface.
- Triaged in 6 hours
- Fixed in 4 months
- Paid in 5 months
- Disclosed after 5 months
Summary by the program
Advisory at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-5vw6-6prg-gvw6
The report
Summary:
Endpoint /nextcloud/index.php/core/apps/recommended is accessible via GET http method and doesn't check anti-csrf token. If an admin visits this endpoint in a browser the process of installation of recommended applications begins immediately.
Steps To Reproduce:
- an attacker creates a malicious page on controlled domain
- an attacker enforce an admin to visit this page
- an admin visits this page
- applications will be installed in a while
Affected version:
nextcloud/server: 22.2.2 (at least)
Recommendation:
require requesttoken for this GET query or you can change behaviour so to initiate the installation process by manual click (POST query with checking of requesttoken)
[attachment / reference]
Impact
Increasing of attack surface. Any unused plugins should be disabled or removed. But this way allows to install them.
Context
Nextcloud is a self-hosted file sync and collaboration platform. Its server component ships with an app store, and the server can recommend a set of applications to administrators. The feature at the centre of this report is the endpoint that starts installing those recommended applications.
The researcher found that this endpoint, /nextcloud/index.php/core/apps/recommended, is reachable with a plain GET request and does not check an anti-CSRF token. Because the action is triggered by a simple GET, any page an administrator visits in the same browser can cause the installation to start. The report was filed against nextcloud/server version 22.2.2 (at least) and was rated low severity (CVSS 2.4), with a 100 USD bounty, under the Cross-Site Request Forgery weakness.
Setup
The precondition is an administrator who is logged in to Nextcloud and who then visits an attacker-controlled page in the same browser. The attacker needs a domain they control to host that page. No other tooling, account or configuration is described in the report.
Finding it
The researcher observed that the recommended-apps endpoint accepts GET and performs the installation as a side effect, without validating a request token. A state-changing action reachable by GET and without a token check is the classic shape of a CSRF: the browser will happily issue the request cross-site, and the server has nothing to distinguish it from a legitimate one.
Exploitation
Step 1: Host a malicious page
The attacker creates a page on a domain they control. The report does not include the page's markup, only the fact that visiting it is enough to reach the endpoint.
Step 2: Get the administrator to visit it
The attacker enforces, in the report's wording, that an administrator visits the page. The mechanism for that is not described beyond the visit itself.
Step 3: The administrator visits the page
When the logged-in administrator loads the attacker's page, the browser sends the request to the Nextcloud endpoint. Because the endpoint is a GET and does not check an anti-CSRF token, the request is accepted.
Step 4: Applications are installed
The installation of the recommended applications begins immediately and the applications are installed after a while. The video attached to the report shows the process running:
Root cause
The endpoint performs a state-changing operation (installing applications) on a GET request and does not require a request token. The report's recommendation points at exactly this: require a request token for the GET query, or change the behaviour so that installation starts from a manual click, i.e. a POST with a request token check. The report does not describe the server-side code, so the precise reason the existing defences did not apply is not stated; likely the endpoint simply lacked the token validation that other state-changing routes use.
Impact
The impact is an increase in attack surface. Applications that are unused should be disabled or removed, but this behaviour allows an attacker to have them installed instead. The action is limited to the set of recommended applications and requires an administrator to visit the attacker's page while logged in. The report does not claim code execution, data access or any other consequence beyond the installation of those applications.
Fix
The report recommends one of two changes: require a request token for the GET query, or move the installation trigger to a manual click backed by a POST that validates the request token. The program published an advisory for the issue at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-5vw6-6prg-gvw6; the report itself does not describe the patch.
Variants to test
- Other endpoints that install, enable or configure apps and accept
GET: a positive result is the action completing from a cross-site page without a token. - Administrative actions that are triggered on page load rather than on a form submission: a positive result is the state change happening when the admin merely opens the attacker's page.
- Endpoints that check a token only on
POSTbut still act onGET: a positive result is the same side effect through theGETpath. - Recommended or default-content features that fetch and install remote items: a positive result is installation starting without an explicit administrator confirmation.
Hunting notes
This kind of bug tends to hide in convenience features: endpoints that kick off a background job, an installation or a configuration change and that were written to be easy to link to or load. During recon, look for routes whose names suggest an action (install, enable, recommended, setup) and check whether they respond to GET. The signal is a state-changing route without a token parameter or header requirement. The report attaches a video as evidence; it does not describe any further evidence presented to the program.
What happened, in plain words
Nextcloud is a piece of software that lets a group of people keep files and calendars in sync on a server they run themselves. Think of it as a private shared drive that lives on a computer you control, rather than on someone else's cloud. The server part of Nextcloud comes with an app store, a place where an administrator can add extra features (apps) to the installation. Nextcloud can also suggest a set of apps it thinks are worth having, and there is a special web address that starts installing those suggested apps.
A security researcher, igorpyan, found that this web address could be triggered by simply loading a page. It did not ask for any proof that the request really came from the administrator using Nextcloud's own screens. That means a page on any other website could quietly make the administrator's browser send the request, and the installation would start. This kind of trick is called Cross-Site Request Forgery, or CSRF: another site forges a request that the victim's browser sends with the victim's own logged-in identity attached.
The report was filed against the Nextcloud server code, version 22.2.2 (at least), and was rated low severity with a CVSS score of 2.4. A bounty of 100 USD was paid, and the report was disclosed on 29 April 2022. The program also published an advisory at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-5vw6-6prg-gvw6.
The pieces you need to know
Before the steps make sense, a few everyday ideas:
- A web address (URL) and an endpoint. When you type an address into your browser, you are asking a particular computer (the server) for something. An endpoint is just the specific address on that server that handles one job. Here the endpoint is
/nextcloud/index.php/core/apps/recommended, which is the job of installing the recommended apps. - GET and POST. These are two ways a browser can ask a server to do something. A
GETis what happens when you click a normal link or load a page: the browser asks for something and expects to be given it back. APOSTis what happens when you submit a form: the browser sends data and expects the server to change something. The convention is thatGETshould only read, never change. This report is about aGETthat changes things. - A token (anti-CSRF token, request token). A token is a short, hard-to-guess value that the server gives to the real Nextcloud page and expects back with any request that changes something. It works like a cloakroom ticket: only the person holding the matching ticket gets the coat. If a request arrives without the right ticket, the server should refuse it. The report calls this an anti-CSRF token or a request token.
- A cookie and a logged-in session. When you log in to a website, the server gives your browser a small piece of data (a cookie) so it can recognise you on the next page. Your browser automatically attaches that cookie to every request it sends to that site, including requests started by other pages. That automatic attachment is exactly what makes CSRF possible.
- CSRF (Cross-Site Request Forgery). Imagine someone posts you a form letter that is already filled in and stamped with your signature, and all you have to do is drop it in the postbox. You did not write it, but it arrives as if you did. In CSRF, the attacker's page makes your browser send a request to a site you are logged in to, and the site cannot tell it apart from a request you made yourself.
- Attack surface. The attack surface is the total set of things an attacker could possibly use to get in or cause trouble. Every extra feature that is switched on is one more thing that could have a flaw, so a larger attack surface is worse.
The finding
The researcher noticed that the recommended-apps endpoint, /nextcloud/index.php/core/apps/recommended, answers to a plain GET request and does not check for an anti-CSRF token. In other words, the address that installs software can be reached the same way as an ordinary link, and the server does not ask for the cloakroom ticket.
A change to the system (installing apps) that can be triggered by a GET and without a token check is the classic shape of a CSRF. The browser will happily send the request from another site, and the server has nothing to compare it against to tell whether it was really the administrator's own doing.
How it was done
The only precondition is an administrator who is logged in to Nextcloud and who then opens a page controlled by the attacker in the same browser. The attacker needs a domain they control to host that page. The report does not describe any other tool, account or configuration.
Step 1: Create a malicious page
The attacker creates a page on a domain they control. The report does not include the page's markup; it only says that visiting the page is enough to reach the endpoint. The purpose of this step is to have a place the administrator can be sent to, where the attacker controls what the browser is told to do.
Step 2: Get the administrator to visit it
The attacker, in the report's wording, enforces that an administrator visits the page. The report does not describe how the administrator is persuaded or made to visit; only the visit itself matters. The purpose of this step is to get the victim's browser, with its Nextcloud login cookie attached, to load the attacker's page.
Step 3: The administrator visits the page
When the logged-in administrator loads the attacker's page, the browser sends the request to the Nextcloud endpoint. Because the endpoint is a GET and does not check an anti-CSRF token, the request is accepted. The purpose of this step is the forgery itself: the browser is doing what the attacker's page says, but the Nextcloud server sees a request that looks like it came from the administrator.
Step 4: The apps are installed
The installation of the recommended applications begins immediately and the applications are installed after a while. The video attached to the report shows the process running:
The report attaches a video alongside the steps.
Why it worked
The endpoint performs a state-changing operation (installing applications) on a GET request and does not require a request token. The report's recommendation points at exactly this: require a request token for the GET query, or change the behaviour so that installation starts from a manual click, that is, a POST with a request token check.
Most likely the endpoint simply lacked the token validation that other state-changing routes use.
What the impact is
The impact is an increase in attack surface. Applications that are unused should be disabled or removed, but this behaviour allows an attacker to have them installed instead. The action is limited to the set of recommended applications, and it requires an administrator to visit the attacker's page while logged in. The report does not claim code execution, data access or any other consequence beyond the installation of those applications.
The fix
The report recommends one of two changes: require a request token for the GET query, or move the installation trigger to a manual click backed by a POST that validates the request token. The program published an advisory for the issue at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-5vw6-6prg-gvw6; the report itself does not describe the patch.
Other places to look for the same pattern
- Other endpoints that install, enable or configure apps and accept
GET. A positive result is the action completing from a cross-site page without a token. - Administrative actions that are triggered on page load rather than on a form submission. A positive result is the state change happening when the admin merely opens the attacker's page.
- Endpoints that check a token only on
POSTbut still act onGET. A positive result is the same side effect through theGETpath. - Recommended or default-content features that fetch and install remote items. A positive result is installation starting without an explicit administrator confirmation.
Notes for anyone hunting this kind of bug
This kind of bug tends to hide in convenience features: endpoints that kick off a background job, an installation or a configuration change, and that were written to be easy to link to or load. During recon, look for routes whose names suggest an action (install, enable, recommended, setup) and check whether they respond to GET. The signal is a state-changing route without a token parameter or header requirement.
Glossary
- Nextcloud: self-hosted software for syncing files and collaborating, run on a server you control.
- App store: the part of Nextcloud where extra features (apps) can be added.
- Endpoint: a specific web address on a server that handles one particular job.
- GET: a browser request that asks for something, normally without changing anything, used when you click a link or load a page.
- POST: a browser request that sends data and is expected to change something, normally used when you submit a form.
- Token (anti-CSRF token, request token): a short, hard-to-guess value the server expects back with requests that change something, proving the request came from the real site.
- Cookie: a small piece of data a site stores in your browser so it can recognise you on later requests.
- Session: the logged-in state a site keeps for you, usually tied to a cookie.
- CSRF (Cross-Site Request Forgery): an attack where another website makes your browser send a request to a site you are logged in to, and the site cannot tell it was not you.
- Attack surface: the total set of features and entry points an attacker could try to abuse.
- CVSS: a standard scoring system for how serious a security flaw is; higher numbers mean more severe.
- Bounty: a payment made by a program to a researcher who reports a valid security flaw.
- Advisory: a public notice describing a security flaw and its fix.
- Recon: the information-gathering phase of security testing, where you look for interesting routes and features.