Browsers need to change how autofill works
Typically, the highest impact of an XSS vulnerability on the web is gaining access to a victimâs account on the vulnerable website (either through a session token or by performing actions on their behalf while your code is running). If youâre particularly unlucky, an admin account could be exploited to perform more dangerous actions (like accessing additional user data) or something along those lines.
However, there is a known issue with Chrome and Firefox that nobody seems to be talking about. This issue allows attackers to escalate a vulnerability into something persistent that crosses security boundaries into other parts of the victimâs digital life. Moreover, it can enable persistent access to accounts, even if a site uses HttpOnly
cookies or short-lived tokens.
People reuse passwords. #
People reuse passwords across sitesâitâs just a fact. Even if you set that aside, I would consider this a vulnerability (or at least undesirable behavior) that more people should be aware of.
Aside from phishing attacks or compromising a siteâs login flow, there should be no way for any vulnerability on a site to leak usersâ passwords.
Unfortunately, Chrome and Firefox currently trade security for convenience, automatically filling password fields when you visit a websiteâwith no user interaction required. This allows malicious code on a website to exfiltrate your login credentials without any visual indication that itâs happening.
Firefox
Google Chrome
Safari is not vulnerable to this. #
Safari: clearly requires user interaction in the form of biometricsâthis is good!
Itâs trivial for malicious JavaScript to insert a hidden login form and then read the values out, allowing it to exfiltrate your password with minimal (or no) visual indication or confirmation. On Firefox, my brief testing shows that this can happen on page load. Chrome, however, requires some user interaction before the input values can actually be readâalthough this could easily be triggered by an event on any click. Regardless, both browsers are vulnerable to this.
<form action="/form" method="POST" style="display: none;">
<label for="username">Username:</label>
<input
type="text"
id="username"
name="username"
placeholder="Enter your username"
required
/>
<label for="password">Password:</label>
<input
type="password"
id="password"
name="password"
placeholder="Enter your password"
required
/>
<button type="submit">Submit</button>
</form>
<button
onclick="alert(`username: ${document.forms[0].elements.username.value}\npassword: ${document.forms[0].elements.password.value}`)"
>
Leak my credentials
</button>
Of course, this wouldnât be as big of an issue if users didnât reuse passwords. Although, it is a little ironic how, in this case, itâs the password manager thatâs causing the problem.
Real-world applicability #
While this may seem like a fringe or extreme issue, Iâve been able to use this bug to escalate the severity of two other issues. In both cases, I found a way to upload arbitrary HTML files to a trusted domain. However, an XSS vulnerability alone was not able to exfiltrate much (due to a tight CSP), but this autofill trick worked and allowed me to leak login credentials.
Solutions #
Perhaps browsers shouldnât autofill inputs that arenât directly visible to users, or they should at least prompt users before autofilling credentials (ideally with a biometric verification step). Safari does this very well.
Try it out here: Demo