Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monstra 3.0.4 has Stored XSS via Uploading html file that has no extension. #459

Open
Hexife opened this issue Oct 25, 2018 · 8 comments
Open

Comments

@Hexife
Copy link

Hexife commented Oct 25, 2018

Brief of this vulnerability
In uploading process, Monstra file filter allow to upload no-extension file. If html file that has no extension, it can be executed in browser as html, and it causes of Stored XSS.

Test Environment

  • Apache/2.4.18 (Debian)
  • PHP 5.6.38-2+ubuntu16.04.1+deb.sury.org+1 (cli)

Affect version
<=3.0.4

Payload

  1. move to http://[address]:[port]/[app_path]/admin/index.php?id=filesmanager with admin credential

  2. Save php codes with no extensions. and upload it like below.

# xss
<html><head><title>Monstra XSS</title></head><body><script>alert('xss');</script></body></html>
  1. Click the uploaded file name or
    move to http://[address]:[port]/[app_path]/public/uploads/[uploaded file].
  • Monstra CMS append '.' behind to upload file name when upload file has no extension
  1. Profit!

Reason of This Vulnerability
Monstra prevent to upload php-style files using extension filer in uploading process at ./plugins/box/filesmanager/filesmanager.admin.php like below.

#./plugins/box/filesmanager/filesmanager.admin.php
    if ($_FILES['file']) {
        if ( ! in_array(File::ext($_FILES['file']['name']), $forbidden_types)) {
            $filepath = $files_path.Security::safeName(basename($_FILES['file']['name'], File::ext($_FILES['file']['name'])), null, false).'.'.File::ext($_FILES['file']['name']);
            $uploaded = move_uploaded_file($_FILES['file']['tmp_name'], $filepath);
            if ($uploaded !== false && is_file($filepath)) {
                Notification::set('success', __('File was uploaded', 'filesmanager'));
            } else {
                $error = 'File was not uploaded';
            }
        } else {
            $error = 'Forbidden file type';
        }
    } else {
        $error = 'File was not uploaded';
    }

This filtering logic checks that extension of upload file is in their blacklist($forbidden_type variable), but it is not check that extension do not exist in their logic.

Following this logic, No extension file saved with appending '.' at end of filename (e.g. xss -> xss.)

It can be executed in browser(I tested in Chrome ver 68.0.3440.106 (Official Build, 64-bit)) as html and JavaScript.

It can be executed in browser as html, and it causes of Stored XSS.

@DanielRuf
Copy link

Ouch. Very unfortunate to see that all these security issues are not resolved and no reaction from the devs.

@Hexife
Copy link
Author

Hexife commented Nov 22, 2018

I got the CVE for this vulnerability - CVE-2018-18694

@DanielRuf
Copy link

I got the CVE for this vulnerability - CVE-2018-18694

Normally it (the vuln) should not be publicly disclosed (at first). But seems the devs do not react which is bad.

@Awilum
Copy link
Member

Awilum commented Nov 22, 2018

Only Admin can access Admin Panel

@DanielRuf
Copy link

Only Admin can access Admin Panel

How can you be sure of that?

A file upload without any checks is dangerous.
Anyone who can break into admin can misuse this vuln.

This is an arbitrary file upload vulnerability.
See https://www.owasp.org/index.php/Unrestricted_File_Upload

@Awilum
Copy link
Member

Awilum commented Nov 22, 2018

Okey, I will double check this for New Monstra (Flextype) #460
Thanks for your contribution!

@Hexife
Copy link
Author

Hexife commented Nov 22, 2018

@DanielRuf Thank you for answer instead of me.

In my opinion, File upload feature MUST have the file filtering logic.

There are many possibilities for stealing admin authority.
Anyone can't convince that admin panel is only able to access with admin authority.
So, I appreciate @Awilum for understanding value of my report and applying it to your new project.

Thank you guys!

@Hexife
Copy link
Author

Hexife commented Oct 7, 2019

Also, XHTML(https://www.w3schools.com/html/html_xhtml.asp, MIME : application/xhtml+xml) file could trigger the JavaScripts.

Please consider xhtml in your next project - flextype.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants