GHSL-2021-1007: SQL Injection and insufficient permission control in Nextcloud Android app - CVE-2021-43863, CVE-2021-41166
The Nextcloud Android app exported content providers without proper permission checks, allowing a malicious app on the same device to perform SQL injection and bypass read permissions. An attacker could read sensitive data from the app's database, including share tokens, and access cached thumbnails.
Originally disclosed on GitHub Security Lab
The Nextcloud Android app uses content providers to manage its data. The providers FileContentProvider and DiskLruImageCacheFileProvider have security issues (an SQL injection, and an insufficient permission control, respectively) that allow malicious apps in the same device to access Nextcloud’s data bypassing the…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
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
Root cause
Likely the exported content providers lacked proper permission checks and used unsanitised user input in SQL queries, and one provider did not enforce a write permission.
Impact
This issue may lead to sensitive information disclosure, such as reading other tables in the database and obtaining share tokens, and may also allow reading thumbnails if they contain sensitive data.
What the attacker needed
Malicious app installed on same device; no special permissions required
The fix
The issues were fixed by the Nextcloud team.
How it was found
- Create a new file entry in the FileContentProvider.
- Use the SQL injection in the update method to set the path of the new file to the result of a subquery that extracts data from another table.
- Query the path of the modified file entry to retrieve the extracted data.
- Delete the file entry to clean up.
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.
Content providers are Android components that let apps share data with other apps. If a provider is exported and not properly protected, any app on the phone can access it. Here, a malicious app could trick the Nextcloud app into running database queries that reveal private information, like file-sharing links.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.