Giter Club home page Giter Club logo

exploit-cve-2016-9920-new's Introduction

Roundcube 1.0.0 <= 1.2.2 Remote Code Execution

Roundcube is a widely distributed open-source webmail software used by many organizations and companies around the globe. The mirror on SourceForge, for example, counts more than 260,000 downloads in the last 12 months which is only a small fraction of the actual users. Once Roundcube is installed on a server, it provides a web interface for authenticated users to send and receive emails with their web browser.

In Roundcube 1.2.2, and earlier, user-controlled input flows unsanitized into the fifth argument of a call to PHP's built-in function mail() which is documented as security critical. The problem is that the invocation of the mail() function will cause PHP to execute the sendmail program. The fifth argument allows to pass arguments to this execution which allows a configuration of sendmail. Since sendmail offers the -X option to log all mail traffic in a file, an attacker can abuse this option and spawn a malicious PHP file in the webroot directory of the attacked server. The following code lines trigger the vulnerability.

Requirements

The vulnerability has the following requirements for exploitation:

  • Roundcube must be configured to use PHP’s mail() function (by default, if no SMTP was specified [1])
  • PHP’s mail() function is configured to use sendmail (by default, see sendmail_path [2])
  • PHP is configured to have safe_mode turned off (by default, see safe_mode [3])
  • An attacker must know or guess the absolute path of the webroot

These requirements are not particular demanding which in turn means that there were a lot of vulnerable systems in the wild.

Vulnerable environment

To setup a vulnerable environment for your test you will need Docker installed, and just run the following command:

docker build -t vuln/cve-2016-9920 .
docker run --rm -it -p 80:80 vuln/cve-2016-9920

And it will spawn a vulnerable web application on your host on 80 port

Vulnerable code

In Roundcube 1.2.2 and earlier, user-controlled input flows unsanitized into the fifth argument of a call to PHP’s built-in function mail() which is documented as critical in terms of security. The problem is that the invocation of the mail() function will cause PHP to execute the sendmail program. The fifth argument allows passing additional parameters to this execution which allows a configuration of sendmail. Since sendmail offers the -X option to log all mail traffic in a file, an attacker can abuse this option and spawn a malicious PHP file in the webroot directory of the attacked server. Although this vulnerability is rare and not widely known, RIPS detected it within seconds. [4]

Exploit

To exploit this target just run:

./exploit.py --host HOST --user USERNAME --pwd PASSWORD --path PATH --www_path WEB_DIRECTORY

If you are using this vulnerable image, you can just run:

./exploit.py --host 127.0.0.1 --user username --pwd password --path roundcube --www_path "/var/www/html/roundcube"

After the exploitation, a file called backdoor.php will be stored on the root folder of the web directory. And the exploit will drop you a shell where you can send commands to the backdoor:

./exploit.py --host 127.0.0.1 --user username --pwd password --path roundcube --www_path "/var/www/html/roundcube"
[+] CVE-2016-9920 exploit by t0kx
[+] Exploiting 127.0.0.1
[+] Target exploited, acessing shell at http://127.0.0.1/roundcube/backdoor.php
[+] Running whoami: www-data
[+] Done

Credits

This flaw was found by Robin Peraglie [4]. The main text and the idea of this education stuff was created by opsxcq.

Disclaimer

This or previous program is for Educational purpose ONLY. Do not use it without permission. The usual disclaimer applies, especially the fact that me (t0kx) is not liable for any damages caused by direct or indirect use of the information or functionality provided by these programs. The author or any Internet provider bears NO responsibility for content or misuse of these programs or any derivatives thereof. By using these programs you accept the fact that any damage (dataloss, system crash, system compromise, etc.) caused by the use of these programs is not t0kx's responsibility.

Links

exploit-cve-2016-9920-new's People

Contributors

t0kx avatar baihliu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.