Hiding in Plain Sight: A Hands-On Look at Confluence’s Widget Connector Flaw
The Widget Connector macro in Confluence did not validate the _template parameter, allowing an attacker to read arbitrary files from the server via a file:// path. In a fully vulnerable instance, the parameter could also be rendered as a Velocity template, leading to remote code execution.
Published on medium.com
Cybersecurity
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.
Context: the Widget Connector macro
Confluence ships a Widget Connector macro that lets users embed external content, such as a YouTube video, directly into a page. To render that content correctly, the macro uses a _template parameter that tells the system which layout file to use for display.
The flaw in CVE-2019-3396 is that Confluence never validates that parameter. Instead of accepting only the layout names it expects, it accepts a path to any file on the server. Point _template at /etc/passwd instead of a legitimate template, and the server reads and returns that file's contents straight to the attacker.
The vulnerability carries a CVSS score of 9.8 (Critical): it needs no special privileges, it is exploitable remotely, and in a fully vulnerable environment it escalates to remote code execution.
Setup
The researcher built an isolated lab rather than touching anything live:
- Target: Confluence 6.10.2, deployed via the Vulhub Docker project
- Host: Ubuntu in a VirtualBox VM, NAT networking
- Snapshot: taken right after setup, before any exploitation, so the environment could always be rolled back to a clean state
Isolation matters here: you want to break things in a sandbox you fully control, not anywhere near production data.
Finding it
The starting observation is the design of the macro itself. The _template parameter selects a layout file for rendering, and the server trusts whatever value it is given. Confluence never validates the value, so a local path such as /etc/passwd is read and returned like any legitimate template.
Exploitation
Step 1: confirm the target is alive
Before trying anything, the researcher confirmed the server was reachable and behaving normally:
curl -I http://localhost:8090/
This returned a standard HTTP response with Confluence's usual headers, confirming the instance was up and responding as expected. The Confluence UI was also loaded in a browser to see a normal, functioning instance before touching anything.
Step 2: obtain a valid content ID
The Widget Connector macro needs to be attached to a real page, so the first step was creating a test page and pulling its content ID through Confluence's REST API:
curl -s -u admin:admin "http://localhost:8090/rest/api/content?spaceKey=CON&title=TEST" | python3 -m json.tool | grep '"id"'
The request queries the content API for the page titled TEST in the CON space, pretty-prints the JSON and greps out the id field. That returned a content ID, which every later request needed.
Step 3: read files off the server
With a valid content ID in hand, the researcher sent a POST request to the macro preview endpoint, but instead of pointing _template at a real layout, pointed it at file:///etc/passwd:
curl -s -u admin:admin -X POST \
-H "Content-Type: application/json;charset=UTF-8" \
-H "X-Atlassian-Token: no-check" \
-d '{"contentId":"98323","macro":{"name":"widget","params":{"url":"https://www.youtube.com/watch?v=dQw4w9WgXcQ","_template":"file:///etc/passwd"},"body":""}}' \
"http://localhost:8090/rest/tinymce/1/macro/preview"
The important parts: the request targets /rest/tinymce/1/macro/preview, names the widget macro, supplies a harmless YouTube url so the macro looks like a normal embed, and sets _template to file:///etc/passwd. The X-Atlassian-Token: no-check header is included alongside the JSON content type.
The server returned the contents of /etc/passwd, system account data it should never expose to a regular user. A feature designed to preview a video embed had just handed over a file from the server's local filesystem. That is the path traversal half of the vulnerability proven.
Step 4: attempt remote code execution
In a fully vulnerable Confluence instance, _template is not just read as a file; it is rendered as an Apache Velocity template, which means it can contain executable code. The researcher built a malicious template (poc.vm) with embedded Velocity code designed to call Runtime.exec("id"), hosted it on a local Python web server, and pointed Confluence's _template parameter at it over HTTP instead of a local file path.
The result was a "widget-error" rather than code execution. To confirm the engine genuinely was not rendering templates, the researcher tested a trivial expression (${7*7}); it returned nothing, rather than 49.
This is a limitation of the prebuilt Docker image rather than a flaw in the exploit chain: the container treats local templates as plain text instead of passing them to the rendering engine, something a full, standard Confluence installation would do. The distinction matters in a write-up: when an exploit does not land, you should be able to say why, and show evidence that you checked the right thing, rather than assuming the vulnerability is not real.
Root cause
The macro's _template parameter is passed to the rendering engine without validation. Confluence does not restrict it to the layout names it expects and does not strip path traversal sequences, so the value can be a path to any file on the server. The same unvalidated value is what the Velocity engine renders, which is why the file read and the template injection share one entry point.
Impact
Chained together, the two exploit paths add up to a serious real-world risk:
- Data theft: database credentials and configuration files stored on the server become readable.
- Lateral movement: harvested credentials can open doors into other connected systems, cloud accounts, and internal networks.
- Full compromise: in a fully vulnerable deployment, remote code execution means an attacker can run arbitrary commands, deploy ransomware, or sit quietly inside the network.
- Confidentiality loss: business documents, source code, and customer data become exposed, with the legal and reputational fallout that follows.
All of that from a video embed widget. The code execution path depends on the instance actually rendering the template, which the Docker image used here did not.
Fix
Atlassian's official remediation is an upgrade to Confluence 6.6.12, 6.12.3, 6.13.3, or 6.14.2. These versions validate the _template parameter against an allowlist and strip path traversal sequences before the value ever reaches the rendering engine.
Since the Docker lab packages Confluence as a fixed image rather than something that can be patched directly, the researcher reproduced the same security outcome by disabling the Widget Connector plugin entirely:
- Logged into Confluence as admin
- Navigated to Settings → Manage Add-ons
- Searched for "widget connector"
- Disabled the plugin
Re-running the exact same path traversal request that had previously leaked /etc/passwd returned nothing. The attack surface was gone.
- Other file paths through
_template: tryfile:///etc/passwdfirst, then configuration and credential files. A positive result is the file's contents in the response body. - Remote template over HTTP: host a
.vmfile on a server you control and point_templateat it. A positive result is the server fetching your template, visible in your web server logs, and a rendered result rather thanwidget-error. - Template rendering check: send a trivial expression such as
${7*7}in the template. A positive result is49in the response, which proves the engine is rendering rather than treating the template as plain text. - Detection coverage: watch web logs for requests to the macro preview endpoint containing
file://,http://, or..in their parameters; network logs for unexpected outbound connections from the Confluence server to unfamiliar external addresses, a sign the server is fetching an attacker-hosted template; and process logs for the main Confluence application spawning shell processes likeshorbash, which it has no legitimate reason to do.
What happened, in plain words
A security researcher wanted to understand a well-known bug in Atlassian Confluence, a piece of software that companies use to build internal wikis and share documents. The bug is tracked publicly as CVE-2019-3396. A CVE is simply a catalogue number for a known security flaw, so anyone can look it up and read about it.
The flaw lives in a small convenience feature called the Widget Connector. That feature lets someone writing a wiki page drop in a YouTube video, or other content from another website, so it appears inside the page. To decide how to display that embedded content, the feature reads a setting called _template, which names a layout file on the server. The bug is that Confluence never checks what is written in that setting. If you put the name of a real layout file there, it works as intended. If you put the path of a completely different file on the server, such as the system's list of user accounts, Confluence reads that file and sends its contents back to you.
That is the whole idea. A feature meant to show a video can be tricked into handing over files from the server. The researcher reproduced this in a safe, isolated copy of Confluence, then tried to go one step further and run commands on the server, and finally showed how to close the hole in that lab.
This walkthrough follows the same steps in the same order, but explains every term from scratch. If you can use a browser, you can follow it.
The target: what Confluence and the Widget Connector are
Confluence is a web application. A web application is software that runs on a server (a computer somewhere, often in a data centre) and is used through a browser. When you open a page in your browser, your browser sends a request over the network to the server, and the server sends back a response, usually a web page. That back-and-forth is the whole basis of the web.
Inside Confluence, people write pages, much like documents in a shared notebook. A macro is a small building block you can insert into a page to add something extra: a table of contents, a status label, or, in this case, embedded content from another site. The Widget Connector macro is the one that embeds external content, such as a YouTube video, directly into a page.
To render that content correctly, the macro uses a _template parameter. A parameter is a named value you hand to a piece of software, like filling in a field on a form. Here, _template tells Confluence which layout file to use for display. A layout file is a small file on the server that describes how something should look.
The bug: Confluence never validates that parameter. Validation means checking that a value is one of the things you expect and rejecting anything else, the way a bouncer checks names against a guest list. Instead of accepting only the layout names it expects, Confluence will happily accept a path to any file on the server. A path is the address of a file on a computer, like /etc/passwd. Point _template at /etc/passwd instead of a legitimate template, and the server reads and returns that file's contents straight to the attacker.
This earned a CVSS score of 9.8 (Critical). CVSS is a standard scoring system for the severity of a security flaw, roughly from 0 to 10, where higher is worse. The score is high for a simple reason: the flaw needs no special privileges (you do not need to be an administrator), it is exploitable remotely (an attacker can do it over the network from elsewhere), and in a fully vulnerable environment it escalates to remote code execution. Remote code execution, often shortened to RCE, means an attacker can make the server run commands of their choosing, which is about as bad as it gets.
Setting it up safely
The researcher built an isolated lab rather than touching anything live:
- Target: Confluence 6.10.2, deployed via the Vulhub Docker project
- Host: Ubuntu in a VirtualBox VM, NAT networking
- Snapshot: taken right after setup, before any exploitation, so the environment could always be rolled back to a clean state
A few of those words need unpacking.
Docker is a tool for running software in containers: packaged, self-contained environments that include everything a program needs. Vulhub is a public collection of deliberately vulnerable Docker setups, made for learning and testing. It lets you spin up an old, unpatched version of software without hunting for installers.
VirtualBox is free software that lets you run a whole computer inside your computer, called a virtual machine, or VM. Ubuntu is a popular version of Linux, an operating system like Windows or macOS. NAT networking is a way of connecting a VM to the network so it can reach out, while staying somewhat separated from the rest of your network.
A snapshot is a saved copy of a VM's entire state at a moment in time. If something breaks, you restore the snapshot and you are back where you started, like a save point in a game.
This kind of isolation matters. You want to break things in a sandbox you fully control, not anywhere near production data. Production means the real systems a company depends on. A sandbox is a safe, disposable environment for experiments.
Confirming the target was alive
Before trying anything, the researcher confirmed the server was reachable and behaving normally:
curl -I http://localhost:8090/
Line by line:
curlis a command-line tool for sending requests to web servers and printing the responses. It is the browser's engine without the window.-Itells curl to ask only for the response headers, not the page body. Headers are the small pieces of information that travel with every web response, such as the server type and the date.http://localhost:8090/is the address.localhostmeans "this same computer".8090is the port, a numbered doorway on a computer through which a particular service listens. Web servers usually use port 80 or 443, but this lab uses 8090.
This returned a standard HTTP response with Confluence's usual headers, confirming the instance was up and responding as expected. The researcher also loaded the Confluence UI in a browser to see a normal, functioning instance before touching anything. UI means user interface, the part you see and click. Checking the normal state first is good practice: you need to know what "working" looks like before you can tell what "broken" looks like.
Getting a foothold: a valid content ID
The Widget Connector macro needs to be attached to a real page, so the first step was creating a test page and pulling its content ID through Confluence's REST API:
curl -s -u admin:admin "http://localhost:8090/rest/api/content?spaceKey=CON&title=TEST" | python3 -m json.tool | grep '"id"'
An API is a defined way for one program to talk to another. Think of a restaurant menu: you do not walk into the kitchen, you order from a fixed list and the kitchen responds. A REST API is a common style of web API where you ask for things using ordinary web addresses. Confluence exposes one so that other tools can read and create pages.
Line by line:
curl -ssends a request.-smeans silent: hide the progress meter so the output is clean.-u admin:adminsupplies a username and password, hereadminandadmin, in the formuser:password. This is the lab's default administrator login. In real life you would never use such credentials, and they are only here because the lab is disposable."http://localhost:8090/rest/api/content?spaceKey=CON&title=TEST"is the API address. Everything after the?is a query string, extra information sent with the request.spaceKey=CONasks for a space calledCON(a space is like a folder or section in Confluence), andtitle=TESTasks for the page titledTEST.|is a pipe. It takes the output of the command on its left and feeds it as input to the command on its right.python3 -m json.toolreformats the response. The API replies in JSON, a text format for structured data that looks like{"key": "value"}.json.toolpretty-prints it with indentation so humans can read it.grep '"id"'filters the output, keeping only lines containing"id". grep is a search tool for text.
That returned a content ID, which every later request needed. A content ID is the unique number Confluence gives each page, like a library catalogue number. Later requests must say which page they are about, and the ID is how they say it.
Exploit 1: reading files off the server
With a valid content ID in hand, the researcher sent a POST request to the macro preview endpoint, but instead of pointing _template at a real layout, pointed it at file:///etc/passwd:
curl -s -u admin:admin -X POST \
-H "Content-Type: application/json;charset=UTF-8" \
-H "X-Atlassian-Token: no-check" \
-d '{"contentId":"98323","macro":{"name":"widget","params":{"url":"https://www.youtube.com/watch?v=dQw4w9WgXcQ","_template":"file:///etc/passwd"},"body":""}}' \
"http://localhost:8090/rest/tinymce/1/macro/preview"
Line by line:
curl -s -u admin:adminis the same as before: send a request quietly, logging in as the lab administrator.-X POSTsets the HTTP method to POST. Methods are verbs for web requests. GET means "give me something"; POST means "here is some data, do something with it". This request carries data, so it is a POST.-H "Content-Type: application/json;charset=UTF-8"adds a header saying the body is JSON text.charset=UTF-8says which character encoding is used, so the server reads the text correctly.-H "X-Atlassian-Token: no-check"adds another header. A token is a short value used to prove a request is legitimate, often to stop forged requests. This particular header tells Confluence not to perform that check. It is included alongside the JSON content type.-d '...'is the body, the data being sent. Inside it:"contentId":"98323"names the page the macro belongs to, using the ID obtained earlier."macro":{"name":"widget",...}says which macro is being used: the widget macro."url":"https://www.youtube.com/watch?v=dQw4w9WgXcQ"is a harmless YouTube address, so the macro looks like a normal video embed."_template":"file:///etc/passwd"is the malicious part.file://is a URL scheme meaning "read from this computer's own disk", and/etc/passwdis a standard Linux file listing user accounts."body":""is an empty body for the macro, which is fine here.
"http://localhost:8090/rest/tinymce/1/macro/preview"is the endpoint, the specific address on the server that handles this kind of request. This one previews a macro before it is saved to a page.
The important parts: the request targets /rest/tinymce/1/macro/preview, names the widget macro, supplies a harmless YouTube url so the macro looks like a normal embed, and sets _template to file:///etc/passwd. The X-Atlassian-Token: no-check header is included alongside the JSON content type.
The server returned the contents of /etc/passwd, system account data it should never expose to a regular user. A feature designed to preview a video embed had just handed over a file from the server's local filesystem. That is the path traversal half of the vulnerability proven. Path traversal means making software read a file outside the folder it was supposed to be limited to, by supplying a path that points elsewhere.
Exploit 2: attempting remote code execution
In a fully vulnerable Confluence instance, _template is not just read as a file; it is rendered as an Apache Velocity template, which means it can contain executable code. Apache Velocity is a template engine: software that takes a template file and fills it in to produce output. Templates can contain small expressions that the engine evaluates, so if an attacker controls the template, they may control what the engine does.
The researcher built a malicious template (poc.vm) with embedded Velocity code designed to call Runtime.exec("id"), hosted it on a local Python web server, and pointed Confluence's _template parameter at it over HTTP instead of a local file path. Runtime.exec("id") is a Java instruction to run a command, and id is a Linux command that prints who the current user is. Java is a programming language, and Confluence is written in it. A proof of concept, or PoC, is a small demonstration that a flaw is real.
The result was a "widget-error" rather than code execution. To confirm the engine genuinely was not rendering templates, the researcher tested a trivial expression (${7*7}); it returned nothing, rather than 49. If the engine had been evaluating the template, it would have done the arithmetic and shown 49.
This is a limitation of the prebuilt Docker image rather than a flaw in the exploit chain: the container treats local templates as plain text instead of passing them to the rendering engine, something a full, standard Confluence installation would do. The distinction matters in a write-up: when an exploit does not land, you should be able to say why, and show evidence that you checked the right thing, rather than assuming the vulnerability is not real.
Why this matters beyond the lab
Chained together, these two exploit paths add up to a serious real-world risk:
- Data theft: database credentials and configuration files stored on the server become readable.
- Lateral movement: harvested credentials can open doors into other connected systems, cloud accounts, and internal networks.
- Full compromise: in a fully vulnerable deployment, remote code execution means an attacker can run arbitrary commands, deploy ransomware, or sit quietly inside the network.
- Confidentiality loss: business documents, source code, and customer data become exposed, with the legal and reputational fallout that follows.
A credential is a username and password, or similar proof of identity. Lateral movement means using one foothold to reach further systems, like using a key found in one room to open others. Ransomware is malicious software that locks files and demands payment. Confidentiality means keeping information private.
All of that from a video embed widget. The code execution path depends on the instance actually rendering the template, which the Docker image used here did not.
Fixing it, and proving the fix worked
Atlassian's official remediation is an upgrade to Confluence 6.6.12, 6.12.3, 6.13.3, or 6.14.2. Remediation means the proper fix. These versions validate the _template parameter against an allowlist and strip path traversal sequences before the value ever reaches the rendering engine. An allowlist is a list of permitted values; anything not on it is refused. Stripping path traversal sequences means removing the parts of a path that try to climb out of the intended folder.
Since the Docker lab packages Confluence as a fixed image rather than something that can be patched directly, the researcher reproduced the same security outcome by disabling the Widget Connector plugin entirely. A plugin (or add-on) is an optional extra that adds features to software.
- Logged into Confluence as admin
- Navigated to Settings → Manage Add-ons
- Searched for "widget connector"
- Disabled the plugin
Re-running the exact same path traversal request that had previously leaked /etc/passwd returned nothing. The attack surface was gone. Attack surface means all the ways an attacker could possibly get in; removing a feature removes its share of that surface.
What to watch for as a defender
Working through both the exploit and the fix left a clear list of what this attack looks like from a blue-team seat. Blue team means the defenders, as opposed to the attackers.
-
Web logs: requests to the macro preview endpoint containing
file://,http://, or..in their parameters. Logs are records that systems keep of what happened...in a path means "go up one folder", a classic sign of path traversal. -
Network logs: unexpected outbound connections from the Confluence server to unfamiliar external addresses, a sign the server is fetching an attacker-hosted template. Outbound means traffic leaving the server.
-
Process logs: the main Confluence application spawning shell processes like
shorbash, which it has no legitimate reason to do. A process is a running program, and a shell is a program that runs commands. -
Other file paths through
_template: tryfile:///etc/passwdfirst, then configuration and credential files. A positive result is the file's contents in the response body. -
Remote template over HTTP: host a
.vmfile on a server you control and point_templateat it. A positive result is the server fetching your template, visible in your web server logs, and a rendered result rather thanwidget-error. -
Template rendering check: send a trivial expression such as
${7*7}in the template. A positive result is49in the response, which proves the engine is rendering rather than treating the template as plain text. -
Detection coverage: watch web logs for requests to the macro preview endpoint containing
file://,http://, or..in their parameters; network logs for unexpected outbound connections from the Confluence server to unfamiliar external addresses, a sign the server is fetching an attacker-hosted template; and process logs for the main Confluence application spawning shell processes likeshorbash, which it has no legitimate reason to do.
The real takeaway
What stuck with the researcher most was not the exploit mechanics; it was how little this attack needed. No custom tooling, no obscure zero-day, no social engineering. A zero-day is a flaw nobody knew about yet, and social engineering means tricking people rather than machines. Just a single crafted request to a feature that looks completely benign, a video preview box. That is the pattern worth remembering: the most dangerous vulnerabilities often live in the features users trust least to be dangerous.
Glossary
- Allowlist: a list of values that are permitted; anything not on the list is refused.
- API: a defined way for one program to talk to another, like ordering from a menu.
- Apache Velocity: a template engine used by Confluence to turn template files into output.
- Attack surface: all the ways an attacker could possibly get into a system.
- Blue team: the defenders in a security exercise or organisation.
- Body: the data carried inside a web request or response, as opposed to its headers.
- Charset: the character encoding that tells software how to read text.
- Confidentiality: keeping information private and out of the wrong hands.
- Container: a packaged, self-contained environment for running software.
- Content ID: the unique number Confluence assigns to each page.
- Credential: a username and password, or similar proof of identity.
- CVSS: a standard scoring system for the severity of a security flaw, roughly 0 to 10.
- CVE: a public catalogue number for a known security flaw.
- Docker: a tool for running software in containers.
- Endpoint: the specific address on a server that handles a particular kind of request.
- Exploit: a technique or piece of code that takes advantage of a flaw.
- GET: an HTTP method meaning "give me something".
- grep: a command-line tool for searching text.
- Header: small pieces of information sent with a web request or response.
- HTTP: the protocol browsers and servers use to exchange requests and responses.
- Java: a programming language; Confluence is written in it.
- JSON: a text format for structured data, looking like
{"key": "value"}. - Lateral movement: using one foothold to reach further systems.
- Layout file: a small file describing how something should be displayed.
- Logs: records that systems keep of what happened.
- Macro: a small building block inserted into a Confluence page to add extra content.
- NAT networking: a way of connecting a virtual machine to a network while keeping it somewhat separated.
- Outbound: traffic leaving a system towards somewhere else.
- Parameter: a named value handed to a piece of software, like a field on a form.
- Path: the address of a file on a computer, such as
/etc/passwd. - Path traversal: making software read a file outside its intended folder by supplying a path that points elsewhere.
- Pipe: the
|symbol, which feeds one command's output into another command. - Plugin: an optional extra that adds features to software.
- Port: a numbered doorway on a computer through which a service listens.
- POST: an HTTP method meaning "here is some data, do something with it".
- Process: a running program.
- Production: the real systems a company depends on.
- Proof of concept (PoC): a small demonstration that a flaw is real.
- Query string: extra information sent with a request, after the
?in a URL. - Ransomware: malicious software that locks files and demands payment.
- Remote code execution (RCE): making a server run commands of the attacker's choosing.
- Remediation: the proper fix for a flaw.
- REST API: a common style of web API where you ask for things using ordinary web addresses.
- Sandbox: a safe, disposable environment for experiments.
- Shell: a program that runs commands.
- Snapshot: a saved copy of a virtual machine's entire state at a moment in time.
- Social engineering: tricking people rather than machines.
- Space: a folder-like section in Confluence that groups pages.
- Template engine: software that takes a template file and fills it in to produce output.
- Token: a short value used to prove a request is legitimate.
- UI: user interface, the part of software you see and click.
- URL scheme: the part of an address before
://, such ashttporfile, saying how to fetch it. - Validation: checking that a value is one of the things you expect and rejecting anything else.
- Virtual machine (VM): a whole computer running inside another computer.
- Vulhub: a public collection of deliberately vulnerable Docker setups for learning and testing.
- Zero-day: a flaw nobody knew about yet.