CVE-2013-4259: Race Condition
runner/connectionplugins/ssh.py in Ansible before 1.2.3, when using ControlPersist, allows local users to redirect a ssh session via a symlink attack on a socket file with a predictable name in /tmp/.
Other sources
by default, ansible try to create a ControlMaster file in a predictible location in /tmp. This is vulnerable to a ssh socket injection attack like this :
~ $ sudo ln -s /tmp/ansible-ssh-elspeth.example.org-22-misc /tmp/ansible-ssh-sisay.example.org-22-misc
~ $ ansible -i 'elspeth.example.org,sisay.example.org' all -m shell -u misc -a hostname elspeth.example.org | success | rc=0 >> elspeth.example.org
sisay.example.org | success | rc=0 >> elspeth.example.org
I also did a test without using root, that's the same. Based on this attack, someone could divert the ssh connexion to another server, make it connect to a server under the control of attacker, and steal configuration file ( with passwords ), or steal password with a fake sudo ( since ansible can also use sudo )
Please note that you need to : - disable selinux setenforce 0
- disable latest protection from the kernel
sysctl -w fs.protectedsymlinks=0 sysctl -w fs.protectedhardlinks=0
to make sure this work. I didn't found how/where ssh control the socket file for suitability, maybe it should
I am not sure what could be a good fix. I do have a patch that put the socket in $XDGRUNTIMEDIR but it is a very weak mitigation technique that do not work on older platform such as RHEL 6.
Another solution would be to make sure the socket is created in specific temporary directory, but this could make the software much slower.
And checking if the socket exist first is prone to race condition.
Upstream was not contacted yet, and plan to release 1.3 around 2 weeks. Issue is not public ( but quite easy to spot )
— Red Hat
runner/connectionplugins/ssh.py in Ansible before 1.2.3, when using ControlPersist, allows local users to redirect a ssh session via a symlink attack on a socket file with a predictable name in /tmp/.
— MITRE
Affected Software
Remediation
Patch Available
Event History
Frequently Asked Questions
What is the severity of CVE-2013-4259?
CVE-2013-4259 has a moderate severity due to the potential for local users to conduct symlink attacks.
How do I fix CVE-2013-4259?
To fix CVE-2013-4259, upgrade to Ansible version 1.2.3 or later.
What versions of Ansible are affected by CVE-2013-4259?
CVE-2013-4259 affects Ansible versions prior to 1.2.3.
What is the impact of CVE-2013-4259?
The impact of CVE-2013-4259 allows local users to redirect SSH sessions, compromising session integrity.
Is there a workaround for CVE-2013-4259?
A potential workaround for CVE-2013-4259 is to configure a different socket file location than the predictable '/tmp/'.