Tools / ForgeRock IAM interview questions
What is PKCE in ForgeRock AM and why is it important for public clients?
PKCE stands for Proof Key for Code Exchange (RFC 7636). It is a security extension to the OAuth 2.0 Authorization Code flow that protects against the authorization code interception attack — a threat where a malicious app on the same device intercepts the authorization code before the legitimate application can exchange it for a token.
The attack is possible because, on mobile and desktop platforms, multiple apps can register for the same custom URI scheme (e.g., myapp://callback). When AM redirects back after authentication, any app registered for that scheme can receive the code. Without PKCE, the malicious app could exchange the stolen code for tokens.
PKCE adds a cryptographic challenge/verifier pair to the flow:
- The client generates a cryptographically random code verifier (a high-entropy string).
- The client computes a code challenge by hashing the verifier with SHA-256 (S256 method) and base64url-encoding it.
- The client sends the
code_challengeandcode_challenge_method=S256in the authorization request to AM. - AM stores the challenge with the authorization code in CTS.
- When the client exchanges the code, it sends the original
code_verifier. - AM hashes the verifier and compares it against the stored challenge. They must match for the exchange to succeed.
A malicious app that intercepts only the authorization code cannot complete the exchange because it does not know the original code verifier. In ForgeRock AM, PKCE can be enforced on a per-client basis. For AM 7.x, PKCE is mandatory by default for public clients (those without a client secret) and strongly recommended for all Authorization Code flows. This aligns with OAuth 2.1's direction of making PKCE universally required.
More Related questions...