Default Nextcloud Server and Android Client leak sharee searches to Nextcloud
- Triaged in 16 hours
- Fixed in 22 days
- Paid in 13 days
- Disclosed after 58 days
On a clean Nextcloud setup the functionality "Search global and public address book for users" is enabled.
Now when searching for a sharee to share with. The lookup parameter is not passed to the server. Resulting in https://github.com/nextcloud/server/blob/master/apps/files_sharing/lib/Controller/ShareesAPIController.php#L144
the lookup being true. So the lookup server of Nextcloud will be searched by default. It seems that the lookup server is down now. But this seems to be an error I assume?
Impact
Anybody sharing trough the android app. Leaks their sharee searches to the Nextcloud lookup server. Now the server can can only see the origin Nextcloud server (or rather the IP of that). Still. This should not be leaked by default.
On the web and desktop there is first a local search. And only if the user explicitly presses the search globally the lookup server is queried. (to be fair this could also be more clear that it actually sends data to other systems)
Context
Nextcloud is a self-hosted file sync and share platform. One of its features is the sharee search: when a user shares a file or folder, the client asks the server which users, groups or other principals the item can be shared with. Nextcloud also operates a global lookup server, a central directory that can be queried to find sharees that are not present on the local instance.
The report concerns the Android client, com.nextcloud.client, and how it performs that sharee search against a Nextcloud server. The relevant server-side code is the sharees API controller in the files_sharing app, which decides whether the global lookup server is queried based on a lookup parameter.
Setup
The precondition is a clean Nextcloud setup on which the setting "Search global and public address book for users" is enabled. On a clean Nextcloud setup this setting is enabled, so no special configuration is needed beyond a default deployment. The researcher used the Android client to search for sharees to share with.
Finding it
The researcher noticed that when the Android client searches for a sharee, it does not pass the lookup parameter to the server. The server-side controller then falls back to treating the lookup as enabled, so the Nextcloud lookup server is queried by default.
The relevant code is in ShareesAPIController.php, at the line the researcher links to:
https://github.com/nextcloud/server/blob/master/apps/files_sharing/lib/Controller/ShareesAPIController.php#L144
At that point the lookup value is true when the client has not supplied it, which means the request is forwarded to the global lookup server without the user asking for a global search.
The researcher also notes that the lookup server appeared to be down at the time of testing, and assumes that this is an error rather than intended behaviour.
Exploitation
Step 1: Use the Android client to search for a sharee
On a default installation with "Search global and public address book for users" enabled, the user opens the sharing dialog in the Android app and searches for a sharee. The client sends the search to the server without the lookup parameter.
Step 2: The server defaults lookup to true
Because the parameter is absent, the controller at the linked line treats lookup as true and queries the Nextcloud lookup server as part of the sharee search. The search terms the user typed are therefore sent to the central lookup server.
Step 3: Observe what the lookup server receives
The lookup server can only see the origin Nextcloud server, or rather the IP address of that server. The researcher notes that the lookup server was down during testing, which is treated as an error rather than a design decision.
Root cause
The Android client does not send the lookup parameter when performing a sharee search, and the server-side controller defaults that parameter to true when it is missing. The result is that a global lookup happens even though the user only intended a local search. The default setting "Search global and public address book for users" being enabled on a clean setup means this happens without any administrator action.
The web and desktop clients behave differently: they perform a local search first, and only query the lookup server if the user explicitly presses the button to search globally. The researcher adds that even that flow could be clearer about the fact that data is being sent to other systems.
Impact
Anybody sharing through the Android app leaks their sharee search terms to the Nextcloud lookup server. The lookup server can only see the origin Nextcloud server, or rather the IP address of that server, so the leak is of the search terms tied to the originating instance rather than of individual user identities. The researcher's position is that this should not happen by default.
Fix
The report does not describe a fix or a change that was made. The behaviour it asks for is that the Android client should not trigger a global lookup unless the user explicitly requests one, matching the web and desktop clients, which search locally first and only query the lookup server on an explicit global search.
Variants to test
- Other mobile or third-party clients against the same sharees API: send a sharee search without the lookup parameter and check whether the server forwards it to the lookup server. A positive result is a request to the lookup server that the user did not ask for.
- Other API endpoints that take an optional boolean controlling external lookups: omit the parameter and observe whether the default enables the external call. A positive result is an outbound request to a third-party service on a default configuration.
- Instances where the global address book search setting has been disabled by the administrator: repeat the Android sharee search and check whether the lookup still occurs. A positive result is a lookup despite the setting being off.
Hunting notes
This kind of bug tends to hide in the gap between clients: a server-side default that is safe for one client (the web UI, which sends the parameter explicitly) can be unsafe for another client that never sends it. During recon, look for optional parameters that gate outbound requests to third-party or central services, and check what the server does when the parameter is absent. Comparing the requests made by different official clients against the same endpoint is a quick way to spot the discrepancy.
The researcher argued that a default installation plus the Android client is enough to send user search terms to an external lookup server, and contrasted that with the web and desktop clients. The report was rated low severity and a bounty of 750.00 USD was awarded.
What happened, in plain words
Nextcloud is a piece of software you install on your own computer or server to store and share files, a bit like running your own private version of a cloud drive. When you want to share a file with someone, you type part of their name into a search box and the software suggests people. That suggestion step is called the sharee search.
Nextcloud can also run a central directory called the lookup server. If the person you want is not on your own Nextcloud, your server can ask this central directory whether it knows them. That is useful, but it means your search words leave your server and go to a machine run by someone else.
This report is about the Nextcloud Android app, the phone app for Nextcloud. The researcher found that when you search for someone to share with in the Android app, the app does not tell the server whether you wanted a local search or a global one. The server, seeing no answer, assumes you wanted the global search, and quietly asks the central lookup server. So your search terms are sent to an outside system even though you never asked for that.
The web and desktop versions of Nextcloud behave differently: they search your own server first, and only contact the central directory if you press a button that clearly asks for a global search. The Android app skips that choice.
The report was rated low severity and a bounty of 750.00 USD was paid.
Context
Nextcloud is a self-hosted file sync and share platform. "Self-hosted" means the software runs on a machine you or your organisation control, rather than on a company's servers. One of its features is the sharee search: when a user shares a file or folder, the client asks the server which users, groups or other principals the item can be shared with. A "client" here is any program that talks to the Nextcloud server: the website in your browser, the desktop app, or the phone app.
Nextcloud also operates a global lookup server, a central directory that can be queried to find sharees that are not present on the local instance. Think of it as a phone book shared by many Nextcloud installations: if the name you want is not in your own address book, you can ask the shared one.
The report concerns the Android client, com.nextcloud.client, and how it performs that sharee search against a Nextcloud server. com.nextcloud.client is the package name, the unique identifier Android uses for the app. The relevant server-side code is the sharees API controller in the files_sharing app, which decides whether the global lookup server is queried based on a lookup parameter.
Two terms are worth unpacking here. An API (application programming interface) is the set of addresses and rules a program uses to ask a server to do something, in the same way a restaurant menu lists what you can order and how to order it. A controller is the piece of server code that handles one such request. A parameter is an extra piece of information attached to a request, like a note on an order form saying "no onions"; here the parameter is called lookup and it is meant to say whether a global search is wanted.
Setup
The precondition is a clean Nextcloud setup on which the setting "Search global and public address book for users" is enabled. On a clean Nextcloud setup this setting is enabled, so no special configuration is needed beyond a default deployment. "On by default" means the box is already ticked when you install the software, so an administrator who never touches the settings still has it switched on.
The researcher used the Android client to search for sharees to share with. In other words, the test was done the way an ordinary phone user would do it: open the app, pick a file, choose to share it, type a name.
Finding it
The researcher noticed that when the Android client searches for a sharee, it does not pass the lookup parameter to the server. The server-side controller then falls back to treating the lookup as enabled, so the Nextcloud lookup server is queried by default.
A "fallback" is what a program does when the information it expected is missing. Imagine a form where the question "do you want the global search?" is left blank; the server has to pick an answer anyway, and in this case it picks "yes".
The relevant code is in ShareesAPIController.php, at the line the researcher links to:
https://github.com/nextcloud/server/blob/master/apps/files_sharing/lib/Controller/ShareesAPIController.php#L144
This is a link to a file in the Nextcloud source code on GitHub, which is where the project's code is published. The file name, ShareesAPIController.php, tells you it is the controller handling the sharees API, and the .php ending tells you it is written in the PHP programming language. The #L144 at the end points to line 144 of that file, the exact spot the researcher wants you to look at. The link itself is not a request you can send; it is a pointer to the code that makes the decision.
At that point the lookup value is true when the client has not supplied it, which means the request is forwarded to the global lookup server without the user asking for a global search. "Forwarded" means the Nextcloud server takes the search you typed and passes it on to the central directory as a separate request of its own.
The researcher also notes that the lookup server appeared to be down at the time of testing, and assumes that this is an error rather than intended behaviour. "Down" means the service was not responding. The researcher's assumption is that an unavailable lookup server is a fault, not a deliberate design choice.
Exploitation
Step 1: Use the Android client to search for a sharee
On a default installation with "Search global and public address book for users" enabled, the user opens the sharing dialog in the Android app and searches for a sharee. The client sends the search to the server without the lookup parameter.
This step matters because it is the whole trigger: nothing unusual is done, no special tool is used. The user simply shares a file the normal way, and the app leaves the lookup question unanswered.
Step 2: The server defaults lookup to true
Because the parameter is absent, the controller at the linked line treats lookup as true and queries the Nextcloud lookup server as part of the sharee search. The search terms the user typed are therefore sent to the central lookup server.
"Absent" means the parameter was never included in the request at all, not that it was set to false. The server cannot tell the difference between "the user did not want a global search" and "the app forgot to say", so it applies its default, and the default is to search globally.
Step 3: Observe what the lookup server receives
The lookup server can only see the origin Nextcloud server, or rather the IP address of that server. An IP address is the numeric label that identifies a machine on a network, roughly like a postal address for computers. So the central directory learns which Nextcloud installation asked, and what was searched for, but not which individual person on that installation typed it.
The researcher notes that the lookup server was down during testing, which is treated as an error rather than a design decision.
Root cause
The Android client does not send the lookup parameter when performing a sharee search, and the server-side controller defaults that parameter to true when it is missing. The result is that a global lookup happens even though the user only intended a local search. The default setting "Search global and public address book for users" being enabled on a clean setup means this happens without any administrator action.
"Root cause" means the underlying reason the problem exists, as opposed to its visible symptom. Here the symptom is search terms leaving the server; the cause is a missing value on one side and a permissive default on the other.
The web and desktop clients behave differently: they perform a local search first, and only query the lookup server if the user explicitly presses the button to search globally. The researcher adds that even that flow could be clearer about the fact that data is being sent to other systems.
Impact
Anybody sharing through the Android app leaks their sharee search terms to the Nextcloud lookup server. "Leaks" here means information leaves the place the user expected it to stay. The lookup server can only see the origin Nextcloud server, or rather the IP address of that server, so the leak is of the search terms tied to the originating instance rather than of individual user identities. The researcher's position is that this should not happen by default.
In everyday terms: the shared phone book does not learn your name, but it does learn which building asked and what name was looked up. That is still information the user did not agree to share.
Fix
The report does not describe a fix or a change that was made. The behaviour it asks for is that the Android client should not trigger a global lookup unless the user explicitly requests one, matching the web and desktop clients, which search locally first and only query the lookup server on an explicit global search.
"Explicit" is the key word: the user should have to do something deliberate, such as pressing a button labelled as a global search, rather than having it happen silently.
Variants to test
These are follow-up checks in the same spirit, for anyone who wants to look for similar problems.
- Other mobile or third-party clients against the same sharees API: send a sharee search without the lookup parameter and check whether the server forwards it to the lookup server. A positive result is a request to the lookup server that the user did not ask for.
- Other API endpoints that take an optional boolean controlling external lookups: omit the parameter and observe whether the default enables the external call. A "boolean" is a value that is either true or false. A positive result is an outbound request to a third-party service on a default configuration.
- Instances where the global address book search setting has been disabled by the administrator: repeat the Android sharee search and check whether the lookup still occurs. A positive result is a lookup despite the setting being off.
Hunting notes
This kind of bug tends to hide in the gap between clients: a server-side default that is safe for one client (the web UI, which sends the parameter explicitly) can be unsafe for another client that never sends it. During recon, look for optional parameters that gate outbound requests to third-party or central services, and check what the server does when the parameter is absent. "Recon" (reconnaissance) is the early phase of security testing where you map out how a system behaves before trying anything clever. "Gate" means the parameter acts as a switch that allows or blocks the outbound request.
Comparing the requests made by different official clients against the same endpoint is a quick way to spot the discrepancy. An "endpoint" is a specific address on a server that accepts a particular kind of request, like a single counter in a large office. If two clients talk to the same counter and one asks a question the other does not, the answers can differ in ways nobody intended.
The researcher argued that a default installation plus the Android client is enough to send user search terms to an external lookup server, and contrasted that with the web and desktop clients. "Opt-in" means the user has to actively choose to take part. The report was rated low severity and a bounty of 750.00 USD was awarded.
Glossary
- API: the set of addresses and rules a program uses to ask a server to do something, like a menu of available requests.
- Boolean: a value that can only be true or false.
- Client: a program that talks to a server, such as a browser, a desktop app or a phone app.
- Controller: the part of server code that handles one kind of request.
- Default: the value a program uses when nobody has specified one.
- Down: a service that is not responding or not running.
- Endpoint: a specific address on a server that accepts a particular kind of request.
- Explicit: done deliberately by the user, rather than happening automatically.
- Fallback: what a program does when the information it expected is missing.
- Forwarded: passed on by one system to another as a separate request.
- IP address: the numeric label identifying a machine on a network.
- Leak: information leaving the place the user expected it to stay.
- Lookup server: a central Nextcloud directory that can be queried to find sharees not present on a local installation.
- Opt-in: a behaviour the user must actively choose to enable.
- Parameter: an extra piece of information attached to a request, such as
lookup. - Recon: the early phase of security testing where you map out how a system behaves.
- Root cause: the underlying reason a problem exists, as opposed to its visible symptom.
- Self-hosted: software that runs on a machine you or your organisation control.
- Sharee search: the step where a client asks the server which users or groups a file can be shared with.
- Source code: the human-readable text that a program is built from.
- Severity: a rating of how serious a security issue is.
- Bounty: a payment made to a researcher who reports a valid security issue.