As security practitioners, we give daily advices to our customers to increase the security level of their infrastructures. Install this tool, enable this feature, disable this function, etc. When enabled, these techniques can also be (ab)used by attackers to perform nasty actions.
PAM or Pluggable Authentication Modules is an old authentication system that is around since 1997! It allows you to extend the authentication capabilities of a system to interconnect with third party systems. PAM is available on all Linux flavours and used, amongst plenty of others, by the SSH daemon. By default, SSH allows you to authenticate via credentials or a key but they are plenty of other ways to authenticate a user. Via a centralised DB (LDAP, RADIUS, Kerberos) against a proprietary databases and much more. It can also be used to raise the security level by implemented MFA (“Multi-Factor Authentication”). In 2009(!), I already wrote a blog post to explain how to use a Yubikey as second factor via PAM.
By reading this, you can imagine that the PAM sub-system, being part of the authentication, has access to a lot of sensitive information! Here is an example of credentials leaking technique that I found in the wild recently and it’s pretty easy to implement. In many organisations, bastion hosts are used to provide access to internal resources to admins, consultants, etc. They are used to “pivot” inside the network.
If a bastion host is compromised (or a server or an admin end-point), some nasty PAM modules can be installed to automatically collect credentials. One of these modules is called “pam_steal”. This module has only 40 lines of code and, once the attacker installed this plugin, it will collect and dump credentials into a flat file. This will then be collected by the attacker. No need to sniff, to decrypt data!
When dropped on the victim’s computer, the malicious module is just enabled by adding it to the /etc/pam.d/common-auth file. To protect against this kind of attack, a good idea is to use a FIM (“File Integrity Monitor”) to detect changes performed in sensitive files like in /etc/pam.d.
Xavier Mertens (@xme)
Senior ISC Handler – Freelance Cyber Security Consultant
(c) SANS Internet Storm Center. https://isc.sans.edu Creative Commons Attribution-Noncommercial 3.0 United States License.
Source: Read More (SANS Internet Storm Center, InfoCON: green)