NetBSD Security Advisory 2016-005: bozohttpd CGI handlers potential remote code execution
21 April, 2016 by security-officer@netbsd.org | netbsd
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 NetBSD Security Advisory 2016-005 ================================= Topic: bozohttpd CGI handlers potential remote code execution Version: NetBSD-current: 20160415 NetBSD 7.0: affected NetBSD 6.1 - 6.1.5: affected NetBSD 6.0 - 6.0.6: affected Severity: Potential execution of arbitrary commands as httpd user Fixed: NetBSD-current: April 15, 2016 NetBSD-7 branch: April 15, 2016 NetBSD-6 branch: April 15, 2016 NetBSD-6-1 branch: April 15, 2016 NetBSD-6-0 branch: April 15, 2016 pkgsrc: bozohttpd-20160415 corrects this issue Please note that NetBSD releases prior to 6.0 are no longer supported. It is recommended that all users upgrade to a supported release. Abstract ======== Running programs as CGI handlers that were not designed to serve as such may create a vulnerability since bozohttpd would pass any arguments to the executed binary. In the worst case scenario this may lead to remote code execution. This vulnerability has been assigned CVE-2015-8212. Technical Details ================= bozohttpd supports option -C which can be used to add a CGI handler for a particular file type. It was designed to support both CGI and non-CGI aware programs to serve dynamic content. Binaries were executed using arguments from the remote client. In case of non-CGI programs this can be abused to exploit features of such programs and change their behaviour, which in worst case scenario can lead to running attacker-provided code. It was proven that arbitrary code can be executed in case of PHP-CLI as CGI handler. Solutions and Workarounds ========================= This problem only affects users which use not-CGI aware programs as CGI handlers (such as sh, CLI version of PHP etc.) directly. The simplest fix is to install the latest pkgsrc bozohttpd which fixes this problem (and run it instead of the system one). Support for non-CGI handlers has been removed as there's no way to securely handle user's requests. cd /var/tmp ftp http://nyftp.netbsd.org/pub/NetBSD-daily/<rel>/<build>/<arch>/binary/sets/base.tgz cd / tar xzpf /var/tmp/base.tgz ./usr/libexec/httpd with the following replacements: <rel> = the release version you are using <build> = the source date of the build. 20160416* and later will fit <arch> = your system's architecture The following instructions describe how to upgrade your bozohttpd binaries by updating your source tree and rebuilding and installing a new version of bozohttpd. The following instructions describe how to upgrade your bozohttpd binary by updating your source tree and rebuilding and installing a new version of bozohttpd. * NetBSD-current: Systems running NetBSD-current dated from before 2016-04-15 should be upgraded to NetBSD-current dated 2016-04-16 or later. The following files/directories need to be updated from the netbsd-current CVS branch (aka HEAD): src/libexec/httpd To update from CVS, re-build, and re-install bozohttpd: # cd src # cvs update -d -P libexec/httpd # cd libexec/httpd # make USETOOLS=no cleandir dependall # make USETOOLS=no install * NetBSD 7.*: Systems running NetBSD 7.* sources dated from before 2016-04-15 should be upgraded from NetBSD 7.* sources dated 2016-04-16 or later. The following files/directories need to be updated from the netbsd-7, netbsd-7-0 branches: src/libexec/httpd To update from CVS, re-build, and re-install bozohttpd: # cd src # cvs update -r <branch_name> -d -P libexec/httpd # cd libexec/httpd # make USETOOLS=no cleandir dependall # make USETOOLS=no install * NetBSD 6.*: Systems running NetBSD 6.* sources dated from before 2016-04-15 should be upgraded from NetBSD 6.* sources dated 2016-04-16 or later. The following files/directories need to be updated from the netbsd-6, netbsd-6-1 or netbsd-6-0 branches: src/libexec/httpd To update from CVS, re-build, and re-install bozohttpd: # cd src # cvs update -r <branch_name> -d -P libexec/httpd # cd libexec/httpd # make USETOOLS=no cleandir dependall # make USETOOLS=no install Thanks To ========= Thanks go to Mateusz Kocielski who found this problem and supplied the fixes. Revision History ================ 2016-04-21 Initial release More Information ================ Advisories may be updated as new information becomes available. The most recent version of this advisory (PGP signed) can be found at http://ftp.NetBSD.org/pub/NetBSD/security/advisories/NetBSD-SA2016-005.txt.asc Information about NetBSD and NetBSD security can be found at http://www.NetBSD.org/ and http://www.NetBSD.org/Security/ . Copyright 2016, The NetBSD Foundation, Inc. All Rights Reserved. Redistribution permitted only in full, unmodified form. $Id: NetBSD-SA2016-005.txt,v 1.1 2016/04/21 16:15:07 christos Exp $ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXGPzCAAoJEAZJc6xMSnBu/qcQALGoQF9v6u52UEBT+MhpC07A LQpU+o6S447bSduvr7mshy31zjwDM9mmqS4l+1Sk0DphuoZU9sMupYvrx4KrJ6za dcL9E8+4iZ3M+Zz6yCzdYqvN4NF+zeaPeOWMpxOjJn/YOO40V0sLCE9n74hl72OQ NqNvbsOWrxP6Wa3Qs4AIi067yFmR2HFASFiRf7bvZuiC+x/4ODtir9mgKLUOROgj qrEFhZoM5rPLEy+0oDCd9ouYuOy1iPgw2S+ssQlAtuHrIANQHPOU642clY8d4/cW aSm3HgXPhJXugDZENQtgQ8UM1HdBjH7TCJA30D+ryw8rGoNaw2P8o1+K1j6fHuOC SLsyenypB1HsKhD6TNHI0Tr15yBqtkVXwA6EHoerA92K2LmvtFZHNo0D5sQwNviu isAZB8dL0rnHFyXi+vnsHzIC4lc7BDRArVS63MBAnDewRLk9eDYt9F1zUdO6YkKH 9mbwV05iXT1+I22KDp4j/bQDTiS0Llx2yhgwFHjglVKyEkrys9Y7P5fHOqTOHDCZ 1d+y98QsS3YO8XyuZdbo2AcYoaOXectZDFt/M0Pg7UF0W/lxTomGRwZDWZPpoFn3 bou9jIq+x+AlAUPaAYaJfZwQ9T7OktwgxuOB65ly/UWQ6N6Ztl+kBRc9RduwvUfL cawd54WCtlmRWIuKeCmz =aiei -----END PGP SIGNATURE-----