The StateToOptions function in msfweb in Metasploit Framework 2.4 and earlier, when running with the -D option (defanged mode), allows attackers to modify temporary environment variables before the "_Defanged" environment option is checked when processing the Exploit command.
https://exchange.xforce.ibmcloud.com/vulnerabilities/21705
http://www.securityfocus.com/bid/14455