Accepting error message on twitter sends you to attacker site
When a logged-in user opened a Twitter error page and clicked its OK button, the browser returned them to the page they came from rather than to Twitter. An attacker could use this to send a victim back to an attacker-controlled site after they clicked OK on a genuine Twitter page, which makes phishing easier.
Originally disclosed on HackerOne
- Triaged in 4 days
- Fixed in 46 days
- Paid in 19 days
- Disclosed after 50 days
Summary: Accepting error message on twitter sends you back to attacker site.
Description:
- The link https://twitter.com/i/flow shows up an error message with an OK button
- When you are not logged in, clicking in that OK button takes you back to twitter.com
- But if you open that link when you are logged in, clicking on OK takes you to the page from where you are routed to twitter.
- This simplifies phishing attack where an attacker can take user to malicious page on clicking OK button on twitter.
PS: This may not be an Open redirect using URL but a redirection that could simplify phishing attacks (CWE-601)
Steps To Reproduce:
- Save the following code as HTML file
- Login to twitter and in other tab of same browser open the HTML file
- Click on the link "Click here"
- You are then taken to twitter and an error message is shown
- Click OK
- You are then reidrected to attackers site (Here in PoC I have used "https://hackerone.com/twitter")
<html>
<body>
<h1> This is hacker's site</h1>
<a href="https://twitter.com/i/flow" onClick="userClicked()">Click here</a> //This may also be made an auto-redirection to twitter from attacker site
</body>
<script>
function userClicked(){
localStorage.setItem("ClickCount", 1); //Setting up a value in local storage to detected user click
}
if(localStorage.getItem("ClickCount")==1)
{
localStorage.setItem("ClickCount", 0);
if(localStorage.getItem("ClickCount")==0)
{
window.location.replace("https://hackerone.com/twitter"); //This can any attacker controlled website
}
}
</script>
</html>
Impact
This simplifies phishing attack where an attacker can take user to malicious page on clicking OK button on twitter Possible fix might be sending the user back to twitter.com on click of OK
Context
The target is Twitter, reported through the X / xAI program on HackerOne under the asset *.twitter.com. The feature involved is the flow endpoint at https://twitter.com/i/flow, which, when visited, displays an error message with an OK button. The report classifies the issue as an Open Redirect (CWE-601), though the researcher notes it may not be a redirect driven by a URL parameter but rather a redirection that could simplify phishing attacks.
Setup
No special tooling is required. The precondition is a logged-in Twitter session in the browser. The researcher also uses a local HTML file opened in another tab of the same browser to demonstrate the attack. The proof of concept uses https://hackerone.com/twitter as the attacker-controlled destination.
Finding it
The researcher observed that the behaviour of the OK button on the error page depends on authentication state:
- The link
https://twitter.com/i/flowshows an error message with an OK button. - When you are not logged in, clicking that OK button takes you back to twitter.com.
- But if you open that link when you are logged in, clicking on OK takes you to the page from where you are routed to twitter.
That difference is the core of the finding: for an authenticated user, the OK button returns the browser to the referring page rather than to twitter.com. The researcher explicitly frames this as something that may not be an Open redirect using URL but a redirection that could simplify phishing attacks (CWE-601).
Exploitation
Step 1: Create the attacker page
Save the following code as an HTML file:
<html>
<body>
<h1> This is hacker's site</h1>
<a href="https://twitter.com/i/flow" onClick="userClicked()">Click here</a> //This may also be made an auto-redirection to twitter from attacker site
</body>
<script>
function userClicked(){
localStorage.setItem("ClickCount", 1); //Setting up a value in local storage to detected user click
}
if(localStorage.getItem("ClickCount")==1)
{
localStorage.setItem("ClickCount", 0);
if(localStorage.getItem("ClickCount")==0)
{
window.location.replace("https://hackerone.com/twitter"); //This can any attacker controlled website
}
}
</script>
</html>
The page contains a link to https://twitter.com/i/flow. The onClick handler calls userClicked(), which writes the value 1 to localStorage under the key ClickCount. The script then checks whether ClickCount equals 1; if so, it resets the value to 0 and, when the check for 0 succeeds, calls window.location.replace("https://hackerone.com/twitter"). The comment in the code notes that this can be any attacker-controlled website, and that the link could also be made an auto-redirection to twitter from the attacker site.
Step 2: Log in and open the page
Log in to Twitter and, in another tab of the same browser, open the HTML file.
Step 3: Click the link
Click on the link "Click here". This sets the ClickCount value in local storage and navigates to https://twitter.com/i/flow.
Step 4: Observe the error page
You are then taken to twitter and an error message is shown.
Step 5: Click OK
Click OK on the error message.
Step 6: Land on the attacker site
You are then redirected to the attacker's site. In the proof of concept the researcher used https://hackerone.com/twitter.
The page sets a local storage value when the link is clicked, and the script redirects to the attacker-controlled destination when that value is present.
Root cause
The report does not describe the server-side implementation. What it establishes is the behaviour: for a logged-in user, the OK button on the https://twitter.com/i/flow error page sends the browser back to the page from which the user was routed to Twitter, rather than to twitter.com. Because that originating page can be attacker-controlled, the OK button can return the user to the attacker's page. The researcher's suggested fix points at the same mechanism: sending the user back to twitter.com on click of OK.
Impact
This simplifies a phishing attack where an attacker can take a user to a malicious page on clicking the OK button on twitter. The report describes the impact as simplifying a phishing attack where clicking OK on Twitter takes the user to a malicious page. The report does not claim any further consequence beyond the phishing facilitation, and the researcher hedges that this may not be an Open redirect using URL but a redirection that could simplify phishing attacks (CWE-601).
Fix
The report proposes one change: sending the user back to twitter.com on click of OK. The report does not state what was actually changed.
Variants to test
- Error and interstitial pages on other hosts that offer an OK or Continue button. A positive result is that, while authenticated, pressing the button returns you to the referring page instead of the host's own domain.
- Flows reached from an external link where the return destination is taken from the referrer or from stored navigation state. A positive result is that the destination follows an attacker-supplied origin.
- Client-side state such as local storage used to detect a return visit, as in this proof of concept. A positive result is that a page you control can detect the return and redirect onward without any server-side parameter.
Hunting notes
This kind of bug hides in error pages and multi-step flows that try to return the user to where they came from. During recon, look for endpoints that render an error with a single acknowledgement button, and compare the button's behaviour when logged out and when logged in: a difference between returning to the site's own domain and returning to the referrer is the signal. The researcher demonstrated the sequence with an HTML page and a concrete destination, and explained the phishing scenario.
What happened, in plain words
Twitter has a page at https://twitter.com/i/flow that, when you visit it, shows an error message with an OK button. The researcher found that what that OK button does depends on whether you are logged in. If you are not logged in, pressing OK takes you back to twitter.com. If you are logged in, pressing OK takes you back to the page you came from. That sounds harmless, but the page you came from can be a page the attacker controls. So an attacker can build a page that sends you to Twitter, waits for you to press OK on the genuine Twitter error message, and then drops you on a site of their choosing. The report calls this an Open Redirect (CWE-601), while noting it may not be a redirect driven by a URL parameter but a redirection that could simplify phishing attacks.
A quick comparison: imagine a receptionist at a building who, when you ask for directions, walks you back to wherever you came from. If a stranger sent you there, the receptionist politely walks you back to the stranger. That is the shape of this bug: a trusted site handing you back to an untrusted origin.
Context
The target is Twitter, reported through the X / xAI program on HackerOne under the asset *.twitter.com. The feature involved is the flow endpoint at https://twitter.com/i/flow, which, when visited, displays an error message with an OK button. The report classifies the issue as an Open Redirect (CWE-601), though the researcher notes it may not be a redirect driven by a URL parameter but rather a redirection that could simplify phishing attacks.
A few terms first, because they come up throughout:
- Endpoint: a specific address on a website that does one job, like a particular counter in a large shop.
https://twitter.com/i/flowis one such address. - Open redirect: a situation where a website will send your browser onward to another site, and an attacker can choose which site. It is dangerous because the first hop looks trustworthy: the address bar briefly shows the real site before you land somewhere else.
- CWE-601: the standard catalogue number for open redirect issues. Catalogues like this give security people a shared name for a kind of mistake.
- Phishing: tricking someone into believing they are on a genuine site so they hand over a password or other information, or click something they should not.
- Referrer: the page your browser came from when it loaded the current page. Browsers can tell a site where you were just before, a bit like a visitor saying "I was sent here by the shop across the street".
Setup
No special tooling is required. The precondition is a logged-in Twitter session in the browser. The researcher also uses a local HTML file opened in another tab of the same browser to demonstrate the attack. The proof of concept uses https://hackerone.com/twitter as the attacker-controlled destination.
Two ideas in that paragraph are worth unpacking for a beginner:
- Logged-in session: when you sign in to a site, the site gives your browser a small piece of stored data (often called a cookie or a session token) so it can recognise you on the next page. That is why you do not type your password on every click. The bug only appears when the site recognises you, so being logged in is part of the setup.
- Local HTML file: a file saved on your own computer that your browser can open just like a web page. It does not need to be hosted anywhere. The attacker in this scenario would host such a page on the internet, but for a demonstration a local file is enough.
Finding it
The researcher observed that the behaviour of the OK button on the error page depends on authentication state:
- The link
https://twitter.com/i/flowshows an error message with an OK button. - When you are not logged in, clicking that OK button takes you back to twitter.com.
- But if you open that link when you are logged in, clicking on OK takes you to the page from where you are routed to twitter.
That difference is the core of the finding: for an authenticated user, the OK button returns the browser to the referring page rather than to twitter.com. The researcher explicitly frames this as something that may not be an Open redirect using URL but a redirection that could simplify phishing attacks (CWE-601).
Why does the difference matter? When you are logged out, clicking OK takes you back to twitter.com. When you are logged in, clicking OK takes you to the page from where you were routed to Twitter. Helpfulness is exactly what an attacker can exploit: if the attacker controls that previous page, the helpful return becomes a free ride to the attacker's site.
Exploitation
Step 1: Create the attacker page
Save the following code as an HTML file:
<html>
<body>
<h1> This is hacker's site</h1>
<a href="https://twitter.com/i/flow" onClick="userClicked()">Click here</a> //This may also be made an auto-redirection to twitter from attacker site
</body>
<script>
function userClicked(){
localStorage.setItem("ClickCount", 1); //Setting up a value in local storage to detected user click
}
if(localStorage.getItem("ClickCount")==1)
{
localStorage.setItem("ClickCount", 0);
if(localStorage.getItem("ClickCount")==0)
{
window.location.replace("https://hackerone.com/twitter"); //This can any attacker controlled website
}
}
</script>
</html>
The page contains a link to https://twitter.com/i/flow. The onClick handler calls userClicked(), which writes the value 1 to localStorage under the key ClickCount. The script then checks whether ClickCount equals 1; if so, it resets the value to 0 and, when the check for 0 succeeds, calls window.location.replace("https://hackerone.com/twitter"). The comment in the code notes that this can be any attacker-controlled website, and that the link could also be made an auto-redirection to twitter from the attacker site.
Line by line, in plain words:
<html>,<body>,<h1>: ordinary page structure. The heading simply says "This is hacker's site", so the reader can see which page they are on.<a href="https://twitter.com/i/flow" onClick="userClicked()">Click here</a>: a normal link to the Twitter flow page. The extraonClickpart means "when this link is clicked, also run the function calleduserClicked". The link still works; the function just runs alongside it.- The comment after the link notes that the click could be replaced by an automatic redirect to Twitter, so the victim does not even need to click a link on the attacker page.
function userClicked(){ ... }: defines that function. Inside it,localStorage.setItem("ClickCount", 1)stores the number 1 under the nameClickCount.- localStorage is a small storage box that a website keeps inside your browser, tied to that website's address. It survives page loads and tab switches, a bit like a sticky note left on your desk. Here it is used as a memory: "this visitor has clicked".
if(localStorage.getItem("ClickCount")==1): when the page loads, check whether the sticky note says 1. On the first visit it does not, so nothing happens and the user is free to click the link.localStorage.setItem("ClickCount", 0): if the note did say 1, reset it to 0, so the trick only fires once.if(localStorage.getItem("ClickCount")==0): confirm the reset worked.window.location.replace("https://hackerone.com/twitter"): send the browser to that address.replacemeans the current page is replaced in the browser history, so the back button does not simply return to the attacker page. The comment notes this could be any attacker-controlled website.
The page sets a local storage value when the link is clicked, and the script redirects to the attacker-controlled destination when that value is present.
Step 2: Log in and open the page
Log in to Twitter and, in another tab of the same browser, open the HTML file.
Being logged in is what triggers the vulnerable behaviour on Twitter's side. The report instructs opening the HTML file in another tab of the same browser.
Step 3: Click the link
Click on the link "Click here". This sets the ClickCount value in local storage and navigates to https://twitter.com/i/flow.
At this point the browser leaves the attacker page and goes to the genuine Twitter address. The browser navigates to the genuine Twitter address.
Step 4: Observe the error page
You are then taken to twitter and an error message is shown.
The error message is shown on Twitter, with an OK button.
Step 5: Click OK
Click OK on the error message.
Because the user is logged in, clicking OK takes the browser to the page from where the user was routed to Twitter.
Step 6: Land on the attacker site
You are then redirected to the attacker's site. In the proof of concept the researcher used https://hackerone.com/twitter.
Root cause
The report does not describe the server-side implementation. What it establishes is the behaviour: for a logged-in user, the OK button on the https://twitter.com/i/flow error page sends the browser back to the page from which the user was routed to Twitter, rather than to twitter.com. Because that originating page is attacker-controlled, the button becomes a trusted-looking hop to an arbitrary site. The researcher's suggested fix points at the same mechanism: sending the user back to twitter.com on click of OK.
The researcher's suggested fix is to send the user back to twitter.com on click of OK.
Impact
This simplifies a phishing attack where an attacker can take a user to a malicious page on clicking the OK button on twitter. The condition is that the victim is logged in to Twitter and arrives at the flow endpoint from the attacker's page. The report does not claim any further consequence beyond the phishing facilitation, and the researcher hedges that this may not be an Open redirect using URL but a redirection that could simplify phishing attacks (CWE-601).
The report says this simplifies a phishing attack where an attacker can take a user to a malicious page on clicking the OK button on Twitter.
Fix
The report proposes one change: sending the user back to twitter.com on click of OK. The report does not state what was actually changed.
Variants to test
- Error and interstitial pages on other hosts that offer an OK or Continue button. A positive result is that, while authenticated, pressing the button returns you to the referring page instead of the host's own domain.
- Flows reached from an external link where the return destination is taken from the referrer or from stored navigation state. A positive result is that the destination follows an attacker-supplied origin.
- Client-side state such as local storage used to detect a return visit, as in this proof of concept. A positive result is that a page you control can detect the return and redirect onward without any server-side parameter.
An interstitial page is a page that sits between you and your destination, usually to show a warning or ask you to confirm something. They are common places for this kind of bug because they often try to send you back where you came from.
Hunting notes
This kind of bug hides in error pages and multi-step flows that try to return the user to where they came from. During recon, look for endpoints that render an error with a single acknowledgement button, and compare the button's behaviour when logged out and when logged in: a difference between returning to the site's own domain and returning to the referrer is the signal. The researcher demonstrated the sequence with an HTML page and a concrete destination, and explained the phishing scenario.
Recon here simply means looking around a site's pages and features to find places worth testing. The habit to take away is comparison: try the same button in two states, logged in and logged out, and see whether it behaves differently.
Glossary
- Endpoint: a specific address on a website that performs one function, such as
https://twitter.com/i/flow. - Open redirect: a flaw where a site will forward your browser to another site chosen by an attacker.
- CWE-601: the standard catalogue entry for open redirect vulnerabilities.
- Phishing: deceiving someone into trusting a page or message so they reveal information or click something harmful.
- Referrer: the page a browser came from when it loaded the current page.
- Session: the state of being signed in, kept alive by data the site stores in your browser.
- Cookie / session token: small pieces of data a site stores in your browser so it can recognise you on later requests.
- localStorage: a storage area inside the browser, tied to a website's address, that keeps values across page loads and tabs.
- HTML file: a text file written in the language browsers use to display pages; it can be opened locally from your computer.
onClickhandler: a piece of code attached to an element that runs when the user clicks it.window.location.replace: a browser instruction that sends the page to a new address and replaces the current entry in history.- Interstitial page: a page shown between you and your destination, often a warning or confirmation step.
- Recon: the exploratory phase of looking around a target to find things worth testing.
- Authentication state: whether the site currently recognises you as signed in or not.