Authentication Bypass in the Rest API via XSS on Safari and Chrome (iOS/iPhone only)
Confluence's file upload feature allowed uploading an HTML file with a non-executable extension and a crafted MIME type (video/mp2t) that WebKit-based mobile browsers interpret as HTML, leading to stored XSS. An attacker could exploit this to perform actions as the victim, such as creating a personal access token, via a crafted link.
- Accepted in 7 days
- Fixed in 5 months
- Disclosed after 6 months
Summary by Atlassian
Cross-Site Scripting Vulnerability in Confluence on Safari or Chrome (iOS/iPhone)
Summary by c4v4r0n
This bug as founded using source code analysis of the Confluence application, but I developed a browser fuzzer to find how to exploit it.
Report details
-
Submitted
22 Jan 2025 02:41:49 UTC
-
Target Location
Confluence Data Center -
Target category
Other
-
VRT
Cross-Site Scripting (XSS) > Stored > CSRF/URL-Based
-
Priority
P2
-
Bug URL
confluence.local/download/attachments/{{ID}}/{{FileName}} -
Description
Authentication Bypass in the Rest API via XSS on Safari and Chrome (iOS/iPhone only)
CVSS: High 7.9 https://www.first.org/cvss/calculator/3.0#CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:L
This bug only affects users that access Confluence through an iPhone or iPad using either Safari or Chrome.
This is a new research I'm doing in content-type, by now I found that is possible to bypass your current deny-list approach using a content-type that can interpret HTML in WebKit, this should affect the users that log in Confluence using a iPhone, this is a proof that is really hard to implement a deny-list and the focus should be in a more restrict approach like an allow-list.
Because this is a new research, I request that this XSS vector don't get disclosed before I publish my research.
Introduction
This bug occurs because of a problem in the way that Confluence handles files that are uploaded in the comment section of any personal page.
When we upload a file, Confluence will take as a parameter the filename (with the extension) and its mime-type in the file upload request "POST /plugins/drag-and-drop/upload.action".
If I try to upload a HTML file:
As we can see, the application allows us to upload this file, it gets stored, and we receive a URL to it.
But if we try to access this URL in any browser, the file will be downloaded and not loaded by the browser as HTML.
We can check the HTTP request to understand why this file is being downloaded.
As we can see, the application is responding with the header "Content-Disposition: attachment" This will force the browser to download the file and not show it. Also, we can see the header "X-Content-Type-Options: nosniff", this header will not allow the browser to "guess" the content-type and the browser will be forced to use the Content-Type header from the HTTP response to parse the content.
But if we upload a .txt file we are able to see it without downloading.
If we look at this request through a proxy, we can see that the "Content-Disposition" header is now using the inline value. This allows the browser to show the file if it can understand the content-type (in this case text/plain).
Code Review and how Confluence parses mime-types
The way Confluence choose if the Content-Disposition should be inline or attachment comes from the method guessContentDispositionHeader() that can be found in the com.atlassian.http_atlassian-http-4.1.0.jar file in the path /com/atlassian/http/mime/ContentDispositionHeaderGuesser.class
This method will call this.isExecutableContent() with the filename and with the mime-type that we saved the file. Based on the return of this method, the application will decide if the Content-Disposition should be attachment or inline.
public String guessContentDispositionHeader(String fileName, String mimeContentType, String userAgent) { DownloadPolicy downloadPolicy = this.downloadPolicyProvider.getPolicy(); boolean forceDownload = false; if (downloadPolicy.equals(DownloadPolicy.Insecure)) { return "inline"; } else if (!downloadPolicy.equals(DownloadPolicy.Secure) && !downloadPolicy.equals(DownloadPolicy.WhiteList)) { forceDownload = this.isExecutableContent(fileName, mimeContentType); if (BrowserUtils.isIE(userAgent) && this.isTextContentType(mimeContentType)) { forceDownload = true; } if (forceDownload && log.isDebugEnabled()) { log.debug("\"" + fileName + "\" (" + mimeContentType + ") presents as executable content, forcing download."); } return forceDownload ? "attachment" : "inline"; } else { return "attachment"; } }The method isExecutableContent() is just a wrapper to hostileExtensionDetector.isExecutableContent().
private boolean isExecutableContent(String name, String mimeContentType) { return this.hostileExtensionDetector.isExecutableContent(name, mimeContentType); }Then hostileExtensionDetector.isExecutableContent() will call two functions, isExecutableFileExtension() and isExecutableContentType(). To be able to reach the Content-Disposition inline, both should return false.
public boolean isExecutableContent(String fileName, String contentType) { return this.isExecutableFileExtension(fileName) || this.isExecutableContentType(contentType); }First, isExecutableFileExtension() will compare the file name with an array of malicious file extensions; if the filename contains any of the file extensions in the array, the function will return true, and the Content-Disposition will be set to attachment. To bypass this check we can use any other file extensions like .png for example; this will not affect the web browser behavior.
The isExecutableContentType() function will do something similar and compare the file mime-type with a list of malicious types and return true if it finds any match.
public boolean isExecutableContentType(String contentType) { boolean isExecutableContentType = false; if (StringUtils.isBlank(contentType)) { return true; } else if (!VALID_MIME_TYPE.matcher(contentType.toLowerCase()).matches()) { return true; } else { for(String executableContentType : this.executableContentTypes) { if (contentType.toLowerCase(Locale.US).contains(executableContentType)) { isExecutableContentType = true; break; } } return isExecutableContentType; } }This is a list with all the mime-types Confluence understands as bad.
0 = "image/svg+xml" 1 = "application/pdf" 2 = "image/svg-xml" 3 = "message/rfc822" 4 = "multipart/x-mixed-replace" 5 = "text/xml-external-parsed-entity" 6 = "text/vtt" 7 = "application/atom+xml" 8 = "text/webviewhtml" 9 = "application/x-shockwave-flash" 10 = "text/html-sandboxed" 11 = "text/html" 12 = "application/rdf+xml" 13 = "application/octet-stream" 14 = "text/vnd.wap.wml" 15 = "text/xsl" 16 = "video/x-flv" 17 = "application/vnd.wap.xhtml+xml" 18 = "application/mathml+xml" 19 = "application/xml" 20 = "application/xml-dtd" 21 = "application/x-cab" 22 = "text/xml" 23 = "application/futuresplash" 24 = "application/xml-external-parsed-entity" 25 = "text/rdf" 26 = "text/xhtml" 27 = "application/xhtml+xml"So to bypass this we just need to use a different file extension and a different mime-type
video/mp2t and PoC
During my research in mime-types I found that the video/mp2t is a mime-type that is interpreted as HTML by WebKit mobile based browsers (Safari and Chrome in iOS), this is just one example that a deny-list is not the best approach for this situation, different devices may support different mime-types that can be interpreted as HTML or XML.
To exploit this bug we need to create an HTML file using any file extension that is not in the deny-list, I will use .png.
When uploading the file, we need to intercept the request and change the mimeType GET parameter to video/mp2t.
The file is uploaded to http://localhost:8090/download/attachments/163936/alert.png?version=2&modificationDate=1737506251465&api=v2 (to access from my iPhone device, I should use the 192.168.0.108 IP address). Now I need to open this link using an iPhone or another iOS-based device. I'm using the iPhone virtual machine that comes with XCode, but I also tested in a real iPhone 15, and it worked as well.
Authentication Bypass using Personal Access Token (PAT)
As per the documentation.
"Personal access tokens (PATs) are a secure way to use scripts and integrate external applications with your Atlassian application. If an external system is compromised, you simply revoke the token instead of changing the password and consequently changing it in all scripts and integrations.
Personal access tokens are a safe alternative to using username and password for authentication with various services. "
We can use a PAT to authenticate in the Confluence API.
A PAT token is created with a request to "POST /rest/pat/latest/tokens".
We then can use this token in a curl request to access the Confluence rest API.
curl -H 'Authorization: Bearer NDMxMTI2NjM3Nzk2OhAVOxGM+a7vpoX5HRsw8yOVLk2/' http://localhost:8090/rest/api/user?username=admin ; echoBecause we can use the PAT token to authenticate in Confluence, it is a good target for our XSS payload.
PoC
Our PoC will create a new PAT token in the victim account and show it in a alert box, but of course we could easly send this PAT token to a remote server controled by us.
First, we need to create a .png file to store our XSS payload. I will call mine token.png
token.png:
<script> (async () => { const rawResponse = await fetch("/rest/pat/latest/tokens", { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, method: "POST", body: JSON.stringify({name:"Backdoor", expirationDuration:90}) }); const content = await rawResponse.json(); alert(content.rawToken); })(); </script>Then we need to upload this file and change the mimeType parameter to video/mp2t.
Select our payload and click send. Now change the mimeType parameter to video/mp2t using a proxy.
As we can see, the file is saved without any problem. The URL we need to send to the victim iPhone's is http://192.168.0.108:8090/download/attachments/163936/token.png?version=1&modificationDate=1737508504777&api=v2
And when the victim opens the link, a new PAT token will appear in the alert box.
Below is a PoC video showing the victim opening the malicious link in an iPhone and a new PAT token being created in his account.
Context
Confluence Data Center lets users attach files to pages, including personal pages, through the comment section. When a file is uploaded, Confluence records the filename (with its extension) and its MIME type, and later serves the stored file from a download URL of the form:
[redacted]/download/attachments/{{ID}}/{{FileName}}
Whether the browser displays the file or downloads it depends on the Content-Disposition header that Confluence returns. The researcher found that this decision can be influenced by the uploader, and that on iPhone or iPad in Safari or Chrome the resulting file can be rendered as HTML, which turns a stored file into a stored XSS. The report was submitted to Atlassian's Bugcrowd programme on 22 January 2025, rated P2 with a CVSS of High 7.9.
The researcher notes that the bug was found through source code analysis of Confluence, and that a browser fuzzer was developed to work out how to exploit it. The report also states that the bug only affects users who access Confluence through an iPhone or iPad using either Safari or Chrome.
Setup
The researcher worked against a local Confluence instance reachable at localhost:8090, and from an iPhone used the LAN address [redacted]. Testing was done in the iPhone virtual machine that ships with Xcode, and also on a real iPhone 15, where the researcher reports it worked as well.
Two capabilities are needed for the full chain:
- The ability to upload a file to the comment section of a personal page, and to intercept the upload request with a proxy so the
mimeTypeparameter can be changed. - A victim who opens the resulting download link on an iOS device in Safari or Chrome.
The second stage of the attack targets Confluence's REST API, which can be authenticated with a Personal Access Token (PAT). The report quotes the Atlassian documentation describing PATs as a secure way for scripts and external applications to integrate with Atlassian applications, and as an alternative to username and password authentication. A PAT is created with a request to POST /rest/pat/latest/tokens.
Finding it
When a file is uploaded, Confluence takes the filename (with extension) and its MIME type from the file upload request POST /plugins/drag-and-drop/upload.action. Uploading an HTML file is permitted: the file is stored and a URL is returned. Accessing that URL in a browser, however, downloads the file rather than rendering it as HTML.
Inspecting the HTTP response explains why. Confluence returns Content-Disposition: attachment, which forces a download, together with X-Content-Type-Options: nosniff, which stops the browser guessing the content type and forces it to use the Content-Type from the response.
A .txt file behaves differently: it can be viewed without being downloaded. Through a proxy, the response for the text file shows Content-Disposition using the inline value, which lets the browser display the file when it understands the content type, in this case text/plain.
That difference is the thread the researcher pulled: the disposition is computed from the filename and the stored MIME type, both of which the uploader controls.
Exploitation
Step 1: understand how the disposition is chosen
The decision between inline and attachment comes from the method guessContentDispositionHeader(), found in com.atlassian.http_atlassian-http-4.1.0.jar at the path /com/atlassian/http/mime/ContentDispositionHeaderGuesser.class:
public String guessContentDispositionHeader(String fileName, String mimeContentType, String userAgent) {
DownloadPolicy downloadPolicy = this.downloadPolicyProvider.getPolicy();
boolean forceDownload = false;
if (downloadPolicy.equals(DownloadPolicy.Insecure)) {
return "inline";
} else if (!downloadPolicy.equals(DownloadPolicy.Secure) && !downloadPolicy.equals(DownloadPolicy.WhiteList)) {
forceDownload = this.isExecutableContent(fileName, mimeContentType);
if (BrowserUtils.isIE(userAgent) && this.isTextContentType(mimeContentType)) {
forceDownload = true;
}
if (forceDownload && log.isDebugEnabled()) {
log.debug("\"" + fileName + "\" (" + mimeContentType + ") presents as executable content, forcing download.");
}
return forceDownload ? "attachment" : "inline";
} else {
return "attachment";
}
}
The method calls this.isExecutableContent() with the filename and the stored MIME type, and the return value decides between attachment and inline. isExecutableContent() is a wrapper around hostileExtensionDetector.isExecutableContent():
private boolean isExecutableContent(String name, String mimeContentType) {
return this.hostileExtensionDetector.isExecutableContent(name, mimeContentType);
}
That in turn calls two functions, isExecutableFileExtension() and isExecutableContentType(). To reach Content-Disposition: inline, both must return false:
public boolean isExecutableContent(String fileName, String contentType) {
return this.isExecutableFileExtension(fileName) || this.isExecutableContentType(contentType);
}
Step 2: get past the extension check
isExecutableFileExtension() compares the filename against an array of malicious file extensions and returns true if the filename contains any of them, which would force attachment. Any extension outside that array avoids the check; the researcher used .png, noting that this does not affect browser behaviour.
Step 3: get past the MIME type check
isExecutableContentType() compares the file's MIME type against a list of malicious types and returns true on a match:
public boolean isExecutableContentType(String contentType) {
boolean isExecutableContentType = false;
if (StringUtils.isBlank(contentType)) {
return true;
} else if (!VALID_MIME_TYPE.matcher(contentType.toLowerCase()).matches()) {
return true;
} else {
for(String executableContentType : this.executableContentTypes) {
if (contentType.toLowerCase(Locale.US).contains(executableContentType)) {
isExecutableContentType = true;
break;
}
}
return isExecutableContentType;
}
}
The list of MIME types Confluence treats as bad, as printed in the report, is:
0 = "image/svg+xml"
1 = "application/pdf"
2 = "image/svg-xml"
3 = "message/rfc822"
4 = "multipart/x-mixed-replace"
5 = "text/xml-external-parsed-entity"
6 = "text/vtt"
7 = "application/atom+xml"
8 = "text/webviewhtml"
9 = "application/x-shockwave-flash"
10 = "text/html-sandboxed"
11 = "text/html"
12 = "application/rdf+xml"
13 = "application/octet-stream"
14 = "text/vnd.wap.wml"
15 = "text/xsl"
16 = "video/x-flv"
17 = "application/vnd.wap.xhtml+xml"
18 = "application/mathml+xml"
19 = "application/xml"
20 = "application/xml-dtd"
21 = "application/x-cab"
22 = "text/xml"
23 = "application/futuresplash"
24 = "application/xml-external-parsed-entity"
25 = "text/rdf"
26 = "text/xhtml"
27 = "application/xhtml+xml"
To bypass this check, a different file extension and a different MIME type are enough.
Step 4: find a MIME type WebKit renders as HTML
During research into MIME types, the researcher found that video/mp2t is interpreted as HTML by WebKit-based mobile browsers, meaning Safari and Chrome on iOS. The report stresses that this is just one example, and that a deny-list is hard to implement, with the focus better placed on a more restrictive approach such as an allow-list.
Step 5: upload the payload with a spoofed MIME type
The exploit needs an HTML file with any extension not on the deny-list; the researcher used .png. The file is uploaded through the comment section, and the request is intercepted so the mimeType GET parameter can be changed to video/mp2t.
In the first test the file was uploaded to:
http://localhost:8090/download/attachments/163936/alert.png?version=2&modificationDate=1737506251465&api=v2
To open it from the iPhone, the [redacted] address was used instead of localhost. Opening the link on an iOS device rendered the file as HTML.
Step 6: build the payload that abuses PAT creation
Because a PAT can be used to authenticate against the Confluence API, it is a good target for the XSS payload. The proof of concept creates a new PAT in the victim's account and shows it in an alert box; the researcher notes that the token could just as easily be sent to a remote server controlled by the attacker.
The payload is stored in a file called token.png:
<script>
(async () => {
const rawResponse = await fetch("/rest/pat/latest/tokens",
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify({name:"Backdoor", expirationDuration:90})
});
const content = await rawResponse.json();
alert(content.rawToken);
})();
</script>
The script sends a POST to /rest/pat/latest/tokens with a JSON body naming the token Backdoor and setting expirationDuration to 90, then reads rawToken from the JSON response and displays it.
Step 7: upload and rewrite the MIME type
The payload file is selected and sent, then the mimeType parameter is changed to video/mp2t using a proxy. The file is saved without any problem, and the URL to send to the victim's iPhone is:
http://[redacted]:8090/download/attachments/163936/token.png?version=1&modificationDate=1737508504777&api=v2
When the victim opens the link, a new PAT token appears in the alert box. The report links a PoC video.
Step 8: use the stolen token
With the token in hand, the attacker can authenticate to the Confluence REST API. The report shows this with a curl request:
curl -H 'Authorization: Bearer [redacted]' http://localhost:8090/rest/api/user?username=admin ; echo
Root cause
The disposition of an uploaded file is decided by a deny-list. guessContentDispositionHeader() asks hostileExtensionDetector.isExecutableContent() whether the file is executable, and that check is the OR of an extension deny-list and a MIME type deny-list. Both inputs come from the upload request, so an attacker who picks an extension and a MIME type outside the lists gets Content-Disposition: inline.
The deny-list contains text/html and a set of XML and related types, but not video/mp2t, which WebKit on iOS interprets as HTML. The researcher's conclusion is that a deny-list is very hard to get right, and that the focus should be on a more restrictive approach such as an allow-list. The report also notes that different devices may support different MIME types that can be interpreted as HTML or XML.
Impact
The bug only affects users who access Confluence through an iPhone or iPad using Safari or Chrome. For those users, an attacker who can upload a file to a comment section can get script execution in the Confluence origin when the victim opens the download link. In the demonstrated chain, the script creates a Personal Access Token in the victim's account through POST /rest/pat/latest/tokens and shows it in an alert box; the researcher notes it could instead be sent to an attacker-controlled server. The report's PoC shows the token in an alert box and states that sending it to an attacker-controlled server would be easy.
The CVSS vector given in the report is:
CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:L
That is, network attack vector, high attack complexity, low privileges required, user interaction required, changed scope, high confidentiality and integrity impact, and low availability impact.
Fix
The report does not describe a fix or a change made by Atlassian. The researcher's recommendation is to move away from the deny-list approach towards a more restrictive one, such as an allow-list.
Variants to test
- Other MIME types rendered as HTML by WebKit. Upload an HTML file with an extension outside the deny-list and set
mimeTypeto candidate types one at a time, then open the download URL on an iOS device. A positive result is the file rendering as HTML rather than downloading, withContent-Disposition: inlinein the response. - Other browsers and platforms. The report only establishes the behaviour for Safari and Chrome on iOS. Trying the same upload and MIME type rewrite on other mobile browsers and platforms tests whether the rendering behaviour is broader than WebKit on iOS.
- Other upload surfaces. The report describes uploads in the comment section of a personal page through
POST /plugins/drag-and-drop/upload.action. Testing other places where Confluence stores and serves user-supplied files would show whether the same disposition logic applies there. - Other token and API endpoints. The PoC targets
POST /rest/pat/latest/tokens. Any endpoint that returns credentials or performs sensitive actions with the victim's session is worth testing as a payload target; a positive result is a response containing a usable secret or a state change visible in the victim's account. - Filename edge cases against the extension check. The extension check returns true if the filename contains any listed extension. Trying filenames that combine an allowed extension with a listed one, or that use unusual casing or separators, tests how the containment check behaves; a positive result is
Content-Disposition: inlinefor a file the browser still renders as HTML.
What happened, in plain words
Confluence is a product made by Atlassian. Teams use it as a shared workspace: they write pages, comment on them, and attach files to them. Confluence Data Center is the version that a company installs and runs on its own servers rather than renting from Atlassian.
One ordinary feature of Confluence is that you can attach a file to a page, including a personal page, by dropping it into the comment section. When you do that, Confluence saves two things about your file: its name (including the part after the dot, such as .png or .txt) and its MIME type. A MIME type is a short label that says what kind of content a file holds, for example text/plain for plain text or image/png for a picture. Browsers and servers use these labels to decide how to treat a file.
Later, when someone opens the link to that stored file, Confluence has to tell the browser whether to show the file inside the browser window or to download it to disk. It does this with a response header called Content-Disposition. A header is a small line of extra information that a server sends alongside the actual content. Content-Disposition: attachment means "save this to disk", and Content-Disposition: inline means "show this in the window".
The researcher found that the person uploading the file can influence that decision, and that on an iPhone or iPad using Safari or Chrome the resulting file can be treated as a web page and run as a script. That turns a harmless-looking stored file into a stored XSS. XSS, short for Cross-Site Scripting, means getting your own code to run inside someone else's website, in that site's context, as if the site itself had written it. "Stored" means the malicious content is saved on the server first and runs later, whenever a victim opens it.
The report was submitted to Atlassian's Bugcrowd programme on 22 January 2025, rated P2 with a CVSS of High 7.9. CVSS is a standard scoring system for the severity of a security flaw, and a bounty is a reward a company pays to someone who reports a problem responsibly.
The researcher says the bug was found through source code analysis of Confluence, meaning by reading the program's own code, and that a browser fuzzer was developed to work out how to exploit it. A fuzzer is a tool that tries many variations automatically to see which one gets through. The report also states that the bug only affects users who access Confluence through an iPhone or iPad using either Safari or Chrome.
Setup
The researcher worked against a local Confluence instance reachable at localhost:8090. "Local" means the copy of Confluence was running on the researcher's own computer; localhost is the name a computer uses for itself, and 8090 is the port, a numbered door on that computer where the web server listens. From the iPhone, the same machine was reached at [redacted], which is its address on the local network. Testing was done in the iPhone virtual machine that ships with Xcode, Apple's development tool, and also on a real iPhone 15, where the researcher reports it worked as well.
Two capabilities are needed for the full chain:
- The ability to upload a file to the comment section of a personal page, and to intercept the upload request with a proxy so the
mimeTypeparameter can be changed. A proxy is a tool that sits between your browser and the server and lets you look at and edit the traffic going back and forth. A parameter is a named value carried in a request, here the one that tells Confluence what MIME type to record. - A victim who opens the resulting download link on an iOS device in Safari or Chrome.
The second stage of the attack targets Confluence's REST API. An API is a set of addresses a program exposes so that other programs can talk to it, rather than a human clicking around in a browser. REST is a common style for such APIs, where each address represents a thing and standard HTTP methods like POST are used to act on it. Confluence's REST API can be authenticated with a Personal Access Token (PAT). A token is a long random string that acts like a password for a program: whoever holds it can act as the account it belongs to. The report quotes the Atlassian documentation describing PATs as a secure way for scripts and external applications to integrate with Atlassian applications, and as an alternative to username and password authentication. A PAT is created with a request to POST /rest/pat/latest/tokens.
Finding it
When a file is uploaded, Confluence takes the filename (with extension) and its MIME type from the file upload request POST /plugins/drag-and-drop/upload.action. In HTTP terms, POST is the method used to send data to the server, and the path after it is the address on the server that handles it. Uploading an HTML file is permitted: the file is stored and a URL is returned. Accessing that URL in a browser, however, downloads the file rather than rendering it as HTML.
Inspecting the HTTP response explains why. Confluence returns Content-Disposition: attachment, which forces a download, together with X-Content-Type-Options: nosniff, which stops the browser guessing the content type and forces it to use the Content-Type from the response. Guessing is what browsers normally do when a server's label looks wrong: they peek at the bytes and decide for themselves. nosniff switches that behaviour off.
A .txt file behaves differently: it can be viewed without being downloaded. Through a proxy, the response for the text file shows Content-Disposition using the inline value, which lets the browser display the file when it understands the content type, in this case text/plain.
That difference is the thread the researcher pulled: the disposition is computed from the filename and the stored MIME type, both of which the uploader controls.
Exploitation
Step 1: understand how the disposition is chosen
The decision between inline and attachment comes from the method guessContentDispositionHeader(), found in com.atlassian.http_atlassian-http-4.1.0.jar at the path /com/atlassian/http/mime/ContentDispositionHeaderGuesser.class. A .jar file is a bundle of compiled Java code, and a method is a named block of code inside it. Reading the method shows exactly how the decision is made:
public String guessContentDispositionHeader(String fileName, String mimeContentType, String userAgent) {
DownloadPolicy downloadPolicy = this.downloadPolicyProvider.getPolicy();
boolean forceDownload = false;
if (downloadPolicy.equals(DownloadPolicy.Insecure)) {
return "inline";
} else if (!downloadPolicy.equals(DownloadPolicy.Secure) && !downloadPolicy.equals(DownloadPolicy.WhiteList)) {
forceDownload = this.isExecutableContent(fileName, mimeContentType);
if (BrowserUtils.isIE(userAgent) && this.isTextContentType(mimeContentType)) {
forceDownload = true;
}
if (forceDownload && log.isDebugEnabled()) {
log.debug("\"" + fileName + "\" (" + mimeContentType + ") presents as executable content, forcing download.");
}
return forceDownload ? "attachment" : "inline";
} else {
return "attachment";
}
}
Line by line:
- The method receives three pieces of information: the file name, the MIME type that was stored, and the browser's user agent string. A user agent is the text a browser sends to identify itself, such as "Safari on iPhone".
- It first asks the configured download policy what to do. A policy is an administrator's setting for how strict the server should be.
- If the policy is
Insecure, it immediately answersinline, meaning show the file in the browser. - Otherwise, if the policy is neither
SecurenorWhiteList, it callsthis.isExecutableContent()with the filename and MIME type. "Executable" here means "could be run as code by a browser", which is exactly what we do not want. - There is a special case: if the browser is Internet Explorer and the content is text, it forces a download regardless.
- If debug logging is on, it writes a line to the log saying the file looks executable and is being forced to download.
- Finally it returns
attachmentif a download was forced, andinlineotherwise. In theSecureandWhiteListpolicies it always returnsattachment.
The method calls this.isExecutableContent() with the filename and the stored MIME type, and the return value decides between attachment and inline. isExecutableContent() is a wrapper around hostileExtensionDetector.isExecutableContent(). A wrapper is a small method that just passes the work on to another one:
private boolean isExecutableContent(String name, String mimeContentType) {
return this.hostileExtensionDetector.isExecutableContent(name, mimeContentType);
}
- It takes the name and the MIME type.
- It hands both straight to
hostileExtensionDetector.isExecutableContent()and returns whatever that gives back. The name "hostile extension detector" tells you its job: spot file types that could be dangerous.
That in turn calls two functions, isExecutableFileExtension() and isExecutableContentType(). To reach Content-Disposition: inline, both must return false:
public boolean isExecutableContent(String fileName, String contentType) {
return this.isExecutableFileExtension(fileName) || this.isExecutableContentType(contentType);
}
- It runs the filename check and the MIME type check.
- The
||means "or": if either check says the file is dangerous, the whole answer is true, and the file is forced to download. Only when both say "not dangerous" do we getinline.
Step 2: get past the extension check
isExecutableFileExtension() compares the filename against an array of malicious file extensions and returns true if the filename contains any of them, which would force attachment. An array is simply a list. Any extension outside that array avoids the check; the researcher used .png, noting that this does not affect browser behaviour. The browser does not care that the file is called .png; it cares what the server says the content is.
Step 3: get past the MIME type check
isExecutableContentType() compares the file's MIME type against a list of malicious types and returns true on a match:
public boolean isExecutableContentType(String contentType) {
boolean isExecutableContentType = false;
if (StringUtils.isBlank(contentType)) {
return true;
} else if (!VALID_MIME_TYPE.matcher(contentType.toLowerCase()).matches()) {
return true;
} else {
for(String executableContentType : this.executableContentTypes) {
if (contentType.toLowerCase(Locale.US).contains(executableContentType)) {
isExecutableContentType = true;
break;
}
}
return isExecutableContentType;
}
}
Line by line:
- It starts by assuming the type is not dangerous.
- If the MIME type is blank, it returns true, treating a missing label as dangerous.
- If the MIME type does not match the expected shape of a MIME type (the
VALID_MIME_TYPEpattern), it also returns true. A pattern here is a rule describing what a well-formed value looks like. - Otherwise it loops over the list of known dangerous types. For each one, it lowercases the supplied type and checks whether it contains the dangerous entry. If it does, it marks the type as dangerous and stops looping.
- It returns the result. So a type is dangerous only if it appears in the list; anything else passes.
The list of MIME types Confluence treats as bad, as printed in the report, is:
0 = "image/svg+xml"
1 = "application/pdf"
2 = "image/svg-xml"
3 = "message/rfc822"
4 = "multipart/x-mixed-replace"
5 = "text/xml-external-parsed-entity"
6 = "text/vtt"
7 = "application/atom+xml"
8 = "text/webviewhtml"
9 = "application/x-shockwave-flash"
10 = "text/html-sandboxed"
11 = "text/html"
12 = "application/rdf+xml"
13 = "application/octet-stream"
14 = "text/vnd.wap.wml"
15 = "text/xsl"
16 = "video/x-flv"
17 = "application/vnd.wap.xhtml+xml"
18 = "application/mathml+xml"
19 = "application/xml"
20 = "application/xml-dtd"
21 = "application/x-cab"
22 = "text/xml"
23 = "application/futuresplash"
24 = "application/xml-external-parsed-entity"
25 = "text/rdf"
26 = "text/xhtml"
27 = "application/xhtml+xml"
This is a deny-list: a list of things that are forbidden. The idea is that anything on the list is blocked and everything else is allowed. To bypass this check, a different file extension and a different MIME type are enough, as long as neither appears on the lists.
Step 4: find a MIME type WebKit renders as HTML
During research into MIME types, the researcher found that video/mp2t is interpreted as HTML by WebKit-based mobile browsers, meaning Safari and Chrome on iOS. WebKit is the engine that renders web pages inside those browsers; on iOS, both Safari and Chrome use it. The report stresses that this is just one example, and that a deny-list is hard to implement, with the focus better placed on a more restrictive approach such as an allow-list.
Step 5: upload the payload with a spoofed MIME type
The exploit needs an HTML file with any extension not on the deny-list; the researcher used .png. The file is uploaded through the comment section, and the request is intercepted so the mimeType GET parameter can be changed to video/mp2t. A GET parameter is a value appended to a URL after a question mark, and here the upload request carries the MIME type that way.
In the first test the file was uploaded to:
http://localhost:8090/download/attachments/163936/alert.png?version=2&modificationDate=1737506251465&api=v2
http://is the protocol, the language browsers and servers use to talk.localhost:8090is the researcher's own machine and the port Confluence listens on./download/attachments/163936/alert.pngis the path to the stored file, where163936identifies the attachment andalert.pngis the file name.?version=2&modificationDate=1737506251465&api=v2are parameters: which version of the file, when it was last modified, and which API style to use.
To open it from the iPhone, the [redacted] address was used instead of localhost, because localhost on the phone would mean the phone itself. Opening the link on an iOS device rendered the file as HTML.
Step 6: build the payload that abuses PAT creation
Because a PAT can be used to authenticate against the Confluence API, it is a good target for the XSS payload. The proof of concept creates a new PAT in the victim's account and shows it in an alert box; the researcher notes that the token could just as easily be sent to a remote server controlled by the attacker. An alert box is the small pop-up a browser shows when a page calls alert().
The payload is stored in a file called token.png:
<script>
(async () => {
const rawResponse = await fetch("/rest/pat/latest/tokens",
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify({name:"Backdoor", expirationDuration:90})
});
const content = await rawResponse.json();
alert(content.rawToken);
})();
</script>
Line by line:
<script>and</script>mark the start and end of JavaScript, the language browsers run. Everything between them is code, not text to display.(async () => {starts a function that can wait for slow operations, such as a network request, without freezing the page.asyncmeans it is allowed to wait, andawaitmarks the places where it does.const rawResponse = await fetch("/rest/pat/latest/tokens",sends a request to that address and waits for the answer.fetchis the browser's built-in way to make requests. The address is relative, so it goes to the same site the page came from, which is Confluence itself.- The object that follows describes the request.
headersare the extra lines sent with it:Accept: application/jsonsays "I would like a JSON answer", andContent-Type: application/jsonsays "the body I am sending is JSON". JSON is a simple text format for structured data, made of names and values. method: "POST"says this request creates something rather than just reading.body: JSON.stringify({name:"Backdoor", expirationDuration:90})is the data being sent: a token namedBackdoorthat expires after 90 (the report does not state the unit).JSON.stringifyturns that into JSON text.const content = await rawResponse.json();waits for the reply and reads it as JSON.alert(content.rawToken);shows therawTokenfield from the reply in a pop-up. That field is the newly created token itself.})();closes and immediately runs the function.
Step 7: upload and rewrite the MIME type
The payload file is selected and sent, then the mimeType parameter is changed to video/mp2t using a proxy. The file is saved without any problem, and the URL to send to the victim's iPhone is:
http://[redacted]:8090/download/attachments/163936/token.png?version=1&modificationDate=1737508504777&api=v2
[redacted]:8090is the researcher's machine as seen from the phone on the same network./download/attachments/163936/token.pngis the stored payload file.?version=1&modificationDate=1737508504777&api=v2again say which version, when it was modified, and which API style to use.
When the victim opens the link, a new PAT token appears in the alert box. The report links a PoC video.
Step 8: use the stolen token
With the token in hand, the attacker can authenticate to the Confluence REST API. The report shows this with a curl request. curl is a command-line tool for making HTTP requests:
curl -H 'Authorization: Bearer [redacted]' http://localhost:8090/rest/api/user?username=admin ; echo
curlis the program being run.-Hadds a header to the request. Here it isAuthorization: Bearer [redacted], which is how a token is presented: the wordBearerfollowed by the token itself. The token is redacted here because it is a secret.http://localhost:8090/rest/api/user?username=adminis the API address being called, asking for the user namedadmin.; echoruns a second, trivial command that prints a blank line, so the output ends neatly.
Root cause
The disposition of an uploaded file is decided by a deny-list. guessContentDispositionHeader() asks hostileExtensionDetector.isExecutableContent() whether the file is executable, and that check is the OR of an extension deny-list and a MIME type deny-list. Both inputs come from the upload request, so an attacker who picks an extension and a MIME type outside the lists gets Content-Disposition: inline.
The deny-list contains text/html and a set of XML and related types, but not video/mp2t, which WebKit on iOS interprets as HTML. The researcher's conclusion is that a deny-list is very hard to get right, and that the focus should be on a more restrictive approach such as an allow-list. An allow-list is the opposite of a deny-list: only named things are permitted and everything else is refused, so a type nobody thought of is blocked by default rather than allowed by default. The report also notes that different devices may support different MIME types that can be interpreted as HTML or XML.
Impact
The bug only affects users who access Confluence through an iPhone or iPad using Safari or Chrome. For those users, an attacker who can upload a file to a comment section can get script execution in the Confluence origin when the victim opens the download link. The origin is the combination of scheme, host and port that a browser uses to decide which site a page belongs to; script running in the Confluence origin can do anything the victim could do on Confluence. In the demonstrated chain, the script creates a Personal Access Token in the victim's account through POST /rest/pat/latest/tokens and shows it in an alert box; the researcher notes it could instead be sent to an attacker-controlled server. Exfiltrate means get the secret out to the attacker. The report's PoC shows the token in an alert box and states that sending it to an attacker-controlled server would be easy.
The CVSS vector given in the report is:
CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:L
Each part is a short code. AV:N means the attack can come over the network. AC:H means it is hard to carry out. PR:L means the attacker needs low privileges, such as an ordinary account. UI:R means the victim must do something, here open a link. S:C means the impact reaches beyond the vulnerable component. C:H and I:H mean high impact on confidentiality and integrity: secrets can be read and data changed. A:L means low impact on availability.
Fix
The report does not describe a fix or a change made by Atlassian. The researcher's recommendation is to move away from the deny-list approach towards a more restrictive one, such as an allow-list.
Variants to test
- Other MIME types rendered as HTML by WebKit. Upload an HTML file with an extension outside the deny-list and set
mimeTypeto candidate types one at a time, then open the download URL on an iOS device. A positive result is the file rendering as HTML rather than downloading, withContent-Disposition: inlinein the response. - Other browsers and platforms. The report only establishes the behaviour for Safari and Chrome on iOS. Trying the same upload and MIME type rewrite on other mobile browsers and platforms tests whether the rendering behaviour is broader than WebKit on iOS.
- Other upload surfaces. The report describes uploads in the comment section of a personal page through
POST /plugins/drag-and-drop/upload.action. Testing other places where Confluence stores and serves user-supplied files would show whether the same disposition logic applies there. - Other token and API endpoints. The PoC targets
POST /rest/pat/latest/tokens. Any endpoint that returns credentials or performs sensitive actions with the victim's session is worth testing as a payload target; a positive result is a response containing a usable secret or a state change visible in the victim's account. - Filename edge cases against the extension check. The extension check returns true if the filename contains any listed extension. Trying filenames that combine an allowed extension with a listed one, or that use unusual casing or separators, tests how the containment check behaves; a positive result is
Content-Disposition: inlinefor a file the browser still renders as HTML.
Glossary
- API: a set of addresses a program exposes so other programs can talk to it.
- Allow-list: a list of things that are permitted, with everything else refused.
- Array: an ordered list of values in code.
- Attachment: a file stored alongside a page or comment.
- Bounty: a reward paid for a responsibly reported security flaw.
- Content-Disposition: a response header that tells the browser to show a file inline or download it.
- Content-Type: a response header that labels what kind of content is being sent.
- Confluence Data Center: the self-hosted version of Atlassian's team workspace product.
- Cookie: a small piece of data a site stores in the browser to remember who you are.
- CSRF: Cross-Site Request Forgery, tricking a logged-in browser into sending a request the user did not intend.
- curl: a command-line tool for making HTTP requests.
- CVSS: a standard scoring system for the severity of a security flaw.
- Deny-list: a list of things that are forbidden, with everything else allowed.
- Exfiltrate: get data out of a system to a place the attacker controls.
- Fuzzer: a tool that tries many variations automatically to find one that gets through.
- GET parameter: a value appended to a URL after a question mark.
- Header: a line of extra information sent with an HTTP request or response.
- HTML: the language web pages are written in.
- HTTP: the protocol browsers and servers use to talk.
- Inline: shown inside the browser window rather than downloaded.
- iOS: Apple's operating system for iPhone and iPad.
- JSON: a simple text format for structured data, made of names and values.
- MIME type: a short label saying what kind of content a file holds.
- nosniff: a header that stops the browser guessing a file's type and forces it to use the server's label.
- Origin: the scheme, host and port that a browser uses to decide which site a page belongs to.
- PAT (Personal Access Token): a long random string that acts like a password for a program.
- Port: a numbered door on a computer where a network service listens.
- POST: the HTTP method used to send data to a server, often to create something.
- Proxy: a tool that sits between browser and server and lets you inspect and edit traffic.
- REST: a common style for APIs, where each address represents a thing and standard HTTP methods act on it.
- Script: code that a browser runs, usually JavaScript.
- Source code analysis: reading a program's own code to find flaws.
- Stored XSS: Cross-Site Scripting where the malicious content is saved on the server and runs when a victim opens it.
- Token: a long random string used to prove identity, like a password for a program.
- User agent: the text a browser sends to identify itself.
- WebKit: the engine that renders web pages in Safari and, on iOS, in Chrome too.
- Wrapper: a small method that passes work on to another one.
- XSS (Cross-Site Scripting): getting your own code to run inside someone else's website, in that site's context.