Nextcloud · Report #358339
File access control rules not enforced on image files
How it was found
-
Installed Nextcloud from Snap package (version 13.0.2snap1, revision 6916) on fresh Ubuntu 18.04 LTS install.
-
Installed and enabled Files access control (v1.3.0) and Files automated tagging (v1.3.0) apps.
-
As an administrator created an invisible collaborative tag
Secret. -
Added Files automated tagging rule to add the
Secrettag for all files with user membership ofadmingroup. -
Added Files access control rule restricting the access for all files with the
Secrettag and user who is not a member ofadmingroup. -
Created unprivileged user
user. -
Accessed the
adminaccount from WebDAV interface (in order to avoid generating automatic file previews) and created the following files/folders on the server:folder: Secret_Folder folder: Secret_Folder/Secret_Subfolder file: Secret_Folder/Secret_Subfolder/Secret_Picture.jpeg file: Secret_Folder/Secret_Subfolder/Secret_Text.txt -
Shared the
Secret_Folderfromadminuser to the unprivileged useruserwith no edit rights. -
From client computer authorized as the unprivileged user
userand used WebDAV search to recursively list all files with their MIME types with the followingcurlcommand: {F302611}. This command downloaded the list of all shared files as an xml file: {F302614}. -
Identified an image file
Secret_Folder/Secret_Subfolder/Secret_Picture.jpegfrom the file list and accessed its contents through files preview API with the followingcurlcommand:curl -u user 'https://test.frp.lv/index.php/apps/files/api/v1/thumbnail/1212/750/Secret_Folder/Secret_Subfolder/Secret_Picture.jpeg' -H 'Content-Type: application/x-www-form-urlencoded' > Secret_Picture.jpeg
Impact
-
The unauthorized attacker can list all files recursively for an unlimited depth, even if explicitly denied by
Files access controlrules. -
The unauthorized attacker can view the contents of all denied image files up to their maximum resolution. It is up to the attacker to choose the required image resolution (1024 x 768 in the example) and construct corresponding
GETquery through image preview API. Note that it is not even required for the file owner to use web interface and preview the protected image files before the attack. The corresponding image preview files are generated on the server upon the request of the attacker. -
If the file owner has logged in Nextcloud web interface and browsed the protected files, thus automatically rendering thumbnail previews, it also becomes possible for the attacker to access previews of protected text files with the following
curlcommand referencing the text file from the example, choosing 4096x4096 resolution:curl -u user 'https://test.frp.lv/index.php/apps/files/api/v1/thumbnail/4096/4096/Secret_Folder/Secret_Subfolder/Secret_Text.txt' -H 'Content-Type: application/x-www-form-urlencoded' > Secret_Text.png
The obtained preview image can contain critical information that should have been protected - see example of downloaded preview below: {F302628}