A system where I work is set up to authenticate users of a single page app (with a backend) via an OAuth Authorization code grant, without PKCE.
So:
- User clicks login and is redirected to the auth server
- User authenticates, and gets redirected back to the callback url with an authorization code
- The client sends the authorization code to a public endpoint on our backend
- The backend endpoint supplies a client id and secret, along with the authorization code in exchange for an access token & refresh token, then it returns them to the client in the response.
- The client can now make authenticated requests to our API using the access token
As the endpoint in step 3 is publicly accessible, what is to stop an attacker from intercepting the authorisation code and sending a request via postman to the endpoint so that they receive the token instead of our client?
My understanding is that this is why the PKCE extension is now recommended but I'm far from an expert.
As the public endpoint adds in the client secret, it's similar to the authorization server not asking for a client secret at all. Anyone can call the endpoint with a code and have it pass the code + secret to the authorisation server.
Is that a vulnerability or am I worrying about nothing? If not, then why does OAuth require a client_secret at all for an Authorization code grant?
Thank you!