Reputation: 415
I've been reading the OAuth2 specs over and over, but I can't figure out one thing. Isn't the Authorization Code flow without Client Secret (which is now recommended for single page apps) highly insecure because it can easily be used for phishing? Let me explain:
Now, in reality, the Client that requested the authorization is a phishing site which the user, unfortunately, didn't recognize. The Redirect URL passed to the Authorization Server points to the malicious Client, not to the legitimate one. The Client ID is a public information, so setting up such site is fairly easy.
What will happen if the Client Secret is required?
But what if the Resource Server doesn't require the Client Secret?
Am I missing something or is this correct and there's nothing that can be done to make using OAuth2 with single page apps more secure?
Upvotes: 6
Views: 8259
Reputation: 393
The resource server doesn't require a client_secret
as only valid clients can obtain an redeem an authorization code.
A client must be validated against not only the client_id
but also the redirect_uri
that is registered to the client. When registering an OAuth Client you should require a list of permitted redirect_uri's that are permitted for use with the client_id
.
So if a malicious client made a request it would fail validation as you must only redirect if the redirect_uri
is permitted.
This is detailed in the OAuth 2.0 RFC under section 3.1.2.2 https://www.rfc-editor.org/rfc/rfc6749#section-3.1.2.2
Upvotes: 12