Skip to content
XSS Disclosed report Intermediate

HTML injection in Desktop Client

The ownCloud desktop client inserted user-controlled folder names into HTML without escaping, so a malicious folder name could inject HTML into the selective sync notification. An attacker on the same instance could share a large folder with a crafted name to display fake messages in the victim's client.

lukasreschke Follow

Originally disclosed on HackerOne

  • Fixed in 25 days
  • Disclosed after 3 months

#Problem

There are HTML injections throughout the ownCloud desktop client. A good example of this can be seen in accountsettings.cpp line 641 to 705. For reference purposes this is a trimmed down and slightly commented version of the code:

C++
void AccountSettings::refreshSelectiveSyncStatus()
{
    QString msg;
    int cnt = 0;
    foreach (Folder *folder, FolderMan::instance()->map().values()) {
    ...
        foreach(const auto &it, undecidedList) {
            ...
            QString myFolder = (it);
            ...
            QModelIndex theIndx = _model->indexForPath(folder, myFolder);
            if(theIndx.isValid()) {
                // User supplied content is appended to msg
                msg += QString::fromLatin1("<a href=\"%1?folder=%2\">%1</a>").arg(myFolder).arg(folder->alias());
            } else {
                msg += myFolder; // no link because we do not know the index yet.
            }
        }
    }

    if (msg.isEmpty()) {
       ...
    } else {
        ConfigFile cfg;
        QString info =
            !cfg.confirmExternalStorage() ? tr("There are folders that were not synchronized because they are too big: ") :
            !cfg.newBigFolderSizeLimit().first ? tr("There are folders that were not synchronized because they are external storages: ") :
            tr("There are folders that were not synchronized because they are too big or external storages: ");

        ui->selectiveSyncNotification->setText(info + msg);
        ui->selectiveSyncButtons->setVisible(false);
        ui->bigFolderUi->setVisible(true);
        shouldBeVisible = true;
    }
   ...
}

msg is assigned QString::fromLatin1("<a href=\"%1?folder=%2\">%1</a>").arg(myFolder).arg(folder->alias()); whereas myFolder and folder->alias() are user-controlled content.

If an adversary on the instance now shares a folder with someone else that exceeds the "ask for confirmation before synchronising limit" (default: 500MB) this will lead into above execution path. An example malicious folder name would be:

"><&#x2f;a><p><center><h1><strong>Important!<&#x2f;strong> Please go to nextcloud.com and relogin!<&#x2f;center><&#x2f;h1><&#x2f;p><!--

In the user interface this will lead to following view in the 2.3.x client:

spoofed-error-message.png
spoofed-error-message.png From the original on HackerOne

Note that this is also exploitable on 2.2.x. For simplicity, I went with the 2.3.x client as this is the currently developed branch. Exploit has been tested on OS X and may need adjustments for other operating systems.

#Patch proposal

This kind of vulnerability can be addressed by escaping user-supplied content, in this case one approach to patch it would be:

Diff
diff --git src/gui/accountsettings.cpp src/gui/accountsettings.cpp
index 0fb32cfbf..9c46ce9c1 100644
--- src/gui/accountsettings.cpp
+++ src/gui/accountsettings.cpp
@@ -664,7 +664,7 @@ void AccountSettings::refreshSelectiveSyncStatus()
             }
             QModelIndex theIndx = _model->indexForPath(folder, myFolder);
             if(theIndx.isValid()) {
-                msg += QString::fromLatin1("<a href=\"%1?folder=%2\">%1</a>").arg(myFolder).arg(folder->alias());
+                msg += QString::fromLatin1("<a href=\"%1?folder=%2\">%1</a>").arg(myFolder.toHtmlEscaped()).arg(folder->alias().toHtmlEscaped());
             } else {
                 msg += myFolder; // no link because we do not know the index yet.
             }

#General recommendation

A quick research on the client application shows that similar vulnerabilities can be found throughout the application. For example when hovering file names as can be seen in F161223.

I'd highly recommend thus to review the whole codebase for similar vulnerabilities.

Attachments

font-exploit.png
font-exploit.png From the original on HackerOne

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

Likely the client concatenated user-controlled folder names into an HTML string without escaping them.

Impact

An attacker could display fake messages or links in the victim's desktop client, potentially tricking them into visiting a malicious site.

What the attacker needed

Attacker has an account on the same instance; victim uses the desktop client; shared folder exceeds size limit

The fix

The client should escape user-supplied content before inserting it into HTML, as shown in the patch proposal.

How it was found

  1. An attacker on the instance shares a folder with the victim that exceeds the confirmation size limit.
  2. The victim's client processes the shared folder and reaches the selective sync notification code.
  3. The malicious folder name is inserted into the HTML message and rendered in the client UI.

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.

When a program builds a web page or message by gluing together text, it must treat user input as plain text, not as code. Here the client put a folder name directly into HTML, so a folder named with HTML tags could change what the user sees. This is called HTML injection.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by lukasreschke

View all

19 more disclosed reports, best first.

More from ownCloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.