Discovery of CVE-2022-35406
The author found that Burp Suite's Repeater tab would follow a meta refresh redirect to a javascript: URL even when the response content type was not text/html, while browsers would not. This could lead to leakage of the Referer header, which might contain sensitive tokens.
Published on medium.com
On 11th April 2022, it was a regular day for me. I went to the office & started my daily activities.
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
This is an account of how CVE-2022-35406 was found. The researcher was pen-testing one of the products at his workplace, and the feature under test was file upload. The uploaded file was served back to the user with a Content-Disposition header, so the browser downloaded it rather than rendering it. The write-up does not name the product or the organisation beyond that.
As the researcher understood it, the finding was a Burp Suite issue rather than a flaw in the product. It was a discrepancy between how Burp Suite's Repeater tab handled a response and how a browser handled the same response. The researcher reported it to PortSwigger on HackerOne with a Low severity rating, and the report is partially published as HackerOne report 1541301.
Setup
The tools and preconditions that matter here are small:
- Burp Suite, with the Proxy and Repeater tabs, used to capture and replay requests.
- A browser, used to compare behaviour against Repeater.
- A local Python HTTP server, started to rule the target product out of the picture.
- A file upload feature on the product under test, which accepted a file and served it back with
Content-Dispositionset.
No account details, roles or product versions are given in the write-up.
Finding it
While testing the upload feature, the researcher uploaded a file containing XSS payloads, but uploaded it with a .txt extension by mistake. When the file was visited from the browser it was downloaded directly as a .txt file, because of the Content-Disposition header in the response. That ruled out XSS in the browser at that moment.
Separately, in the Repeater tab, an open redirection appeared. Open redirection on its own is not critical unless it can be chained with something else, so the researcher tried to escalate it. The same case was not reproducible in the browser. Turning the proxy off and repeating the request produced no redirect either. Capturing the request again, sending it to Repeater and pressing send produced an HTTP 302 response.
So there were two observations at this point:
- The request was redirected in the Repeater tab.
- The same request was not redirected in the browser.
Looking at where Repeater was sending the response, the redirect target was:
javascript:alert('xss');
Exploitation
Step 1: locate the payload responsible
The researcher pasted the string into the response and found seven similar matches. The uploaded file contained several XSS payloads, so the next task was to work out which one caused the redirect. All similar matches in the XSS file were changed from javascript:alert('xss1'); through to javascript:alert('xss7'); respectively, the updated file was uploaded, and the download request was captured, sent to Repeater and replayed. Repeater now redirected to:
javascript:alert('xss3');
That identified the culprit: a <meta> tag.
<META HTTP-EQUIV="refresh" CONTENT="0; url=javascript:alert('xss3');">
The HTTP-EQUIV="refresh" attribute makes the tag behave like a refresh header, and the CONTENT value sets a delay of 0 and a url of the JavaScript payload. Redirection via a meta tag is common when the Content-Type is text/html.
Step 2: confirm the redirect is content-type independent
The file was updated again, this time setting the URL attribute of the meta tag to https://google.com. In Repeater the response redirected to https://google.com.
The important detail is the content type. Redirection via a meta tag is normally only honoured when the Content-Type is text/html. In Repeater it redirected regardless of content type: it did not matter whether the response was image/png or text/plain. The uploaded file was being served as a .txt download, and Repeater still followed the meta refresh.
Step 3: rule out the target product
The remaining question was why the browser did not redirect. At first the researcher suspected this might not be a security issue at all, since the redirect only appeared in Repeater and exploitation might be impossible. Then the question turned to Burp Suite itself. To confirm, a local Python HTTP server was started:
python3 -m http.server 8081
The XSS file was opened in the browser from the local server:
http://[redacted]:8081/Downloads/XSS.txt
The request was captured in Burp, sent to Repeater, and the send button produced an HTTP 302. The same file, served by a plain local server with no product code involved, behaved the same way in Repeater. As the researcher understood it, this was a Burp Suite issue.
Root cause
The write-up does not describe Burp's internals, so the mechanism can only be stated as the researcher framed it: Repeater followed a <meta http-equiv="refresh"> redirect in the response irrespective of the response's Content-Type. A browser applies the usual rule and only honours the meta refresh when the content is treated as HTML, which is why the same response did nothing in the browser. The file was served with a Content-Disposition header, so the browser downloaded it, while Repeater still acted on the meta tag.
Impact
With the redirect confirmed as a Burp behaviour rather than a product flaw, the researcher considered what it could expose. The impact that came to mind was HTTP Referer header leakage: when a redirect is followed, the Referer header sent onward can contain a sensitive token or key. The write-up does not demonstrate a captured Referer value or a leaked token.
Because of the high level of user interaction required, the issue was reported to PortSwigger on HackerOne with a Low severity. The report is partially published.
Fix
It only records that the issue was reported to PortSwigger on HackerOne as a Low severity finding, with the report partially published.
Variants to test
These are things to try when you meet a similar discrepancy between a proxy tool and a browser:
- Meta refresh in non-HTML responses. Serve a file with a
<meta http-equiv="refresh">tag and aContent-Typesuch astext/plainorimage/png, then replay the request in Repeater. A positive result is a 302 or a followed redirect in the tool while the browser downloads or displays the file without redirecting. - Other client-side redirect primitives. Try the same comparison with other mechanisms a renderer might act on, and note which ones the tool follows and the browser ignores.
- Referer leakage on the redirect. When a redirect is followed, check what the
Refererheader contains on the resulting request. A positive result is a sensitive token or key appearing in that header. - Content-Disposition as a control. Serve the same payload with
Content-Disposition: attachmentand confirm the browser downloads it. If the tool still follows the redirect, the download header is not protecting the tool's view of the response. - Local server baseline. Reproduce with
python3 -m http.serverand a file on disk, as done here, to separate tool behaviour from target behaviour before reporting anything to the target.
What happened, in plain words
A security researcher was testing a file upload feature on one of his company's products. He uploaded a text file that happened to contain some JavaScript code, and when he looked at the same request in a tool called Burp Suite, the tool followed a redirect written inside that file. His browser did not. After some digging he worked out that the redirect was caused by a small piece of HTML called a meta tag, and that the tool was following it even though the file was not a web page. As he understood it, the issue was in the tool, not in the product. He reported it to the company that makes the tool, PortSwigger, and the report is partially published as HackerOne report 1541301.
This article walks through the whole story slowly, explaining every term as it appears, so you can follow it even if you have never done security testing before.
The background you need first
Before the story makes sense, here are a few ideas in everyday language.
A web request and a response. When you type an address into your browser and press Enter, the browser sends a request to a computer somewhere (a server). The server sends back a response. The response has two parts: headers, which are small labelled lines of information about the response, and a body, which is the actual content (a web page, an image, a file).
HTTP status codes. The response starts with a number that tells the browser what happened. 200 means "here is your content". 302 means "the thing you asked for is somewhere else, go there instead". A 302 is a redirect.
Content-Type. A header that tells the browser what kind of content the body is. text/html means "this is a web page, render it". text/plain means "this is plain text, show it as text". image/png means "this is a picture".
Content-Disposition. A header that tells the browser whether to display the content in the window or download it as a file. When it says attachment, the browser saves the file to disk instead of rendering it.
JavaScript. The programming language that runs inside web pages. A short piece of JavaScript can make the browser do something, such as show a pop-up box.
XSS (Cross-Site Scripting). A class of security bug where an attacker manages to get their own JavaScript to run inside someone else's web page. If a site lets you upload a file and then serves that file back as a web page, and the file contains JavaScript, the JavaScript can run in the browser of anyone who views it. That is why testers upload files containing JavaScript: to see whether the site will execute it.
Open redirection. A bug where a site takes a destination from the request and sends the user there, without checking that the destination is a safe one. On its own it is usually low impact, but it can be chained with other bugs to do more damage.
A proxy and Burp Suite. A proxy sits between your browser and the internet and lets you see and change every request and response. Burp Suite is a popular proxy tool used by security testers. It has a Proxy tab (which captures traffic) and a Repeater tab (which lets you take a captured request and send it again and again, changing it each time).
A meta refresh tag. HTML has a tag that tells the browser "after a certain number of seconds, go to this other address". It looks like <meta http-equiv="refresh" content="...">. Browsers only act on it when they are treating the content as a web page (that is, when the Content-Type is text/html).
The Referer header. When your browser follows a link or a redirect, it often tells the destination which page you came from, in a header called Referer. If the address of the page you came from contains something sensitive, such as a session token, that value travels to the destination too.
A token or session cookie. A short secret string that a website gives your browser after you log in, so it can recognise you on the next request. If someone else gets hold of it, they can pretend to be you.
CVE. A public catalogue number for a known security vulnerability. CVE-2022-35406 is the number assigned to the issue in this story.
HackerOne. A website where security researchers report bugs to companies and can receive a bounty (a payment) for valid reports.
The setup
The researcher was pen-testing one of the products at his workplace. The feature he was testing was file upload: a part of the product where a user can send a file to the server, and the server stores it and serves it back later. The product served uploaded files back with a Content-Disposition header, which means the browser downloads the file instead of displaying it. The write-up does not name the product or the organisation.
The tools involved were:
- Burp Suite, with its Proxy and Repeater tabs, to capture and replay requests.
- A normal browser, to compare what it did with what Repeater did.
- A small local web server written in Python, started later to rule the product out.
- The upload feature itself, which accepted a file and served it back with
Content-Dispositionset.
No account details, roles or product versions are given in the write-up.
Finding it
While testing the upload feature, the researcher uploaded a file containing XSS payloads, but uploaded it with a .txt extension by mistake. A payload here means a short piece of code designed to test whether the site will run it. Because the file was served back with Content-Disposition, the browser downloaded it as a .txt file rather than rendering it. That ruled out XSS in the browser at that moment: the JavaScript never got a chance to run, because the browser never treated the file as a web page.
Separately, in the Repeater tab, an open redirection appeared. Open redirection on its own is not critical unless it can be chained with something else, so the researcher tried to escalate it. The same case was not reproducible in the browser. Turning the proxy off and repeating the request produced no redirect either. Capturing the request again, sending it to Repeater and pressing send produced an HTTP 302 response.
So there were two observations at this point:
- The request was redirected in the Repeater tab.
- The same request was not redirected in the browser.
Looking at where Repeater was sending the response, the redirect target was:
javascript:alert('xss');
Line by line: javascript: is a prefix that tells the browser "run the code that follows as JavaScript". alert('xss') is a JavaScript instruction that shows a pop-up box containing the text xss. The semicolon at the end just ends the instruction. So this redirect target, if followed, would make the browser pop up a box saying xss. That is a classic sign that someone's JavaScript is being executed.
Exploitation
Step 1: locate the payload responsible
The researcher pasted the string into the response and found seven similar matches. The uploaded file contained several XSS payloads, so the next task was to work out which one caused the redirect. All similar matches in the XSS file were changed from javascript:alert('xss1'); through to javascript:alert('xss7'); respectively, the updated file was uploaded, and the download request was captured, sent to Repeater and replayed. Repeater now redirected to:
javascript:alert('xss3');
Line by line: each of the seven payloads was given a different number inside the pop-up text, so that when one of them fired, the number in the box would say which one it was. The result said xss3, so the third payload was the one causing the redirect.
That identified the culprit: a <meta> tag.
<META HTTP-EQUIV="refresh" CONTENT="0; url=javascript:alert('xss3');">
Line by line: <META starts an HTML meta tag. HTTP-EQUIV="refresh" makes the tag behave like a refresh instruction, the same kind of thing a server can send in a header. CONTENT="0; url=javascript:alert('xss3');" sets the delay to 0 seconds and the destination to the JavaScript payload. Redirection via a meta tag is common when the Content-Type is text/html.
Step 2: confirm the redirect is content-type independent
The file was updated again, this time setting the URL attribute of the meta tag to https://google.com. In Repeater the response redirected to https://google.com.
The important detail is the content type. Redirection via a meta tag is normally only honoured when the Content-Type is text/html. In Repeater it redirected regardless of content type: it did not matter whether the response was image/png or text/plain. The uploaded file was being served as a .txt download, and Repeater still followed the meta refresh.
In everyday terms: a browser reads a meta refresh only when it believes it is looking at a web page. Repeater was reading it even when it was looking at a text file or a picture. That is the discrepancy.
Step 3: rule out the target product
The remaining question was why the browser did not redirect. At first the researcher suspected this might not be a security issue at all, since the redirect only appeared in Repeater and exploitation might be impossible. Then the question turned to Burp Suite itself. To confirm, a local Python HTTP server was started:
python3 -m http.server 8081
Line by line: python3 runs the Python interpreter. -m http.server tells Python to run its built-in web server module. 8081 is the port number, the numbered door on your computer that the server listens on. The result is a tiny web server that serves the files in the current folder, with no product code involved at all.
The XSS file was opened in the browser from the local server:
http://[redacted]:8081/Downloads/XSS.txt
Line by line: http:// is the protocol. [redacted] is the address your computer uses to refer to itself (often called localhost). :8081 is the port the Python server is listening on. /Downloads/XSS.txt is the path to the file on disk. So this address asks the researcher's own computer for the file, not the product.
The request was captured in Burp, sent to Repeater, and the send button produced an HTTP 302. The same file, served by a plain local server with no product code involved, behaved the same way in Repeater. As the researcher understood it, this was a Burp Suite issue.
Root cause
The write-up does not describe Burp's internals, so the mechanism can only be stated as the researcher framed it: Repeater followed a <meta http-equiv="refresh"> redirect in the response irrespective of the response's Content-Type. A browser applies the usual rule and only honours the meta refresh when the content is treated as HTML, which is why the same response did nothing in the browser. The file was served with a Content-Disposition header, so the browser downloaded it, while Repeater still acted on the meta tag.
A simple comparison: imagine a note that says "please forward this letter to the address inside". A careful postal worker only follows that instruction when the note is attached to a letter, not when it is scribbled on the back of a shopping list. The browser is the careful worker. Repeater was following the note regardless of what it was attached to.
Impact
With the redirect confirmed as a Burp behaviour rather than a product flaw, the researcher considered what it could expose. The impact that came to mind was HTTP Referer header leakage: when a redirect is followed, the Referer header sent onward can contain a sensitive token or key. The write-up does not demonstrate a captured Referer value or a leaked token.
In plain terms: if a tester is logged into a site and the address of the page they are on contains a secret, and a redirect is followed, that secret can be passed along to wherever the redirect points.
Because of the high level of user interaction required, the issue was reported to PortSwigger on HackerOne with a Low severity. The report is partially published.
Fix
It only records that the issue was reported to PortSwigger on HackerOne as a Low severity finding, with the report partially published.
Variants to test
These are things to try when you meet a similar discrepancy between a proxy tool and a browser:
- Meta refresh in non-HTML responses. Serve a file with a
<meta http-equiv="refresh">tag and aContent-Typesuch astext/plainorimage/png, then replay the request in Repeater. A positive result is a 302 or a followed redirect in the tool while the browser downloads or displays the file without redirecting. - Other client-side redirect primitives. Try the same comparison with other mechanisms a renderer might act on, and note which ones the tool follows and the browser ignores.
- Referer leakage on the redirect. When a redirect is followed, check what the
Refererheader contains on the resulting request. A positive result is a sensitive token or key appearing in that header. - Content-Disposition as a control. Serve the same payload with
Content-Disposition: attachmentand confirm the browser downloads it. If the tool still follows the redirect, the download header is not protecting the tool's view of the response. - Local server baseline. Reproduce with
python3 -m http.serverand a file on disk, as done here, to separate tool behaviour from target behaviour before reporting anything to the target.
Glossary
- 302: an HTTP status code meaning "the content is somewhere else, go there instead"; a redirect.
- API: a way for one piece of software to talk to another, like a waiter taking your order to the kitchen and bringing back the food.
- Burp Suite: a tool used by security testers that sits between the browser and the internet, letting them see and change requests and responses.
- Content-Disposition: a response header that tells the browser whether to display content or download it as a file.
- Content-Type: a response header that tells the browser what kind of content it is receiving, such as
text/htmlortext/plain. - Cookie: a small piece of data a website stores in your browser, often used to recognise you between requests.
- HackerOne: a website where researchers report security bugs to companies and can receive a bounty.
- Header: a small labelled line of information sent with a web request or response, separate from the main content.
- HTTP: the language browsers and servers use to exchange requests and responses.
- Meta refresh tag: an HTML tag that tells the browser to go to another address after a delay.
- Open redirection: a bug where a site sends the user to a destination taken from the request without checking it is safe.
- Payload: a short piece of code or data used in a test to see how a system reacts.
- Pen-testing: deliberately probing a system for security weaknesses, with permission, to find them before attackers do.
- Port: a numbered door on a computer that a particular service listens on.
- Proxy: a middleman between your browser and the internet that can record and alter traffic.
- Referer header: a header that tells the destination which page the request came from.
- Repeater: a Burp Suite tab that lets you take a captured request and send it again and again, changing it each time.
- Response: what a server sends back after a request.
- Session token: a secret string a site gives your browser after login so it can recognise you.
- Severity: a rating of how serious a security issue is, often Low, Medium, High or Critical.
- XSS (Cross-Site Scripting): a bug where an attacker's JavaScript runs inside someone else's web page.