Lucene search

K
hackeroneFoobar7H1:1215263
HistoryJun 02, 2021 - 10:31 a.m.

Nextcloud: Download of file with arbitrary extension via injection into attachment header

2021-06-0210:31:29
foobar7
hackerone.com
$125
32

8.8 High

CVSS3

Attack Vector

NETWORK

Attack Complexity

LOW

Privileges Required

NONE

User Interaction

REQUIRED

Scope

UNCHANGED

Confidentiality Impact

HIGH

Integrity Impact

HIGH

Availability Impact

HIGH

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

6.8 Medium

CVSS2

Access Vector

NETWORK

Access Complexity

MEDIUM

Authentication

NONE

Confidentiality Impact

PARTIAL

Integrity Impact

PARTIAL

Availability Impact

PARTIAL

AV:N/AC:M/Au:N/C:P/I:P/A:P

0.003 Low

EPSS

Percentile

63.4%

Description

When downloading mail attachments, the app fails to properly escape quotes in the content disposition header. Because of this, an attacker can send a victim a file with a benign extension such as .txt or .png which when downloaded will be stored with a malicious extension such as .bat or .docm.

This vulnerability can for example be exploited in the following scenarios:

  • It allows bypassing of extension-based attachment filtering by email providers (or other intermediate email systems), as is common in many networks.
  • As the attachment is displayed as a benign file in Nextcloud, a user may incorrectly trust it to be a benign file.

POC

  • Send a mail to an email address that is connected to Nextcloud Mail with an attached file called test.bat".png.
  • open the mail -> click on the attachment icon -> click on the download icon. While Nextcloud correctly displays the file as a benign .png file, it will be downloaded as test.bat instead.

Tested with Firefox under Windows.

As alternative to .bat files (which may be prevented from executing by Microsoft Defender SmartScreen), an attacker can also send other malicious files such as for example .vbs files, as well as .docm files containing macro viruses.

Request

    GET /nextcloud/index.php/apps/mail/api/messages/26/attachment/2 HTTP/1.1
    Host: 192.168.0.101

    HTTP/1.1 200 OK
    [...]
    Content-Disposition: attachment; filename="test.bat".png"
    [...]
    Content-Type: application/octet-stream

    C:\Windows\system32\calc.exe

Solution

Quotes should be properly escaped before being inserted into the Content-Disposition header.

Impact

Offering malicious files for download, leading to code execution on the computer of the victim if they download and open the file.

8.8 High

CVSS3

Attack Vector

NETWORK

Attack Complexity

LOW

Privileges Required

NONE

User Interaction

REQUIRED

Scope

UNCHANGED

Confidentiality Impact

HIGH

Integrity Impact

HIGH

Availability Impact

HIGH

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

6.8 Medium

CVSS2

Access Vector

NETWORK

Access Complexity

MEDIUM

Authentication

NONE

Confidentiality Impact

PARTIAL

Integrity Impact

PARTIAL

Availability Impact

PARTIAL

AV:N/AC:M/Au:N/C:P/I:P/A:P

0.003 Low

EPSS

Percentile

63.4%