Skip to content
RCE Write-up Advanced

Atlassian Confluence - Remote Code Execution (CVE-2023-22527)

Confluence rendered Velocity template files directly for unauthenticated users, and one template passed a user-supplied parameter into an OGNL evaluation call. An attacker could inject an OGNL expression and reach a class outside Struts' sandbox to run system commands.

Rahul Maini Follow

Published on blog.projectdiscovery.io

CVE-2023-22527 is a critical vulnerability within Atlassian's Confluence Server and Data Center. This vulnerability has the potential to permit unauthenticated attackers to inject OGNL expressions into the Confluence instance, thereby enabling the execution of arbitrary code and system commands.

Rahul Maini (@iamnoooob), Harsh Jaiswal (@rootxharsh), on blog.projectdiscovery.io

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a Velocity template passed an unauthenticated request parameter into an OGNL findValue call, and the OGNL context exposed a Struts helper that evaluates expressions outside the sandbox.

Impact

An unauthenticated attacker could execute arbitrary code and system commands on an affected Confluence instance; the text notes that a maximum expression length setting blocked longer payloads, which was bypassed by passing the argument through the parameters map.

What the attacker needed

Network access to the Confluence instance; no login required

The fix

The vulnerable template file was removed in later versions, which the text says eliminated the root cause.

How it was found

  1. Patch diff versions 8.5.3 and 8.5.4 and look for OGNL-related changes.
  2. Notice that .vm template files render directly for unauthenticated users.
  3. Find a template that passes a request parameter into findValue inside double quotes.
  4. Send a request to that template with a label value that breaks out of the getText call.
  5. Use unicode escapes to get past HTML encoding of the injected expression.
  6. Reach the OGNL tool through the request map and call findValue to run a command.

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 write-up has not been written yet. The Original tab links to the source.

Confluence builds some of its pages from template files. One template took a value from the visitor and handed it to a component that evaluates expressions, which is like passing user text to an interpreter. Because the template could be opened without logging in, anyone could send a crafted value and get their own expression evaluated, which in this case allowed running commands on the server.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Rahul Maini

View all

2 more disclosed reports, best first.

More from Atlassian

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.