We were recently called to fix a hacked ColdFusion server. This was a file hack. Something was appending JS code to the end of variuos .cfm files on the server. The appended code redirected the user's browser to a different site (to sell them viagra or puppies or whatever). When analysing the server we found an interesting attack vector. I say interesting because it used a technique I had not seen before that leveraged a quirky feature of ColdFusion. The end result of the hack was a layered infection that was difficult to find and resulted in the infected files coming back regardless of our lockdown efforts. If that sounds like something you are experiencing or if you are interested in ColdFusion security, read on!
To understand it you need to understand the nuances of the "missing template handler." This is a page you specify in the CF Admin. The setting looks like this:
Finally, perusing the admin settings, we noticed that "license.log" was entered as the default missing template handler. The result? All the hacker had to do was attempt to load any non-existent ColdFusion template. That's right, the hacker could simply reinfect the server by hitting /blah/1234.cfm. If 1234.cfm did not exist ColdFusion would call the "missing template handler" (license.log) as an include and execute whatever CFML it found there - in this case the code to recreate the ttextt.cfm.
Why go through all this trouble? It does seem like a good bit of trouble. If you are already able to do things like change the missing template handler and upload license.log to the server, do you really need an additional back door? I suppose the main result is a vulnerable server that is hard to disinfect. Shutting down FTP and Webdav, Patching ColdFusion, patching CKEditor, analyzing and fixing cffile code etc. - all of these might plug the original hole but none of these fixes would keep ttextt.cfm from coming back. Disabling file creation would do it but that's not an option for most ColdFusion servers which use such features regularly. Then too, the file "license.log" looks both important (ooh, it's a license file, if I delete it bad things could happen!) and innocuous (it's just a log file after all). Finally, that missing template handler is not a setting you check every day - or believe to be broken - unless you use it to do something very specific (besides just catching bad cfm requests). So it's an ingenious layered attack with entrenched lines that you have to dig through to fix.
The takeaway? If you have a file based hack on your server, be sure and check the missing template handler setting. Good luck out and may the Muse be with you.
Muse Note: I had nothing to do with this fix or the information I'm presenting here. This hack was found and fixed by Super Guru Wil Genovese (trunkful.com) who is my great friend and with whom I have the privilege to collaborate.