Bypass PKCE in Mozilla VPN on Windows
The Mozilla VPN Windows client stored the PKCE code verifier in a world-readable location, so any local application could read it. A malicious app could register a protocol handler to capture the authorization code and then combine it with the verifier to obtain an access token.
- Fixed in 7 days
- Paid in 34 days
- Disclosed after 7 days
This is a bug in the Mozilla VPN Windows client (https://github.com/mozilla-services/guardian-vpn-windows) version 1.2.
While reading the source code of the Windows client with the intention of implementing the new authentication flow for MozWire (https://github.com/NilsIrl/MozWire/), I found the issue.
The new authentication flow uses PKCE (RFC 7636, https://tools.ietf.org/html/rfc7636). PKCE uses a secret code verifier so that even if a malicious application can observe the response and access the authorization code (by registering its own protocol handler for example), the malicious application cannot retrieve an access token.
However, in the Windows client, the secret code verifier is stored in "CommonApplicationData" (C:\ProgramData) which is world readable. This means that a malicious application could register a protocol handler to retrieve the authorization code and then use the code verifier stored in C:\ProgramData\moz_gen_cvf.txt to get an access token.
Possible solutions:
* Store the code verifier in a safer place (e.g. in the user's home folder in C:\Users).
* Revert to the old flow
* Have the process which generated the code verifier be able to access the authorization code rather than the other way round (currently the process with the authorization code is the one accessing the code verifier), this can be done my using interprocess communication or by storing the authorization code on the filesystem (storing the authorization code on the filesystem wouldn't be an issue as the whole point of PKCE is to prevent a malicious app from getting an access token when it has an authorization code).
Line where the code verifier is written to a world readable location: https://github.com/mozilla-services/guardian-vpn-windows/blob/ac6f562973a83f6758cd7ab7aa313e863047d41b/ui/src/FxA/Login.cs#L64
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
A malicious local application could obtain an access token for the victim's account, defeating the protection PKCE is meant to provide.
What the attacker needed
Malicious app on the same machine; victim logs in through the client
The fix
The code verifier should be stored in a safer location such as the user's home folder, or the flow should be changed so the process holding the authorization code cannot read the verifier.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you log in to an app, it sometimes uses a temporary secret to prove it is really the same app that started the login. This report found that secret was saved in a folder any program on the computer can read. So another program could grab the login code and the secret, then get into the account.
What is OAuth / SSO?
Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.